ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

evxfregn.c
Go to the documentation of this file.
00001 /******************************************************************************
00002  *
00003  * Module Name: evxfregn - External Interfaces, ACPI Operation Regions and
00004  *                         Address Spaces.
00005  *
00006  *****************************************************************************/
00007 
00008 /******************************************************************************
00009  *
00010  * 1. Copyright Notice
00011  *
00012  * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp.
00013  * All rights reserved.
00014  *
00015  * 2. License
00016  *
00017  * 2.1. This is your license from Intel Corp. under its intellectual property
00018  * rights.  You may have additional license terms from the party that provided
00019  * you this software, covering your right to use that party's intellectual
00020  * property rights.
00021  *
00022  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
00023  * copy of the source code appearing in this file ("Covered Code") an
00024  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
00025  * base code distributed originally by Intel ("Original Intel Code") to copy,
00026  * make derivatives, distribute, use and display any portion of the Covered
00027  * Code in any form, with the right to sublicense such rights; and
00028  *
00029  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
00030  * license (with the right to sublicense), under only those claims of Intel
00031  * patents that are infringed by the Original Intel Code, to make, use, sell,
00032  * offer to sell, and import the Covered Code and derivative works thereof
00033  * solely to the minimum extent necessary to exercise the above copyright
00034  * license, and in no event shall the patent license extend to any additions
00035  * to or modifications of the Original Intel Code.  No other license or right
00036  * is granted directly or by implication, estoppel or otherwise;
00037  *
00038  * The above copyright and patent license is granted only if the following
00039  * conditions are met:
00040  *
00041  * 3. Conditions
00042  *
00043  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
00044  * Redistribution of source code of any substantial portion of the Covered
00045  * Code or modification with rights to further distribute source must include
00046  * the above Copyright Notice, the above License, this list of Conditions,
00047  * and the following Disclaimer and Export Compliance provision.  In addition,
00048  * Licensee must cause all Covered Code to which Licensee contributes to
00049  * contain a file documenting the changes Licensee made to create that Covered
00050  * Code and the date of any change.  Licensee must include in that file the
00051  * documentation of any changes made by any predecessor Licensee.  Licensee
00052  * must include a prominent statement that the modification is derived,
00053  * directly or indirectly, from Original Intel Code.
00054  *
00055  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
00056  * Redistribution of source code of any substantial portion of the Covered
00057  * Code or modification without rights to further distribute source must
00058  * include the following Disclaimer and Export Compliance provision in the
00059  * documentation and/or other materials provided with distribution.  In
00060  * addition, Licensee may not authorize further sublicense of source of any
00061  * portion of the Covered Code, and must include terms to the effect that the
00062  * license from Licensee to its licensee is limited to the intellectual
00063  * property embodied in the software Licensee provides to its licensee, and
00064  * not to intellectual property embodied in modifications its licensee may
00065  * make.
00066  *
00067  * 3.3. Redistribution of Executable. Redistribution in executable form of any
00068  * substantial portion of the Covered Code or modification must reproduce the
00069  * above Copyright Notice, and the following Disclaimer and Export Compliance
00070  * provision in the documentation and/or other materials provided with the
00071  * distribution.
00072  *
00073  * 3.4. Intel retains all right, title, and interest in and to the Original
00074  * Intel Code.
00075  *
00076  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
00077  * Intel shall be used in advertising or otherwise to promote the sale, use or
00078  * other dealings in products derived from or relating to the Covered Code
00079  * without prior written authorization from Intel.
00080  *
00081  * 4. Disclaimer and Export Compliance
00082  *
00083  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
00084  * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
00085  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
00086  * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
00087  * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
00088  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
00089  * PARTICULAR PURPOSE.
00090  *
00091  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
00092  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
00093  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
00094  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
00095  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
00096  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
00097  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
00098  * LIMITED REMEDY.
00099  *
00100  * 4.3. Licensee shall not export, either directly or indirectly, any of this
00101  * software or system incorporating such software without first obtaining any
00102  * required license or other approval from the U. S. Department of Commerce or
00103  * any other agency or department of the United States Government.  In the
00104  * event Licensee exports any such software from the United States or
00105  * re-exports any such software from a foreign destination, Licensee shall
00106  * ensure that the distribution and export/re-export of the software is in
00107  * compliance with all laws, regulations, orders, or other restrictions of the
00108  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
00109  * any of its subsidiaries will export/re-export any technical data, process,
00110  * software, or service, directly or indirectly, to any country for which the
00111  * United States government or any agency thereof requires an export license,
00112  * other governmental approval, or letter of assurance, without first obtaining
00113  * such license, approval or letter.
00114  *
00115  *****************************************************************************/
00116 
00117 #define __EVXFREGN_C__
00118 
00119 #include "acpi.h"
00120 #include "accommon.h"
00121 #include "acnamesp.h"
00122 #include "acevents.h"
00123 
00124 #define _COMPONENT          ACPI_EVENTS
00125         ACPI_MODULE_NAME    ("evxfregn")
00126 
00127 
00128 /*******************************************************************************
00129  *
00130  * FUNCTION:    AcpiInstallAddressSpaceHandler
00131  *
00132  * PARAMETERS:  Device          - Handle for the device
00133  *              SpaceId         - The address space ID
00134  *              Handler         - Address of the handler
00135  *              Setup           - Address of the setup function
00136  *              Context         - Value passed to the handler on each access
00137  *
00138  * RETURN:      Status
00139  *
00140  * DESCRIPTION: Install a handler for all OpRegions of a given SpaceId.
00141  *
00142  * NOTE: This function should only be called after AcpiEnableSubsystem has
00143  * been called. This is because any _REG methods associated with the Space ID
00144  * are executed here, and these methods can only be safely executed after
00145  * the default handlers have been installed and the hardware has been
00146  * initialized (via AcpiEnableSubsystem.)
00147  *
00148  ******************************************************************************/
00149 
00150 ACPI_STATUS
00151 AcpiInstallAddressSpaceHandler (
00152     ACPI_HANDLE             Device,
00153     ACPI_ADR_SPACE_TYPE     SpaceId,
00154     ACPI_ADR_SPACE_HANDLER  Handler,
00155     ACPI_ADR_SPACE_SETUP    Setup,
00156     void                    *Context)
00157 {
00158     ACPI_NAMESPACE_NODE     *Node;
00159     ACPI_STATUS             Status;
00160 
00161 
00162     ACPI_FUNCTION_TRACE (AcpiInstallAddressSpaceHandler);
00163 
00164 
00165     /* Parameter validation */
00166 
00167     if (!Device)
00168     {
00169         return_ACPI_STATUS (AE_BAD_PARAMETER);
00170     }
00171 
00172     Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
00173     if (ACPI_FAILURE (Status))
00174     {
00175         return_ACPI_STATUS (Status);
00176     }
00177 
00178     /* Convert and validate the device handle */
00179 
00180     Node = AcpiNsValidateHandle (Device);
00181     if (!Node)
00182     {
00183         Status = AE_BAD_PARAMETER;
00184         goto UnlockAndExit;
00185     }
00186 
00187     /* Install the handler for all Regions for this Space ID */
00188 
00189     Status = AcpiEvInstallSpaceHandler (Node, SpaceId, Handler, Setup, Context);
00190     if (ACPI_FAILURE (Status))
00191     {
00192         goto UnlockAndExit;
00193     }
00194 
00195     /*
00196      * For the default SpaceIDs, (the IDs for which there are default region handlers
00197      * installed) Only execute the _REG methods if the global initialization _REG
00198      * methods have already been run (via AcpiInitializeObjects). In other words,
00199      * we will defer the execution of the _REG methods for these SpaceIDs until
00200      * execution of AcpiInitializeObjects. This is done because we need the handlers
00201      * for the default spaces (mem/io/pci/table) to be installed before we can run
00202      * any control methods (or _REG methods). There is known BIOS code that depends
00203      * on this.
00204      *
00205      * For all other SpaceIDs, we can safely execute the _REG methods immediately.
00206      * This means that for IDs like EmbeddedController, this function should be called
00207      * only after AcpiEnableSubsystem has been called.
00208      */
00209     switch (SpaceId)
00210     {
00211     case ACPI_ADR_SPACE_SYSTEM_MEMORY:
00212     case ACPI_ADR_SPACE_SYSTEM_IO:
00213     case ACPI_ADR_SPACE_PCI_CONFIG:
00214     case ACPI_ADR_SPACE_DATA_TABLE:
00215 
00216         if (!AcpiGbl_RegMethodsExecuted)
00217         {
00218             /* We will defer execution of the _REG methods for this space */
00219             goto UnlockAndExit;
00220         }
00221         break;
00222 
00223     default:
00224         break;
00225     }
00226 
00227     /* Run all _REG methods for this address space */
00228 
00229     Status = AcpiEvExecuteRegMethods (Node, SpaceId);
00230 
00231 
00232 UnlockAndExit:
00233     (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
00234     return_ACPI_STATUS (Status);
00235 }
00236 
00237 ACPI_EXPORT_SYMBOL (AcpiInstallAddressSpaceHandler)
00238 
00239 
00240 /*******************************************************************************
00241  *
00242  * FUNCTION:    AcpiRemoveAddressSpaceHandler
00243  *
00244  * PARAMETERS:  Device          - Handle for the device
00245  *              SpaceId         - The address space ID
00246  *              Handler         - Address of the handler
00247  *
00248  * RETURN:      Status
00249  *
00250  * DESCRIPTION: Remove a previously installed handler.
00251  *
00252  ******************************************************************************/
00253 
00254 ACPI_STATUS
00255 AcpiRemoveAddressSpaceHandler (
00256     ACPI_HANDLE             Device,
00257     ACPI_ADR_SPACE_TYPE     SpaceId,
00258     ACPI_ADR_SPACE_HANDLER  Handler)
00259 {
00260     ACPI_OPERAND_OBJECT     *ObjDesc;
00261     ACPI_OPERAND_OBJECT     *HandlerObj;
00262     ACPI_OPERAND_OBJECT     *RegionObj;
00263     ACPI_OPERAND_OBJECT     **LastObjPtr;
00264     ACPI_NAMESPACE_NODE     *Node;
00265     ACPI_STATUS             Status;
00266 
00267 
00268     ACPI_FUNCTION_TRACE (AcpiRemoveAddressSpaceHandler);
00269 
00270 
00271     /* Parameter validation */
00272 
00273     if (!Device)
00274     {
00275         return_ACPI_STATUS (AE_BAD_PARAMETER);
00276     }
00277 
00278     Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
00279     if (ACPI_FAILURE (Status))
00280     {
00281         return_ACPI_STATUS (Status);
00282     }
00283 
00284     /* Convert and validate the device handle */
00285 
00286     Node = AcpiNsValidateHandle (Device);
00287     if (!Node ||
00288         ((Node->Type != ACPI_TYPE_DEVICE)    &&
00289          (Node->Type != ACPI_TYPE_PROCESSOR) &&
00290          (Node->Type != ACPI_TYPE_THERMAL)   &&
00291          (Node != AcpiGbl_RootNode)))
00292     {
00293         Status = AE_BAD_PARAMETER;
00294         goto UnlockAndExit;
00295     }
00296 
00297     /* Make sure the internal object exists */
00298 
00299     ObjDesc = AcpiNsGetAttachedObject (Node);
00300     if (!ObjDesc)
00301     {
00302         Status = AE_NOT_EXIST;
00303         goto UnlockAndExit;
00304     }
00305 
00306     /* Find the address handler the user requested */
00307 
00308     HandlerObj = ObjDesc->Device.Handler;
00309     LastObjPtr = &ObjDesc->Device.Handler;
00310     while (HandlerObj)
00311     {
00312         /* We have a handler, see if user requested this one */
00313 
00314         if (HandlerObj->AddressSpace.SpaceId == SpaceId)
00315         {
00316             /* Handler must be the same as the installed handler */
00317 
00318             if (HandlerObj->AddressSpace.Handler != Handler)
00319             {
00320                 Status = AE_BAD_PARAMETER;
00321                 goto UnlockAndExit;
00322             }
00323 
00324             /* Matched SpaceId, first dereference this in the Regions */
00325 
00326             ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
00327                 "Removing address handler %p(%p) for region %s "
00328                 "on Device %p(%p)\n",
00329                 HandlerObj, Handler, AcpiUtGetRegionName (SpaceId),
00330                 Node, ObjDesc));
00331 
00332             RegionObj = HandlerObj->AddressSpace.RegionList;
00333 
00334             /* Walk the handler's region list */
00335 
00336             while (RegionObj)
00337             {
00338                 /*
00339                  * First disassociate the handler from the region.
00340                  *
00341                  * NOTE: this doesn't mean that the region goes away
00342                  * The region is just inaccessible as indicated to
00343                  * the _REG method
00344                  */
00345                 AcpiEvDetachRegion (RegionObj, TRUE);
00346 
00347                 /*
00348                  * Walk the list: Just grab the head because the
00349                  * DetachRegion removed the previous head.
00350                  */
00351                 RegionObj = HandlerObj->AddressSpace.RegionList;
00352 
00353             }
00354 
00355             /* Remove this Handler object from the list */
00356 
00357             *LastObjPtr = HandlerObj->AddressSpace.Next;
00358 
00359             /* Now we can delete the handler object */
00360 
00361             AcpiUtRemoveReference (HandlerObj);
00362             goto UnlockAndExit;
00363         }
00364 
00365         /* Walk the linked list of handlers */
00366 
00367         LastObjPtr = &HandlerObj->AddressSpace.Next;
00368         HandlerObj = HandlerObj->AddressSpace.Next;
00369     }
00370 
00371     /* The handler does not exist */
00372 
00373     ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
00374         "Unable to remove address handler %p for %s(%X), DevNode %p, obj %p\n",
00375         Handler, AcpiUtGetRegionName (SpaceId), SpaceId, Node, ObjDesc));
00376 
00377     Status = AE_NOT_EXIST;
00378 
00379 UnlockAndExit:
00380     (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
00381     return_ACPI_STATUS (Status);
00382 }
00383 
00384 ACPI_EXPORT_SYMBOL (AcpiRemoveAddressSpaceHandler)
00385 

Generated on Sun May 27 2012 04:27:16 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.