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

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/intel/io/acpica/utilities/utcache.c
          +++ new/usr/src/common/acpica/components/utilities/utcache.c
   1    1  /******************************************************************************
   2    2   *
   3    3   * Module Name: utcache - local cache allocation routines
   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 ↓ 69 lines elided ↑ open up ↑
  88   88  
  89   89      Cache = AcpiOsAllocate (sizeof (ACPI_MEMORY_LIST));
  90   90      if (!Cache)
  91   91      {
  92   92          return (AE_NO_MEMORY);
  93   93      }
  94   94  
  95   95      /* Populate the cache object and return it */
  96   96  
  97   97      ACPI_MEMSET (Cache, 0, sizeof (ACPI_MEMORY_LIST));
  98      -    Cache->LinkOffset = 8;
  99   98      Cache->ListName   = CacheName;
 100   99      Cache->ObjectSize = ObjectSize;
 101  100      Cache->MaxDepth   = MaxDepth;
 102  101  
 103  102      *ReturnCache = Cache;
 104  103      return (AE_OK);
 105  104  }
 106  105  
 107  106  
 108  107  /*******************************************************************************
↓ open down ↓ 5 lines elided ↑ open up ↑
 114  113   * RETURN:      Status
 115  114   *
 116  115   * DESCRIPTION: Free all objects within the requested cache.
 117  116   *
 118  117   ******************************************************************************/
 119  118  
 120  119  ACPI_STATUS
 121  120  AcpiOsPurgeCache (
 122  121      ACPI_MEMORY_LIST        *Cache)
 123  122  {
 124      -    char                    *Next;
      123 +    void                    *Next;
 125  124      ACPI_STATUS             Status;
 126  125  
 127  126  
 128  127      ACPI_FUNCTION_ENTRY ();
 129  128  
 130  129  
 131  130      if (!Cache)
 132  131      {
 133  132          return (AE_BAD_PARAMETER);
 134  133      }
↓ open down ↓ 3 lines elided ↑ open up ↑
 138  137      {
 139  138          return (Status);
 140  139      }
 141  140  
 142  141      /* Walk the list of objects in this cache */
 143  142  
 144  143      while (Cache->ListHead)
 145  144      {
 146  145          /* Delete and unlink one cached state object */
 147  146  
 148      -        Next = *(ACPI_CAST_INDIRECT_PTR (char,
 149      -                    &(((char *) Cache->ListHead)[Cache->LinkOffset])));
      147 +        Next = ACPI_GET_DESCRIPTOR_PTR (Cache->ListHead);
 150  148          ACPI_FREE (Cache->ListHead);
 151  149  
 152  150          Cache->ListHead = Next;
 153  151          Cache->CurrentDepth--;
 154  152      }
 155  153  
 156  154      (void) AcpiUtReleaseMutex (ACPI_MTX_CACHES);
 157  155      return (AE_OK);
 158  156  }
 159  157  
↓ open down ↓ 38 lines elided ↑ open up ↑
 198  196  
 199  197  /*******************************************************************************
 200  198   *
 201  199   * FUNCTION:    AcpiOsReleaseObject
 202  200   *
 203  201   * PARAMETERS:  Cache       - Handle to cache object
 204  202   *              Object      - The object to be released
 205  203   *
 206  204   * RETURN:      None
 207  205   *
 208      - * DESCRIPTION: Release an object to the specified cache.  If cache is full,
      206 + * DESCRIPTION: Release an object to the specified cache. If cache is full,
 209  207   *              the object is deleted.
 210  208   *
 211  209   ******************************************************************************/
 212  210  
 213  211  ACPI_STATUS
 214  212  AcpiOsReleaseObject (
 215  213      ACPI_MEMORY_LIST        *Cache,
 216  214      void                    *Object)
 217  215  {
 218  216      ACPI_STATUS             Status;
↓ open down ↓ 25 lines elided ↑ open up ↑
 244  242              return (Status);
 245  243          }
 246  244  
 247  245          /* Mark the object as cached */
 248  246  
 249  247          ACPI_MEMSET (Object, 0xCA, Cache->ObjectSize);
 250  248          ACPI_SET_DESCRIPTOR_TYPE (Object, ACPI_DESC_TYPE_CACHED);
 251  249  
 252  250          /* Put the object at the head of the cache list */
 253  251  
 254      -        * (ACPI_CAST_INDIRECT_PTR (char,
 255      -            &(((char *) Object)[Cache->LinkOffset]))) = Cache->ListHead;
      252 +        ACPI_SET_DESCRIPTOR_PTR (Object, Cache->ListHead);
 256  253          Cache->ListHead = Object;
 257  254          Cache->CurrentDepth++;
 258  255  
 259  256          (void) AcpiUtReleaseMutex (ACPI_MTX_CACHES);
 260  257      }
 261  258  
 262  259      return (AE_OK);
 263  260  }
 264  261  
 265  262  
 266  263  /*******************************************************************************
 267  264   *
 268  265   * FUNCTION:    AcpiOsAcquireObject
 269  266   *
 270  267   * PARAMETERS:  Cache           - Handle to cache object
 271  268   *
 272      - * RETURN:      the acquired object.  NULL on error
      269 + * RETURN:      the acquired object. NULL on error
 273  270   *
 274      - * DESCRIPTION: Get an object from the specified cache.  If cache is empty,
      271 + * DESCRIPTION: Get an object from the specified cache. If cache is empty,
 275  272   *              the object is allocated.
 276  273   *
 277  274   ******************************************************************************/
 278  275  
 279  276  void *
 280  277  AcpiOsAcquireObject (
 281  278      ACPI_MEMORY_LIST        *Cache)
 282  279  {
 283  280      ACPI_STATUS             Status;
 284  281      void                    *Object;
 285  282  
 286  283  
 287  284      ACPI_FUNCTION_NAME (OsAcquireObject);
 288  285  
 289  286  
 290  287      if (!Cache)
 291  288      {
 292      -        return (NULL);
      289 +        return_PTR (NULL);
 293  290      }
 294  291  
 295  292      Status = AcpiUtAcquireMutex (ACPI_MTX_CACHES);
 296  293      if (ACPI_FAILURE (Status))
 297  294      {
 298      -        return (NULL);
      295 +        return_PTR (NULL);
 299  296      }
 300  297  
 301  298      ACPI_MEM_TRACKING (Cache->Requests++);
 302  299  
 303  300      /* Check the cache first */
 304  301  
 305  302      if (Cache->ListHead)
 306  303      {
 307  304          /* There is an object available, use it */
 308  305  
 309  306          Object = Cache->ListHead;
 310      -        Cache->ListHead = *(ACPI_CAST_INDIRECT_PTR (char,
 311      -                                &(((char *) Object)[Cache->LinkOffset])));
      307 +        Cache->ListHead = ACPI_GET_DESCRIPTOR_PTR (Object);
 312  308  
 313  309          Cache->CurrentDepth--;
 314  310  
 315  311          ACPI_MEM_TRACKING (Cache->Hits++);
 316  312          ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
 317  313              "Object %p from %s cache\n", Object, Cache->ListName));
 318  314  
 319  315          Status = AcpiUtReleaseMutex (ACPI_MTX_CACHES);
 320  316          if (ACPI_FAILURE (Status))
 321  317          {
 322      -            return (NULL);
      318 +            return_PTR (NULL);
 323  319          }
 324  320  
 325  321          /* Clear (zero) the previously used Object */
 326  322  
 327  323          ACPI_MEMSET (Object, 0, Cache->ObjectSize);
 328  324      }
 329  325      else
 330  326      {
 331  327          /* The cache is empty, create a new object */
 332  328  
↓ open down ↓ 4 lines elided ↑ open up ↑
 337  333          {
 338  334              Cache->MaxOccupied = Cache->TotalAllocated - Cache->TotalFreed;
 339  335          }
 340  336  #endif
 341  337  
 342  338          /* Avoid deadlock with ACPI_ALLOCATE_ZEROED */
 343  339  
 344  340          Status = AcpiUtReleaseMutex (ACPI_MTX_CACHES);
 345  341          if (ACPI_FAILURE (Status))
 346  342          {
 347      -            return (NULL);
      343 +            return_PTR (NULL);
 348  344          }
 349  345  
 350  346          Object = ACPI_ALLOCATE_ZEROED (Cache->ObjectSize);
 351  347          if (!Object)
 352  348          {
 353      -            return (NULL);
      349 +            return_PTR (NULL);
 354  350          }
 355  351      }
 356  352  
 357      -    return (Object);
      353 +    return_PTR (Object);
 358  354  }
 359  355  #endif /* ACPI_USE_LOCAL_CACHE */
 360      -
 361      -
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX