167754Smsmith/****************************************************************************** 267754Smsmith * 377424Smsmith * Module Name: exregion - ACPI default OpRegion (address space) handlers 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 44193341Sjkim#include <contrib/dev/acpica/include/acpi.h> 45193341Sjkim#include <contrib/dev/acpica/include/accommon.h> 46193341Sjkim#include <contrib/dev/acpica/include/acinterp.h> 4767754Smsmith 4867754Smsmith 4977424Smsmith#define _COMPONENT ACPI_EXECUTER 5091116Smsmith ACPI_MODULE_NAME ("exregion") 5167754Smsmith 5267754Smsmith 5367754Smsmith/******************************************************************************* 5467754Smsmith * 5577424Smsmith * FUNCTION: AcpiExSystemMemorySpaceHandler 5667754Smsmith * 5767754Smsmith * PARAMETERS: Function - Read or Write operation 5867754Smsmith * Address - Where in the space to read or write 5967754Smsmith * BitWidth - Field width in bits (8, 16, or 32) 6067754Smsmith * Value - Pointer to in or out value 6167754Smsmith * HandlerContext - Pointer to Handler's context 6267754Smsmith * RegionContext - Pointer to context specific to the 6384491Smsmith * accessed region 6467754Smsmith * 6567754Smsmith * RETURN: Status 6667754Smsmith * 6767754Smsmith * DESCRIPTION: Handler for the System Memory address space (Op Region) 6867754Smsmith * 6967754Smsmith ******************************************************************************/ 7067754Smsmith 7167754SmsmithACPI_STATUS 7277424SmsmithAcpiExSystemMemorySpaceHandler ( 7367754Smsmith UINT32 Function, 7469450Smsmith ACPI_PHYSICAL_ADDRESS Address, 7567754Smsmith UINT32 BitWidth, 76202771Sjkim UINT64 *Value, 7767754Smsmith void *HandlerContext, 7867754Smsmith void *RegionContext) 7967754Smsmith{ 8067754Smsmith ACPI_STATUS Status = AE_OK; 8167754Smsmith void *LogicalAddrPtr = NULL; 8277424Smsmith ACPI_MEM_SPACE_CONTEXT *MemInfo = RegionContext; 8367754Smsmith UINT32 Length; 84199337Sjkim ACPI_SIZE MapLength; 85199337Sjkim ACPI_SIZE PageBoundaryMapLength; 86151937Sjkim#ifdef ACPI_MISALIGNMENT_NOT_SUPPORTED 8799679Siwasaki UINT32 Remainder; 8899679Siwasaki#endif 8967754Smsmith 9067754Smsmith 91167802Sjkim ACPI_FUNCTION_TRACE (ExSystemMemorySpaceHandler); 9267754Smsmith 93167802Sjkim 9467754Smsmith /* Validate and translate the bit width */ 9567754Smsmith 9667754Smsmith switch (BitWidth) 9767754Smsmith { 9867754Smsmith case 8: 99250838Sjkim 10067754Smsmith Length = 1; 10167754Smsmith break; 10267754Smsmith 10367754Smsmith case 16: 104250838Sjkim 10567754Smsmith Length = 2; 10667754Smsmith break; 10767754Smsmith 10867754Smsmith case 32: 109250838Sjkim 11067754Smsmith Length = 4; 11167754Smsmith break; 11267754Smsmith 11387031Smsmith case 64: 114250838Sjkim 11587031Smsmith Length = 8; 11687031Smsmith break; 11787031Smsmith 11867754Smsmith default: 119250838Sjkim 120204773Sjkim ACPI_ERROR ((AE_INFO, "Invalid SystemMemory width %u", 12167754Smsmith BitWidth)); 12267754Smsmith return_ACPI_STATUS (AE_AML_OPERAND_VALUE); 12367754Smsmith } 12467754Smsmith 125151937Sjkim#ifdef ACPI_MISALIGNMENT_NOT_SUPPORTED 12667754Smsmith /* 12799679Siwasaki * Hardware does not support non-aligned data transfers, we must verify 12899679Siwasaki * the request. 12999679Siwasaki */ 130202771Sjkim (void) AcpiUtShortDivide ((UINT64) Address, Length, NULL, &Remainder); 13199679Siwasaki if (Remainder != 0) 13299679Siwasaki { 13399679Siwasaki return_ACPI_STATUS (AE_AML_ALIGNMENT); 13499679Siwasaki } 13599679Siwasaki#endif 13699679Siwasaki 13799679Siwasaki /* 13867754Smsmith * Does the request fit into the cached memory mapping? 13967754Smsmith * Is 1) Address below the current mapping? OR 14067754Smsmith * 2) Address beyond the current mapping? 14167754Smsmith */ 14269450Smsmith if ((Address < MemInfo->MappedPhysicalAddress) || 143202771Sjkim (((UINT64) Address + Length) > 144202771Sjkim ((UINT64) 145151937Sjkim MemInfo->MappedPhysicalAddress + MemInfo->MappedLength))) 14667754Smsmith { 14767754Smsmith /* 14867754Smsmith * The request cannot be resolved by the current memory mapping; 14967754Smsmith * Delete the existing mapping and create a new one. 15067754Smsmith */ 15167754Smsmith if (MemInfo->MappedLength) 15267754Smsmith { 15367754Smsmith /* Valid mapping, delete it */ 15467754Smsmith 15567754Smsmith AcpiOsUnmapMemory (MemInfo->MappedLogicalAddress, 156167802Sjkim MemInfo->MappedLength); 15767754Smsmith } 15867754Smsmith 159102550Siwasaki /* 160199337Sjkim * October 2009: Attempt to map from the requested address to the 161199337Sjkim * end of the region. However, we will never map more than one 162199337Sjkim * page, nor will we cross a page boundary. 16392388Smsmith */ 164199337Sjkim MapLength = (ACPI_SIZE) 165151937Sjkim ((MemInfo->Address + MemInfo->Length) - Address); 166151937Sjkim 167199337Sjkim /* 168199337Sjkim * If mapping the entire remaining portion of the region will cross 169199337Sjkim * a page boundary, just map up to the page boundary, do not cross. 170199337Sjkim * On some systems, crossing a page boundary while mapping regions 171199337Sjkim * can cause warnings if the pages have different attributes 172199337Sjkim * due to resource management. 173199337Sjkim * 174199337Sjkim * This has the added benefit of constraining a single mapping to 175199337Sjkim * one page, which is similar to the original code that used a 4k 176199337Sjkim * maximum window. 177199337Sjkim */ 178281687Sjkim PageBoundaryMapLength = (ACPI_SIZE) 179281687Sjkim (ACPI_ROUND_UP (Address, ACPI_DEFAULT_PAGE_SIZE) - Address); 180199337Sjkim if (PageBoundaryMapLength == 0) 18192388Smsmith { 182199337Sjkim PageBoundaryMapLength = ACPI_DEFAULT_PAGE_SIZE; 18392388Smsmith } 184102550Siwasaki 185199337Sjkim if (MapLength > PageBoundaryMapLength) 186199337Sjkim { 187199337Sjkim MapLength = PageBoundaryMapLength; 188199337Sjkim } 189199337Sjkim 19067754Smsmith /* Create a new mapping starting at the address given */ 19167754Smsmith 192281687Sjkim MemInfo->MappedLogicalAddress = AcpiOsMapMemory (Address, MapLength); 193167802Sjkim if (!MemInfo->MappedLogicalAddress) 19467754Smsmith { 195167802Sjkim ACPI_ERROR ((AE_INFO, 196204773Sjkim "Could not map memory at 0x%8.8X%8.8X, size %u", 197281687Sjkim ACPI_FORMAT_UINT64 (Address), (UINT32) MapLength)); 19892388Smsmith MemInfo->MappedLength = 0; 199167802Sjkim return_ACPI_STATUS (AE_NO_MEMORY); 20067754Smsmith } 20167754Smsmith 20284491Smsmith /* Save the physical address and mapping size */ 20367754Smsmith 20469450Smsmith MemInfo->MappedPhysicalAddress = Address; 205199337Sjkim MemInfo->MappedLength = MapLength; 20667754Smsmith } 20767754Smsmith 20867754Smsmith /* 20967754Smsmith * Generate a logical pointer corresponding to the address we want to 21067754Smsmith * access 21167754Smsmith */ 21267754Smsmith LogicalAddrPtr = MemInfo->MappedLogicalAddress + 213202771Sjkim ((UINT64) Address - (UINT64) MemInfo->MappedPhysicalAddress); 21467754Smsmith 21582367Smsmith ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 216209746Sjkim "System-Memory (width %u) R/W %u Address=%8.8X%8.8X\n", 217281687Sjkim BitWidth, Function, ACPI_FORMAT_UINT64 (Address))); 21867754Smsmith 219167802Sjkim /* 220167802Sjkim * Perform the memory read or write 221167802Sjkim * 222167802Sjkim * Note: For machines that do not support non-aligned transfers, the target 223241973Sjkim * address was checked for alignment above. We do not attempt to break the 224167802Sjkim * transfer up into smaller (byte-size) chunks because the AML specifically 225167802Sjkim * asked for a transfer width that the hardware may require. 226167802Sjkim */ 22767754Smsmith switch (Function) 22867754Smsmith { 22987031Smsmith case ACPI_READ: 23067754Smsmith 23191116Smsmith *Value = 0; 23267754Smsmith switch (BitWidth) 23367754Smsmith { 23467754Smsmith case 8: 235250838Sjkim 236202771Sjkim *Value = (UINT64) ACPI_GET8 (LogicalAddrPtr); 23767754Smsmith break; 23867754Smsmith 23967754Smsmith case 16: 240250838Sjkim 241202771Sjkim *Value = (UINT64) ACPI_GET16 (LogicalAddrPtr); 24267754Smsmith break; 24367754Smsmith 24467754Smsmith case 32: 245250838Sjkim 246202771Sjkim *Value = (UINT64) ACPI_GET32 (LogicalAddrPtr); 24767754Smsmith break; 24887031Smsmith 24987031Smsmith case 64: 250250838Sjkim 251202771Sjkim *Value = (UINT64) ACPI_GET64 (LogicalAddrPtr); 25287031Smsmith break; 253167802Sjkim 25499679Siwasaki default: 255250838Sjkim 25699679Siwasaki /* BitWidth was already validated */ 257250838Sjkim 25899679Siwasaki break; 25967754Smsmith } 26067754Smsmith break; 26167754Smsmith 26287031Smsmith case ACPI_WRITE: 26367754Smsmith 26467754Smsmith switch (BitWidth) 26567754Smsmith { 26667754Smsmith case 8: 267250838Sjkim 268243347Sjkim ACPI_SET8 (LogicalAddrPtr, *Value); 26967754Smsmith break; 27067754Smsmith 27167754Smsmith case 16: 272250838Sjkim 273243347Sjkim ACPI_SET16 (LogicalAddrPtr, *Value); 27467754Smsmith break; 27567754Smsmith 27667754Smsmith case 32: 277250838Sjkim 278243347Sjkim ACPI_SET32 (LogicalAddrPtr, *Value); 27967754Smsmith break; 28087031Smsmith 28187031Smsmith case 64: 282250838Sjkim 283243347Sjkim ACPI_SET64 (LogicalAddrPtr, *Value); 28487031Smsmith break; 285102550Siwasaki 28699679Siwasaki default: 287250838Sjkim 28899679Siwasaki /* BitWidth was already validated */ 289250838Sjkim 29099679Siwasaki break; 29167754Smsmith } 29267754Smsmith break; 29367754Smsmith 29467754Smsmith default: 295250838Sjkim 29667754Smsmith Status = AE_BAD_PARAMETER; 29767754Smsmith break; 29867754Smsmith } 29967754Smsmith 30067754Smsmith return_ACPI_STATUS (Status); 30167754Smsmith} 30267754Smsmith 30367754Smsmith 30467754Smsmith/******************************************************************************* 30567754Smsmith * 30677424Smsmith * FUNCTION: AcpiExSystemIoSpaceHandler 30767754Smsmith * 30867754Smsmith * PARAMETERS: Function - Read or Write operation 30967754Smsmith * Address - Where in the space to read or write 31067754Smsmith * BitWidth - Field width in bits (8, 16, or 32) 31167754Smsmith * Value - Pointer to in or out value 31267754Smsmith * HandlerContext - Pointer to Handler's context 31367754Smsmith * RegionContext - Pointer to context specific to the 31484491Smsmith * accessed region 31567754Smsmith * 31667754Smsmith * RETURN: Status 31767754Smsmith * 31867754Smsmith * DESCRIPTION: Handler for the System IO address space (Op Region) 31967754Smsmith * 32067754Smsmith ******************************************************************************/ 32167754Smsmith 32267754SmsmithACPI_STATUS 32377424SmsmithAcpiExSystemIoSpaceHandler ( 32467754Smsmith UINT32 Function, 32569450Smsmith ACPI_PHYSICAL_ADDRESS Address, 32667754Smsmith UINT32 BitWidth, 327202771Sjkim UINT64 *Value, 32867754Smsmith void *HandlerContext, 32967754Smsmith void *RegionContext) 33067754Smsmith{ 33167754Smsmith ACPI_STATUS Status = AE_OK; 332117521Snjl UINT32 Value32; 33367754Smsmith 33467754Smsmith 335167802Sjkim ACPI_FUNCTION_TRACE (ExSystemIoSpaceHandler); 33667754Smsmith 33767754Smsmith 33882367Smsmith ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 339209746Sjkim "System-IO (width %u) R/W %u Address=%8.8X%8.8X\n", 340281687Sjkim BitWidth, Function, ACPI_FORMAT_UINT64 (Address))); 34180062Smsmith 34267754Smsmith /* Decode the function parameter */ 34367754Smsmith 34467754Smsmith switch (Function) 34567754Smsmith { 34687031Smsmith case ACPI_READ: 34767754Smsmith 348193267Sjkim Status = AcpiHwReadPort ((ACPI_IO_ADDRESS) Address, 349151937Sjkim &Value32, BitWidth); 350117521Snjl *Value = Value32; 35167754Smsmith break; 35267754Smsmith 35387031Smsmith case ACPI_WRITE: 35467754Smsmith 355193267Sjkim Status = AcpiHwWritePort ((ACPI_IO_ADDRESS) Address, 356151937Sjkim (UINT32) *Value, BitWidth); 35767754Smsmith break; 35867754Smsmith 35967754Smsmith default: 360250838Sjkim 36167754Smsmith Status = AE_BAD_PARAMETER; 36267754Smsmith break; 36367754Smsmith } 36467754Smsmith 36567754Smsmith return_ACPI_STATUS (Status); 36667754Smsmith} 36767754Smsmith 36880062Smsmith 36967754Smsmith/******************************************************************************* 37067754Smsmith * 37177424Smsmith * FUNCTION: AcpiExPciConfigSpaceHandler 37267754Smsmith * 37367754Smsmith * PARAMETERS: Function - Read or Write operation 37467754Smsmith * Address - Where in the space to read or write 37567754Smsmith * BitWidth - Field width in bits (8, 16, or 32) 37667754Smsmith * Value - Pointer to in or out value 37767754Smsmith * HandlerContext - Pointer to Handler's context 37867754Smsmith * RegionContext - Pointer to context specific to the 37984491Smsmith * accessed region 38067754Smsmith * 38167754Smsmith * RETURN: Status 38267754Smsmith * 38367754Smsmith * DESCRIPTION: Handler for the PCI Config address space (Op Region) 38467754Smsmith * 38567754Smsmith ******************************************************************************/ 38667754Smsmith 38767754SmsmithACPI_STATUS 38877424SmsmithAcpiExPciConfigSpaceHandler ( 38967754Smsmith UINT32 Function, 39069450Smsmith ACPI_PHYSICAL_ADDRESS Address, 39167754Smsmith UINT32 BitWidth, 392202771Sjkim UINT64 *Value, 39367754Smsmith void *HandlerContext, 39467754Smsmith void *RegionContext) 39567754Smsmith{ 39667754Smsmith ACPI_STATUS Status = AE_OK; 39780062Smsmith ACPI_PCI_ID *PciId; 39880062Smsmith UINT16 PciRegister; 39967754Smsmith 40067754Smsmith 401167802Sjkim ACPI_FUNCTION_TRACE (ExPciConfigSpaceHandler); 40267754Smsmith 40380062Smsmith 40467754Smsmith /* 40587031Smsmith * The arguments to AcpiOs(Read|Write)PciConfiguration are: 40667754Smsmith * 40780062Smsmith * PciSegment is the PCI bus segment range 0-31 40880062Smsmith * PciBus is the PCI bus number range 0-255 40980062Smsmith * PciDevice is the PCI device number range 0-31 41080062Smsmith * PciFunction is the PCI device function number 41180062Smsmith * PciRegister is the Config space register range 0-255 bytes 41267754Smsmith * 41380062Smsmith * Value - input value for write, output address for read 41467754Smsmith * 41567754Smsmith */ 41680062Smsmith PciId = (ACPI_PCI_ID *) RegionContext; 41799679Siwasaki PciRegister = (UINT16) (UINT32) Address; 41867754Smsmith 41982367Smsmith ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 420306536Sjkim "Pci-Config %u (%u) Seg(%04x) Bus(%04x) " 421306536Sjkim "Dev(%04x) Func(%04x) Reg(%04x)\n", 42283174Smsmith Function, BitWidth, PciId->Segment, PciId->Bus, PciId->Device, 42380062Smsmith PciId->Function, PciRegister)); 42467754Smsmith 42567754Smsmith switch (Function) 42667754Smsmith { 42787031Smsmith case ACPI_READ: 42867754Smsmith 42980062Smsmith *Value = 0; 430306536Sjkim Status = AcpiOsReadPciConfiguration ( 431306536Sjkim PciId, PciRegister, Value, BitWidth); 43267754Smsmith break; 43367754Smsmith 43487031Smsmith case ACPI_WRITE: 43567754Smsmith 436306536Sjkim Status = AcpiOsWritePciConfiguration ( 437306536Sjkim PciId, PciRegister, *Value, BitWidth); 43867754Smsmith break; 43967754Smsmith 44067754Smsmith default: 44167754Smsmith 44267754Smsmith Status = AE_BAD_PARAMETER; 44367754Smsmith break; 44467754Smsmith } 44567754Smsmith 44667754Smsmith return_ACPI_STATUS (Status); 44767754Smsmith} 44867754Smsmith 44984491Smsmith 45084491Smsmith/******************************************************************************* 45184491Smsmith * 45284491Smsmith * FUNCTION: AcpiExCmosSpaceHandler 45384491Smsmith * 45484491Smsmith * PARAMETERS: Function - Read or Write operation 45584491Smsmith * Address - Where in the space to read or write 45684491Smsmith * BitWidth - Field width in bits (8, 16, or 32) 45784491Smsmith * Value - Pointer to in or out value 45884491Smsmith * HandlerContext - Pointer to Handler's context 45984491Smsmith * RegionContext - Pointer to context specific to the 46084491Smsmith * accessed region 46184491Smsmith * 46284491Smsmith * RETURN: Status 46384491Smsmith * 46484491Smsmith * DESCRIPTION: Handler for the CMOS address space (Op Region) 46584491Smsmith * 46684491Smsmith ******************************************************************************/ 46784491Smsmith 46884491SmsmithACPI_STATUS 46984491SmsmithAcpiExCmosSpaceHandler ( 47084491Smsmith UINT32 Function, 47184491Smsmith ACPI_PHYSICAL_ADDRESS Address, 47284491Smsmith UINT32 BitWidth, 473202771Sjkim UINT64 *Value, 47484491Smsmith void *HandlerContext, 47584491Smsmith void *RegionContext) 47684491Smsmith{ 47784491Smsmith ACPI_STATUS Status = AE_OK; 47884491Smsmith 47984491Smsmith 480167802Sjkim ACPI_FUNCTION_TRACE (ExCmosSpaceHandler); 48184491Smsmith 48284491Smsmith 48384491Smsmith return_ACPI_STATUS (Status); 48484491Smsmith} 48584491Smsmith 48684491Smsmith 48784491Smsmith/******************************************************************************* 48884491Smsmith * 48984491Smsmith * FUNCTION: AcpiExPciBarSpaceHandler 49084491Smsmith * 49184491Smsmith * PARAMETERS: Function - Read or Write operation 49284491Smsmith * Address - Where in the space to read or write 49384491Smsmith * BitWidth - Field width in bits (8, 16, or 32) 49484491Smsmith * Value - Pointer to in or out value 49584491Smsmith * HandlerContext - Pointer to Handler's context 49684491Smsmith * RegionContext - Pointer to context specific to the 49784491Smsmith * accessed region 49884491Smsmith * 49984491Smsmith * RETURN: Status 50084491Smsmith * 50184491Smsmith * DESCRIPTION: Handler for the PCI BarTarget address space (Op Region) 50284491Smsmith * 50384491Smsmith ******************************************************************************/ 50484491Smsmith 50584491SmsmithACPI_STATUS 50684491SmsmithAcpiExPciBarSpaceHandler ( 50784491Smsmith UINT32 Function, 50884491Smsmith ACPI_PHYSICAL_ADDRESS Address, 50984491Smsmith UINT32 BitWidth, 510202771Sjkim UINT64 *Value, 51184491Smsmith void *HandlerContext, 51284491Smsmith void *RegionContext) 51384491Smsmith{ 51484491Smsmith ACPI_STATUS Status = AE_OK; 51584491Smsmith 51684491Smsmith 517167802Sjkim ACPI_FUNCTION_TRACE (ExPciBarSpaceHandler); 51884491Smsmith 51984491Smsmith 52084491Smsmith return_ACPI_STATUS (Status); 52184491Smsmith} 52284491Smsmith 52391116Smsmith 52491116Smsmith/******************************************************************************* 52591116Smsmith * 52691116Smsmith * FUNCTION: AcpiExDataTableSpaceHandler 52791116Smsmith * 52891116Smsmith * PARAMETERS: Function - Read or Write operation 52991116Smsmith * Address - Where in the space to read or write 53091116Smsmith * BitWidth - Field width in bits (8, 16, or 32) 53191116Smsmith * Value - Pointer to in or out value 53291116Smsmith * HandlerContext - Pointer to Handler's context 53391116Smsmith * RegionContext - Pointer to context specific to the 53491116Smsmith * accessed region 53591116Smsmith * 53691116Smsmith * RETURN: Status 53791116Smsmith * 53891116Smsmith * DESCRIPTION: Handler for the Data Table address space (Op Region) 53991116Smsmith * 54091116Smsmith ******************************************************************************/ 54191116Smsmith 54291116SmsmithACPI_STATUS 54391116SmsmithAcpiExDataTableSpaceHandler ( 54491116Smsmith UINT32 Function, 54591116Smsmith ACPI_PHYSICAL_ADDRESS Address, 54691116Smsmith UINT32 BitWidth, 547202771Sjkim UINT64 *Value, 54891116Smsmith void *HandlerContext, 54991116Smsmith void *RegionContext) 55091116Smsmith{ 551167802Sjkim ACPI_FUNCTION_TRACE (ExDataTableSpaceHandler); 55291116Smsmith 55391116Smsmith 554206117Sjkim /* 555206117Sjkim * Perform the memory read or write. The BitWidth was already 556206117Sjkim * validated. 557206117Sjkim */ 55891116Smsmith switch (Function) 55991116Smsmith { 56091116Smsmith case ACPI_READ: 56191116Smsmith 562306536Sjkim memcpy (ACPI_CAST_PTR (char, Value), ACPI_PHYSADDR_TO_PTR (Address), 563167802Sjkim ACPI_DIV_8 (BitWidth)); 56491116Smsmith break; 56591116Smsmith 56691116Smsmith case ACPI_WRITE: 567206117Sjkim 568306536Sjkim memcpy (ACPI_PHYSADDR_TO_PTR (Address), ACPI_CAST_PTR (char, Value), 569206117Sjkim ACPI_DIV_8 (BitWidth)); 570206117Sjkim break; 571206117Sjkim 57299679Siwasaki default: 57391116Smsmith 574206117Sjkim return_ACPI_STATUS (AE_BAD_PARAMETER); 57591116Smsmith } 57691116Smsmith 577167802Sjkim return_ACPI_STATUS (AE_OK); 57891116Smsmith} 579