167754Smsmith/****************************************************************************** 267754Smsmith * 3239340Sjkim * Module Name: utxface - External interfaces, miscellaneous utility functions 467754Smsmith * 567754Smsmith *****************************************************************************/ 667754Smsmith 7217365Sjkim/* 8306536Sjkim * Copyright (C) 2000 - 2016, Intel Corp. 970243Smsmith * All rights reserved. 1067754Smsmith * 11217365Sjkim * Redistribution and use in source and binary forms, with or without 12217365Sjkim * modification, are permitted provided that the following conditions 13217365Sjkim * are met: 14217365Sjkim * 1. Redistributions of source code must retain the above copyright 15217365Sjkim * notice, this list of conditions, and the following disclaimer, 16217365Sjkim * without modification. 17217365Sjkim * 2. Redistributions in binary form must reproduce at minimum a disclaimer 18217365Sjkim * substantially similar to the "NO WARRANTY" disclaimer below 19217365Sjkim * ("Disclaimer") and any redistribution must be conditioned upon 20217365Sjkim * including a substantially similar Disclaimer requirement for further 21217365Sjkim * binary redistribution. 22217365Sjkim * 3. Neither the names of the above-listed copyright holders nor the names 23217365Sjkim * of any contributors may be used to endorse or promote products derived 24217365Sjkim * from this software without specific prior written permission. 2567754Smsmith * 26217365Sjkim * Alternatively, this software may be distributed under the terms of the 27217365Sjkim * GNU General Public License ("GPL") version 2 as published by the Free 28217365Sjkim * Software Foundation. 2967754Smsmith * 30217365Sjkim * NO WARRANTY 31217365Sjkim * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 32217365Sjkim * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 33217365Sjkim * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 34217365Sjkim * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 35217365Sjkim * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 36217365Sjkim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 37217365Sjkim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 38217365Sjkim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 39217365Sjkim * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 40217365Sjkim * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 41217365Sjkim * POSSIBILITY OF SUCH DAMAGES. 42217365Sjkim */ 4367754Smsmith 44281075Sdim#define EXPORT_ACPI_INTERFACES 4567754Smsmith 46193341Sjkim#include <contrib/dev/acpica/include/acpi.h> 47193341Sjkim#include <contrib/dev/acpica/include/accommon.h> 48193341Sjkim#include <contrib/dev/acpica/include/acdebug.h> 4967754Smsmith 5077424Smsmith#define _COMPONENT ACPI_UTILITIES 5191116Smsmith ACPI_MODULE_NAME ("utxface") 5267754Smsmith 5367754Smsmith 5467754Smsmith/******************************************************************************* 5567754Smsmith * 5667754Smsmith * FUNCTION: AcpiTerminate 5767754Smsmith * 5867754Smsmith * PARAMETERS: None 5967754Smsmith * 6067754Smsmith * RETURN: Status 6167754Smsmith * 62197104Sjkim * DESCRIPTION: Shutdown the ACPICA subsystem and release all resources. 6367754Smsmith * 6467754Smsmith ******************************************************************************/ 6567754Smsmith 6667754SmsmithACPI_STATUS 67151937SjkimAcpiTerminate ( 68151937Sjkim void) 6967754Smsmith{ 7099679Siwasaki ACPI_STATUS Status; 7199679Siwasaki 7299679Siwasaki 73167802Sjkim ACPI_FUNCTION_TRACE (AcpiTerminate); 7467754Smsmith 7567754Smsmith 7667754Smsmith /* Shutdown and free all resources */ 7767754Smsmith 7877424Smsmith AcpiUtSubsystemShutdown (); 7967754Smsmith 8067754Smsmith /* Free the mutex objects */ 8167754Smsmith 8277424Smsmith AcpiUtMutexTerminate (); 8367754Smsmith 8467754Smsmith /* Now we can shutdown the OS-dependent layer */ 8567754Smsmith 8699679Siwasaki Status = AcpiOsTerminate (); 8799679Siwasaki return_ACPI_STATUS (Status); 8867754Smsmith} 8967754Smsmith 90281075SdimACPI_EXPORT_SYMBOL_INIT (AcpiTerminate) 9167754Smsmith 92197104Sjkim 93193267Sjkim#ifndef ACPI_ASL_COMPILER 94151937Sjkim/******************************************************************************* 9580062Smsmith * 9680062Smsmith * FUNCTION: AcpiSubsystemStatus 9780062Smsmith * 9880062Smsmith * PARAMETERS: None 9980062Smsmith * 10080062Smsmith * RETURN: Status of the ACPI subsystem 10180062Smsmith * 10280062Smsmith * DESCRIPTION: Other drivers that use the ACPI subsystem should call this 103151937Sjkim * before making any other calls, to ensure the subsystem 104151937Sjkim * initialized successfully. 10580062Smsmith * 106151937Sjkim ******************************************************************************/ 10780062Smsmith 10880062SmsmithACPI_STATUS 109151937SjkimAcpiSubsystemStatus ( 110151937Sjkim void) 11180062Smsmith{ 112151937Sjkim 11380062Smsmith if (AcpiGbl_StartupFlags & ACPI_INITIALIZED_OK) 11480062Smsmith { 11580062Smsmith return (AE_OK); 11680062Smsmith } 11780062Smsmith else 11880062Smsmith { 11980062Smsmith return (AE_ERROR); 12080062Smsmith } 12180062Smsmith} 12280062Smsmith 123167802SjkimACPI_EXPORT_SYMBOL (AcpiSubsystemStatus) 12480062Smsmith 125167802Sjkim 126151937Sjkim/******************************************************************************* 12767754Smsmith * 12867754Smsmith * FUNCTION: AcpiGetSystemInfo 12967754Smsmith * 130151937Sjkim * PARAMETERS: OutBuffer - A buffer to receive the resources for the 131151937Sjkim * device 13267754Smsmith * 13367754Smsmith * RETURN: Status - the status of the call 13467754Smsmith * 13567754Smsmith * DESCRIPTION: This function is called to get information about the current 136241973Sjkim * state of the ACPI subsystem. It will return system information 13767754Smsmith * in the OutBuffer. 13867754Smsmith * 13967754Smsmith * If the function fails an appropriate status will be returned 14067754Smsmith * and the value of OutBuffer is undefined. 14167754Smsmith * 14267754Smsmith ******************************************************************************/ 14367754Smsmith 14467754SmsmithACPI_STATUS 14567754SmsmithAcpiGetSystemInfo ( 14667754Smsmith ACPI_BUFFER *OutBuffer) 14767754Smsmith{ 14867754Smsmith ACPI_SYSTEM_INFO *InfoPtr; 149151937Sjkim ACPI_STATUS Status; 15067754Smsmith 15167754Smsmith 152167802Sjkim ACPI_FUNCTION_TRACE (AcpiGetSystemInfo); 15367754Smsmith 15467754Smsmith 15591116Smsmith /* Parameter validation */ 15691116Smsmith 15791116Smsmith Status = AcpiUtValidateBuffer (OutBuffer); 15891116Smsmith if (ACPI_FAILURE (Status)) 15967754Smsmith { 16091116Smsmith return_ACPI_STATUS (Status); 16167754Smsmith } 16267754Smsmith 16391116Smsmith /* Validate/Allocate/Clear caller buffer */ 16491116Smsmith 16591116Smsmith Status = AcpiUtInitializeBuffer (OutBuffer, sizeof (ACPI_SYSTEM_INFO)); 16691116Smsmith if (ACPI_FAILURE (Status)) 16767754Smsmith { 16891116Smsmith return_ACPI_STATUS (Status); 16967754Smsmith } 17067754Smsmith 17167754Smsmith /* 17291116Smsmith * Populate the return buffer 17367754Smsmith */ 17467754Smsmith InfoPtr = (ACPI_SYSTEM_INFO *) OutBuffer->Pointer; 175167802Sjkim InfoPtr->AcpiCaVersion = ACPI_CA_VERSION; 17667754Smsmith 17767754Smsmith /* System flags (ACPI capabilities) */ 17867754Smsmith 179167802Sjkim InfoPtr->Flags = ACPI_SYS_MODE_ACPI; 18067754Smsmith 18167754Smsmith /* Timer resolution - 24 or 32 bits */ 18291116Smsmith 183167802Sjkim if (AcpiGbl_FADT.Flags & ACPI_FADT_32BIT_TIMER) 18471867Smsmith { 18571867Smsmith InfoPtr->TimerResolution = 24; 18671867Smsmith } 18771867Smsmith else 18871867Smsmith { 18971867Smsmith InfoPtr->TimerResolution = 32; 19071867Smsmith } 19167754Smsmith 19267754Smsmith /* Clear the reserved fields */ 19367754Smsmith 194167802Sjkim InfoPtr->Reserved1 = 0; 195167802Sjkim InfoPtr->Reserved2 = 0; 19667754Smsmith 19767754Smsmith /* Current debug levels */ 19867754Smsmith 199167802Sjkim InfoPtr->DebugLayer = AcpiDbgLayer; 200167802Sjkim InfoPtr->DebugLevel = AcpiDbgLevel; 20167754Smsmith 20267754Smsmith return_ACPI_STATUS (AE_OK); 20367754Smsmith} 20467754Smsmith 205167802SjkimACPI_EXPORT_SYMBOL (AcpiGetSystemInfo) 20667754Smsmith 207167802Sjkim 208193267Sjkim/******************************************************************************* 209193267Sjkim * 210193267Sjkim * FUNCTION: AcpiGetStatistics 211193267Sjkim * 212193267Sjkim * PARAMETERS: Stats - Where the statistics are returned 213193267Sjkim * 214193267Sjkim * RETURN: Status - the status of the call 215193267Sjkim * 216193267Sjkim * DESCRIPTION: Get the contents of the various system counters 217193267Sjkim * 218193267Sjkim ******************************************************************************/ 219193267Sjkim 220193267SjkimACPI_STATUS 221193267SjkimAcpiGetStatistics ( 222193267Sjkim ACPI_STATISTICS *Stats) 223193267Sjkim{ 224193267Sjkim ACPI_FUNCTION_TRACE (AcpiGetStatistics); 225193267Sjkim 226193267Sjkim 227193267Sjkim /* Parameter validation */ 228193267Sjkim 229193267Sjkim if (!Stats) 230193267Sjkim { 231193267Sjkim return_ACPI_STATUS (AE_BAD_PARAMETER); 232193267Sjkim } 233193267Sjkim 234193267Sjkim /* Various interrupt-based event counters */ 235193267Sjkim 236193267Sjkim Stats->SciCount = AcpiSciCount; 237193267Sjkim Stats->GpeCount = AcpiGpeCount; 238193267Sjkim 239306536Sjkim memcpy (Stats->FixedEventCount, AcpiFixedEventCount, 240193267Sjkim sizeof (AcpiFixedEventCount)); 241193267Sjkim 242193267Sjkim /* Other counters */ 243193267Sjkim 244193267Sjkim Stats->MethodCount = AcpiMethodCount; 245193267Sjkim return_ACPI_STATUS (AE_OK); 246193267Sjkim} 247193267Sjkim 248193267SjkimACPI_EXPORT_SYMBOL (AcpiGetStatistics) 249193267Sjkim 250193267Sjkim 25187031Smsmith/***************************************************************************** 25287031Smsmith * 25399679Siwasaki * FUNCTION: AcpiInstallInitializationHandler 25499679Siwasaki * 25599679Siwasaki * PARAMETERS: Handler - Callback procedure 256151937Sjkim * Function - Not (currently) used, see below 25799679Siwasaki * 25899679Siwasaki * RETURN: Status 25999679Siwasaki * 26099679Siwasaki * DESCRIPTION: Install an initialization handler 26199679Siwasaki * 26299679Siwasaki * TBD: When a second function is added, must save the Function also. 26399679Siwasaki * 26499679Siwasaki ****************************************************************************/ 26599679Siwasaki 26699679SiwasakiACPI_STATUS 26799679SiwasakiAcpiInstallInitializationHandler ( 26899679Siwasaki ACPI_INIT_HANDLER Handler, 26999679Siwasaki UINT32 Function) 27099679Siwasaki{ 27199679Siwasaki 27299679Siwasaki if (!Handler) 27399679Siwasaki { 27499679Siwasaki return (AE_BAD_PARAMETER); 27599679Siwasaki } 27699679Siwasaki 27799679Siwasaki if (AcpiGbl_InitHandler) 27899679Siwasaki { 27999679Siwasaki return (AE_ALREADY_EXISTS); 28099679Siwasaki } 28199679Siwasaki 28299679Siwasaki AcpiGbl_InitHandler = Handler; 283241973Sjkim return (AE_OK); 28499679Siwasaki} 28599679Siwasaki 286167802SjkimACPI_EXPORT_SYMBOL (AcpiInstallInitializationHandler) 28799679Siwasaki 288167802Sjkim 28999679Siwasaki/***************************************************************************** 29099679Siwasaki * 29187031Smsmith * FUNCTION: AcpiPurgeCachedObjects 29287031Smsmith * 29387031Smsmith * PARAMETERS: None 29487031Smsmith * 29587031Smsmith * RETURN: Status 29687031Smsmith * 29787031Smsmith * DESCRIPTION: Empty all caches (delete the cached objects) 29887031Smsmith * 29987031Smsmith ****************************************************************************/ 30087031Smsmith 30187031SmsmithACPI_STATUS 302151937SjkimAcpiPurgeCachedObjects ( 303151937Sjkim void) 30487031Smsmith{ 305167802Sjkim ACPI_FUNCTION_TRACE (AcpiPurgeCachedObjects); 30687031Smsmith 307241973Sjkim 308151937Sjkim (void) AcpiOsPurgeCache (AcpiGbl_StateCache); 309151937Sjkim (void) AcpiOsPurgeCache (AcpiGbl_OperandCache); 310151937Sjkim (void) AcpiOsPurgeCache (AcpiGbl_PsNodeCache); 311151937Sjkim (void) AcpiOsPurgeCache (AcpiGbl_PsNodeExtCache); 312241973Sjkim 31387031Smsmith return_ACPI_STATUS (AE_OK); 31487031Smsmith} 315167802Sjkim 316167802SjkimACPI_EXPORT_SYMBOL (AcpiPurgeCachedObjects) 317193267Sjkim 318193267Sjkim 319210976Sjkim/***************************************************************************** 320210976Sjkim * 321210976Sjkim * FUNCTION: AcpiInstallInterface 322210976Sjkim * 323210976Sjkim * PARAMETERS: InterfaceName - The interface to install 324210976Sjkim * 325210976Sjkim * RETURN: Status 326210976Sjkim * 327210976Sjkim * DESCRIPTION: Install an _OSI interface to the global list 328210976Sjkim * 329210976Sjkim ****************************************************************************/ 330210976Sjkim 331210976SjkimACPI_STATUS 332210976SjkimAcpiInstallInterface ( 333210976Sjkim ACPI_STRING InterfaceName) 334210976Sjkim{ 335210976Sjkim ACPI_STATUS Status; 336210976Sjkim ACPI_INTERFACE_INFO *InterfaceInfo; 337210976Sjkim 338210976Sjkim 339210976Sjkim /* Parameter validation */ 340210976Sjkim 341306536Sjkim if (!InterfaceName || (strlen (InterfaceName) == 0)) 342210976Sjkim { 343210976Sjkim return (AE_BAD_PARAMETER); 344210976Sjkim } 345210976Sjkim 346249112Sjkim Status = AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER); 347249112Sjkim if (ACPI_FAILURE (Status)) 348249112Sjkim { 349249112Sjkim return (Status); 350249112Sjkim } 351210976Sjkim 352210976Sjkim /* Check if the interface name is already in the global list */ 353210976Sjkim 354210976Sjkim InterfaceInfo = AcpiUtGetInterface (InterfaceName); 355210976Sjkim if (InterfaceInfo) 356210976Sjkim { 357210976Sjkim /* 358210976Sjkim * The interface already exists in the list. This is OK if the 359210976Sjkim * interface has been marked invalid -- just clear the bit. 360210976Sjkim */ 361210976Sjkim if (InterfaceInfo->Flags & ACPI_OSI_INVALID) 362210976Sjkim { 363210976Sjkim InterfaceInfo->Flags &= ~ACPI_OSI_INVALID; 364210976Sjkim Status = AE_OK; 365210976Sjkim } 366210976Sjkim else 367210976Sjkim { 368210976Sjkim Status = AE_ALREADY_EXISTS; 369210976Sjkim } 370210976Sjkim } 371210976Sjkim else 372210976Sjkim { 373210976Sjkim /* New interface name, install into the global list */ 374210976Sjkim 375210976Sjkim Status = AcpiUtInstallInterface (InterfaceName); 376210976Sjkim } 377210976Sjkim 378210976Sjkim AcpiOsReleaseMutex (AcpiGbl_OsiMutex); 379210976Sjkim return (Status); 380210976Sjkim} 381210976Sjkim 382210976SjkimACPI_EXPORT_SYMBOL (AcpiInstallInterface) 383210976Sjkim 384210976Sjkim 385210976Sjkim/***************************************************************************** 386210976Sjkim * 387210976Sjkim * FUNCTION: AcpiRemoveInterface 388210976Sjkim * 389210976Sjkim * PARAMETERS: InterfaceName - The interface to remove 390210976Sjkim * 391210976Sjkim * RETURN: Status 392210976Sjkim * 393210976Sjkim * DESCRIPTION: Remove an _OSI interface from the global list 394210976Sjkim * 395210976Sjkim ****************************************************************************/ 396210976Sjkim 397210976SjkimACPI_STATUS 398210976SjkimAcpiRemoveInterface ( 399210976Sjkim ACPI_STRING InterfaceName) 400210976Sjkim{ 401210976Sjkim ACPI_STATUS Status; 402210976Sjkim 403210976Sjkim 404210976Sjkim /* Parameter validation */ 405210976Sjkim 406306536Sjkim if (!InterfaceName || (strlen (InterfaceName) == 0)) 407210976Sjkim { 408210976Sjkim return (AE_BAD_PARAMETER); 409210976Sjkim } 410210976Sjkim 411249112Sjkim Status = AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER); 412249112Sjkim if (ACPI_FAILURE (Status)) 413249112Sjkim { 414249112Sjkim return (Status); 415249112Sjkim } 416210976Sjkim 417210976Sjkim Status = AcpiUtRemoveInterface (InterfaceName); 418210976Sjkim 419210976Sjkim AcpiOsReleaseMutex (AcpiGbl_OsiMutex); 420210976Sjkim return (Status); 421210976Sjkim} 422210976Sjkim 423210976SjkimACPI_EXPORT_SYMBOL (AcpiRemoveInterface) 424210976Sjkim 425210976Sjkim 426210976Sjkim/***************************************************************************** 427210976Sjkim * 428210976Sjkim * FUNCTION: AcpiInstallInterfaceHandler 429210976Sjkim * 430210976Sjkim * PARAMETERS: Handler - The _OSI interface handler to install 431210976Sjkim * NULL means "remove existing handler" 432210976Sjkim * 433210976Sjkim * RETURN: Status 434210976Sjkim * 435210976Sjkim * DESCRIPTION: Install a handler for the predefined _OSI ACPI method. 436210976Sjkim * invoked during execution of the internal implementation of 437210976Sjkim * _OSI. A NULL handler simply removes any existing handler. 438210976Sjkim * 439210976Sjkim ****************************************************************************/ 440210976Sjkim 441210976SjkimACPI_STATUS 442210976SjkimAcpiInstallInterfaceHandler ( 443210976Sjkim ACPI_INTERFACE_HANDLER Handler) 444210976Sjkim{ 445249112Sjkim ACPI_STATUS Status; 446210976Sjkim 447210976Sjkim 448249112Sjkim Status = AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER); 449249112Sjkim if (ACPI_FAILURE (Status)) 450249112Sjkim { 451249112Sjkim return (Status); 452249112Sjkim } 453210976Sjkim 454210976Sjkim if (Handler && AcpiGbl_InterfaceHandler) 455210976Sjkim { 456210976Sjkim Status = AE_ALREADY_EXISTS; 457210976Sjkim } 458210976Sjkim else 459210976Sjkim { 460210976Sjkim AcpiGbl_InterfaceHandler = Handler; 461210976Sjkim } 462210976Sjkim 463210976Sjkim AcpiOsReleaseMutex (AcpiGbl_OsiMutex); 464210976Sjkim return (Status); 465210976Sjkim} 466210976Sjkim 467210976SjkimACPI_EXPORT_SYMBOL (AcpiInstallInterfaceHandler) 468210976Sjkim 469229989Sjkim 470229989Sjkim/***************************************************************************** 471229989Sjkim * 472253690Sjkim * FUNCTION: AcpiUpdateInterfaces 473253690Sjkim * 474253690Sjkim * PARAMETERS: Action - Actions to be performed during the 475253690Sjkim * update 476253690Sjkim * 477253690Sjkim * RETURN: Status 478253690Sjkim * 479253690Sjkim * DESCRIPTION: Update _OSI interface strings, disabling or enabling OS vendor 480253690Sjkim * string or/and feature group strings. 481253690Sjkim * 482253690Sjkim ****************************************************************************/ 483253690Sjkim 484253690SjkimACPI_STATUS 485253690SjkimAcpiUpdateInterfaces ( 486253690Sjkim UINT8 Action) 487253690Sjkim{ 488253690Sjkim ACPI_STATUS Status; 489253690Sjkim 490253690Sjkim 491253690Sjkim Status = AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER); 492253690Sjkim if (ACPI_FAILURE (Status)) 493253690Sjkim { 494253690Sjkim return (Status); 495253690Sjkim } 496253690Sjkim 497253690Sjkim Status = AcpiUtUpdateInterfaces (Action); 498253690Sjkim 499253690Sjkim AcpiOsReleaseMutex (AcpiGbl_OsiMutex); 500253690Sjkim return (Status); 501253690Sjkim} 502253690Sjkim 503253690Sjkim 504253690Sjkim/***************************************************************************** 505253690Sjkim * 506229989Sjkim * FUNCTION: AcpiCheckAddressRange 507229989Sjkim * 508229989Sjkim * PARAMETERS: SpaceId - Address space ID 509229989Sjkim * Address - Start address 510229989Sjkim * Length - Length 511229989Sjkim * Warn - TRUE if warning on overlap desired 512229989Sjkim * 513229989Sjkim * RETURN: Count of the number of conflicts detected. 514229989Sjkim * 515229989Sjkim * DESCRIPTION: Check if the input address range overlaps any of the 516229989Sjkim * ASL operation region address ranges. 517229989Sjkim * 518229989Sjkim ****************************************************************************/ 519229989Sjkim 520229989SjkimUINT32 521229989SjkimAcpiCheckAddressRange ( 522229989Sjkim ACPI_ADR_SPACE_TYPE SpaceId, 523229989Sjkim ACPI_PHYSICAL_ADDRESS Address, 524229989Sjkim ACPI_SIZE Length, 525229989Sjkim BOOLEAN Warn) 526229989Sjkim{ 527229989Sjkim UINT32 Overlaps; 528229989Sjkim ACPI_STATUS Status; 529229989Sjkim 530229989Sjkim 531229989Sjkim Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); 532229989Sjkim if (ACPI_FAILURE (Status)) 533229989Sjkim { 534229989Sjkim return (0); 535229989Sjkim } 536229989Sjkim 537229989Sjkim Overlaps = AcpiUtCheckAddressRange (SpaceId, Address, 538229989Sjkim (UINT32) Length, Warn); 539229989Sjkim 540229989Sjkim (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); 541229989Sjkim return (Overlaps); 542229989Sjkim} 543229989Sjkim 544229989SjkimACPI_EXPORT_SYMBOL (AcpiCheckAddressRange) 545229989Sjkim 546210976Sjkim#endif /* !ACPI_ASL_COMPILER */ 547239340Sjkim 548239340Sjkim 549239340Sjkim/******************************************************************************* 550239340Sjkim * 551239340Sjkim * FUNCTION: AcpiDecodePldBuffer 552239340Sjkim * 553239340Sjkim * PARAMETERS: InBuffer - Buffer returned by _PLD method 554239340Sjkim * Length - Length of the InBuffer 555239340Sjkim * ReturnBuffer - Where the decode buffer is returned 556239340Sjkim * 557239340Sjkim * RETURN: Status and the decoded _PLD buffer. User must deallocate 558239340Sjkim * the buffer via ACPI_FREE. 559239340Sjkim * 560239340Sjkim * DESCRIPTION: Decode the bit-packed buffer returned by the _PLD method into 561239340Sjkim * a local struct that is much more useful to an ACPI driver. 562239340Sjkim * 563239340Sjkim ******************************************************************************/ 564239340Sjkim 565239340SjkimACPI_STATUS 566239340SjkimAcpiDecodePldBuffer ( 567239340Sjkim UINT8 *InBuffer, 568239340Sjkim ACPI_SIZE Length, 569239340Sjkim ACPI_PLD_INFO **ReturnBuffer) 570239340Sjkim{ 571239340Sjkim ACPI_PLD_INFO *PldInfo; 572239340Sjkim UINT32 *Buffer = ACPI_CAST_PTR (UINT32, InBuffer); 573239340Sjkim UINT32 Dword; 574239340Sjkim 575239340Sjkim 576239340Sjkim /* Parameter validation */ 577239340Sjkim 578306536Sjkim if (!InBuffer || !ReturnBuffer || (Length < ACPI_PLD_REV1_BUFFER_SIZE)) 579239340Sjkim { 580239340Sjkim return (AE_BAD_PARAMETER); 581239340Sjkim } 582239340Sjkim 583239340Sjkim PldInfo = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_PLD_INFO)); 584239340Sjkim if (!PldInfo) 585239340Sjkim { 586239340Sjkim return (AE_NO_MEMORY); 587239340Sjkim } 588239340Sjkim 589239340Sjkim /* First 32-bit DWord */ 590239340Sjkim 591239340Sjkim ACPI_MOVE_32_TO_32 (&Dword, &Buffer[0]); 592239340Sjkim PldInfo->Revision = ACPI_PLD_GET_REVISION (&Dword); 593239340Sjkim PldInfo->IgnoreColor = ACPI_PLD_GET_IGNORE_COLOR (&Dword); 594281075Sdim PldInfo->Red = ACPI_PLD_GET_RED (&Dword); 595281075Sdim PldInfo->Green = ACPI_PLD_GET_GREEN (&Dword); 596281075Sdim PldInfo->Blue = ACPI_PLD_GET_BLUE (&Dword); 597239340Sjkim 598239340Sjkim /* Second 32-bit DWord */ 599239340Sjkim 600239340Sjkim ACPI_MOVE_32_TO_32 (&Dword, &Buffer[1]); 601239340Sjkim PldInfo->Width = ACPI_PLD_GET_WIDTH (&Dword); 602239340Sjkim PldInfo->Height = ACPI_PLD_GET_HEIGHT(&Dword); 603239340Sjkim 604239340Sjkim /* Third 32-bit DWord */ 605239340Sjkim 606239340Sjkim ACPI_MOVE_32_TO_32 (&Dword, &Buffer[2]); 607239340Sjkim PldInfo->UserVisible = ACPI_PLD_GET_USER_VISIBLE (&Dword); 608239340Sjkim PldInfo->Dock = ACPI_PLD_GET_DOCK (&Dword); 609239340Sjkim PldInfo->Lid = ACPI_PLD_GET_LID (&Dword); 610239340Sjkim PldInfo->Panel = ACPI_PLD_GET_PANEL (&Dword); 611239340Sjkim PldInfo->VerticalPosition = ACPI_PLD_GET_VERTICAL (&Dword); 612239340Sjkim PldInfo->HorizontalPosition = ACPI_PLD_GET_HORIZONTAL (&Dword); 613239340Sjkim PldInfo->Shape = ACPI_PLD_GET_SHAPE (&Dword); 614239340Sjkim PldInfo->GroupOrientation = ACPI_PLD_GET_ORIENTATION (&Dword); 615239340Sjkim PldInfo->GroupToken = ACPI_PLD_GET_TOKEN (&Dword); 616239340Sjkim PldInfo->GroupPosition = ACPI_PLD_GET_POSITION (&Dword); 617239340Sjkim PldInfo->Bay = ACPI_PLD_GET_BAY (&Dword); 618239340Sjkim 619239340Sjkim /* Fourth 32-bit DWord */ 620239340Sjkim 621239340Sjkim ACPI_MOVE_32_TO_32 (&Dword, &Buffer[3]); 622239340Sjkim PldInfo->Ejectable = ACPI_PLD_GET_EJECTABLE (&Dword); 623239340Sjkim PldInfo->OspmEjectRequired = ACPI_PLD_GET_OSPM_EJECT (&Dword); 624239340Sjkim PldInfo->CabinetNumber = ACPI_PLD_GET_CABINET (&Dword); 625239340Sjkim PldInfo->CardCageNumber = ACPI_PLD_GET_CARD_CAGE (&Dword); 626239340Sjkim PldInfo->Reference = ACPI_PLD_GET_REFERENCE (&Dword); 627239340Sjkim PldInfo->Rotation = ACPI_PLD_GET_ROTATION (&Dword); 628239340Sjkim PldInfo->Order = ACPI_PLD_GET_ORDER (&Dword); 629239340Sjkim 630306536Sjkim if (Length >= ACPI_PLD_REV2_BUFFER_SIZE) 631239340Sjkim { 632239340Sjkim /* Fifth 32-bit DWord (Revision 2 of _PLD) */ 633239340Sjkim 634239340Sjkim ACPI_MOVE_32_TO_32 (&Dword, &Buffer[4]); 635239340Sjkim PldInfo->VerticalOffset = ACPI_PLD_GET_VERT_OFFSET (&Dword); 636239340Sjkim PldInfo->HorizontalOffset = ACPI_PLD_GET_HORIZ_OFFSET (&Dword); 637239340Sjkim } 638239340Sjkim 639239340Sjkim *ReturnBuffer = PldInfo; 640239340Sjkim return (AE_OK); 641239340Sjkim} 642239340Sjkim 643239340SjkimACPI_EXPORT_SYMBOL (AcpiDecodePldBuffer) 644