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

rsaddr.c
Go to the documentation of this file.
00001 /*******************************************************************************
00002  *
00003  * Module Name: rsaddr - Address resource descriptors (16/32/64)
00004  *
00005  ******************************************************************************/
00006 
00007 /******************************************************************************
00008  *
00009  * 1. Copyright Notice
00010  *
00011  * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp.
00012  * All rights reserved.
00013  *
00014  * 2. License
00015  *
00016  * 2.1. This is your license from Intel Corp. under its intellectual property
00017  * rights.  You may have additional license terms from the party that provided
00018  * you this software, covering your right to use that party's intellectual
00019  * property rights.
00020  *
00021  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
00022  * copy of the source code appearing in this file ("Covered Code") an
00023  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
00024  * base code distributed originally by Intel ("Original Intel Code") to copy,
00025  * make derivatives, distribute, use and display any portion of the Covered
00026  * Code in any form, with the right to sublicense such rights; and
00027  *
00028  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
00029  * license (with the right to sublicense), under only those claims of Intel
00030  * patents that are infringed by the Original Intel Code, to make, use, sell,
00031  * offer to sell, and import the Covered Code and derivative works thereof
00032  * solely to the minimum extent necessary to exercise the above copyright
00033  * license, and in no event shall the patent license extend to any additions
00034  * to or modifications of the Original Intel Code.  No other license or right
00035  * is granted directly or by implication, estoppel or otherwise;
00036  *
00037  * The above copyright and patent license is granted only if the following
00038  * conditions are met:
00039  *
00040  * 3. Conditions
00041  *
00042  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
00043  * Redistribution of source code of any substantial portion of the Covered
00044  * Code or modification with rights to further distribute source must include
00045  * the above Copyright Notice, the above License, this list of Conditions,
00046  * and the following Disclaimer and Export Compliance provision.  In addition,
00047  * Licensee must cause all Covered Code to which Licensee contributes to
00048  * contain a file documenting the changes Licensee made to create that Covered
00049  * Code and the date of any change.  Licensee must include in that file the
00050  * documentation of any changes made by any predecessor Licensee.  Licensee
00051  * must include a prominent statement that the modification is derived,
00052  * directly or indirectly, from Original Intel Code.
00053  *
00054  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
00055  * Redistribution of source code of any substantial portion of the Covered
00056  * Code or modification without rights to further distribute source must
00057  * include the following Disclaimer and Export Compliance provision in the
00058  * documentation and/or other materials provided with distribution.  In
00059  * addition, Licensee may not authorize further sublicense of source of any
00060  * portion of the Covered Code, and must include terms to the effect that the
00061  * license from Licensee to its licensee is limited to the intellectual
00062  * property embodied in the software Licensee provides to its licensee, and
00063  * not to intellectual property embodied in modifications its licensee may
00064  * make.
00065  *
00066  * 3.3. Redistribution of Executable. Redistribution in executable form of any
00067  * substantial portion of the Covered Code or modification must reproduce the
00068  * above Copyright Notice, and the following Disclaimer and Export Compliance
00069  * provision in the documentation and/or other materials provided with the
00070  * distribution.
00071  *
00072  * 3.4. Intel retains all right, title, and interest in and to the Original
00073  * Intel Code.
00074  *
00075  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
00076  * Intel shall be used in advertising or otherwise to promote the sale, use or
00077  * other dealings in products derived from or relating to the Covered Code
00078  * without prior written authorization from Intel.
00079  *
00080  * 4. Disclaimer and Export Compliance
00081  *
00082  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
00083  * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
00084  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
00085  * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
00086  * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
00087  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
00088  * PARTICULAR PURPOSE.
00089  *
00090  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
00091  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
00092  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
00093  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
00094  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
00095  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
00096  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
00097  * LIMITED REMEDY.
00098  *
00099  * 4.3. Licensee shall not export, either directly or indirectly, any of this
00100  * software or system incorporating such software without first obtaining any
00101  * required license or other approval from the U. S. Department of Commerce or
00102  * any other agency or department of the United States Government.  In the
00103  * event Licensee exports any such software from the United States or
00104  * re-exports any such software from a foreign destination, Licensee shall
00105  * ensure that the distribution and export/re-export of the software is in
00106  * compliance with all laws, regulations, orders, or other restrictions of the
00107  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
00108  * any of its subsidiaries will export/re-export any technical data, process,
00109  * software, or service, directly or indirectly, to any country for which the
00110  * United States government or any agency thereof requires an export license,
00111  * other governmental approval, or letter of assurance, without first obtaining
00112  * such license, approval or letter.
00113  *
00114  *****************************************************************************/
00115 
00116 #define __RSADDR_C__
00117 
00118 #include "acpi.h"
00119 #include "accommon.h"
00120 #include "acresrc.h"
00121 
00122 #define _COMPONENT          ACPI_RESOURCES
00123         ACPI_MODULE_NAME    ("rsaddr")
00124 
00125 
00126 /*******************************************************************************
00127  *
00128  * AcpiRsConvertAddress16 - All WORD (16-bit) address resources
00129  *
00130  ******************************************************************************/
00131 
00132 ACPI_RSCONVERT_INFO     AcpiRsConvertAddress16[5] =
00133 {
00134     {ACPI_RSC_INITGET,  ACPI_RESOURCE_TYPE_ADDRESS16,
00135                         ACPI_RS_SIZE (ACPI_RESOURCE_ADDRESS16),
00136                         ACPI_RSC_TABLE_SIZE (AcpiRsConvertAddress16)},
00137 
00138     {ACPI_RSC_INITSET,  ACPI_RESOURCE_NAME_ADDRESS16,
00139                         sizeof (AML_RESOURCE_ADDRESS16),
00140                         0},
00141 
00142     /* Resource Type, General Flags, and Type-Specific Flags */
00143 
00144     {ACPI_RSC_ADDRESS,  0, 0, 0},
00145 
00146     /*
00147      * These fields are contiguous in both the source and destination:
00148      * Address Granularity
00149      * Address Range Minimum
00150      * Address Range Maximum
00151      * Address Translation Offset
00152      * Address Length
00153      */
00154     {ACPI_RSC_MOVE16,   ACPI_RS_OFFSET (Data.Address16.Granularity),
00155                         AML_OFFSET (Address16.Granularity),
00156                         5},
00157 
00158     /* Optional ResourceSource (Index and String) */
00159 
00160     {ACPI_RSC_SOURCE,   ACPI_RS_OFFSET (Data.Address16.ResourceSource),
00161                         0,
00162                         sizeof (AML_RESOURCE_ADDRESS16)}
00163 };
00164 
00165 
00166 /*******************************************************************************
00167  *
00168  * AcpiRsConvertAddress32 - All DWORD (32-bit) address resources
00169  *
00170  ******************************************************************************/
00171 
00172 ACPI_RSCONVERT_INFO     AcpiRsConvertAddress32[5] =
00173 {
00174     {ACPI_RSC_INITGET,  ACPI_RESOURCE_TYPE_ADDRESS32,
00175                         ACPI_RS_SIZE (ACPI_RESOURCE_ADDRESS32),
00176                         ACPI_RSC_TABLE_SIZE (AcpiRsConvertAddress32)},
00177 
00178     {ACPI_RSC_INITSET,  ACPI_RESOURCE_NAME_ADDRESS32,
00179                         sizeof (AML_RESOURCE_ADDRESS32),
00180                         0},
00181 
00182     /* Resource Type, General Flags, and Type-Specific Flags */
00183 
00184     {ACPI_RSC_ADDRESS,  0, 0, 0},
00185 
00186     /*
00187      * These fields are contiguous in both the source and destination:
00188      * Address Granularity
00189      * Address Range Minimum
00190      * Address Range Maximum
00191      * Address Translation Offset
00192      * Address Length
00193      */
00194     {ACPI_RSC_MOVE32,   ACPI_RS_OFFSET (Data.Address32.Granularity),
00195                         AML_OFFSET (Address32.Granularity),
00196                         5},
00197 
00198     /* Optional ResourceSource (Index and String) */
00199 
00200     {ACPI_RSC_SOURCE,   ACPI_RS_OFFSET (Data.Address32.ResourceSource),
00201                         0,
00202                         sizeof (AML_RESOURCE_ADDRESS32)}
00203 };
00204 
00205 
00206 /*******************************************************************************
00207  *
00208  * AcpiRsConvertAddress64 - All QWORD (64-bit) address resources
00209  *
00210  ******************************************************************************/
00211 
00212 ACPI_RSCONVERT_INFO     AcpiRsConvertAddress64[5] =
00213 {
00214     {ACPI_RSC_INITGET,  ACPI_RESOURCE_TYPE_ADDRESS64,
00215                         ACPI_RS_SIZE (ACPI_RESOURCE_ADDRESS64),
00216                         ACPI_RSC_TABLE_SIZE (AcpiRsConvertAddress64)},
00217 
00218     {ACPI_RSC_INITSET,  ACPI_RESOURCE_NAME_ADDRESS64,
00219                         sizeof (AML_RESOURCE_ADDRESS64),
00220                         0},
00221 
00222     /* Resource Type, General Flags, and Type-Specific Flags */
00223 
00224     {ACPI_RSC_ADDRESS,  0, 0, 0},
00225 
00226     /*
00227      * These fields are contiguous in both the source and destination:
00228      * Address Granularity
00229      * Address Range Minimum
00230      * Address Range Maximum
00231      * Address Translation Offset
00232      * Address Length
00233      */
00234     {ACPI_RSC_MOVE64,   ACPI_RS_OFFSET (Data.Address64.Granularity),
00235                         AML_OFFSET (Address64.Granularity),
00236                         5},
00237 
00238     /* Optional ResourceSource (Index and String) */
00239 
00240     {ACPI_RSC_SOURCE,   ACPI_RS_OFFSET (Data.Address64.ResourceSource),
00241                         0,
00242                         sizeof (AML_RESOURCE_ADDRESS64)}
00243 };
00244 
00245 
00246 /*******************************************************************************
00247  *
00248  * AcpiRsConvertExtAddress64 - All Extended (64-bit) address resources
00249  *
00250  ******************************************************************************/
00251 
00252 ACPI_RSCONVERT_INFO     AcpiRsConvertExtAddress64[5] =
00253 {
00254     {ACPI_RSC_INITGET,  ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64,
00255                         ACPI_RS_SIZE (ACPI_RESOURCE_EXTENDED_ADDRESS64),
00256                         ACPI_RSC_TABLE_SIZE (AcpiRsConvertExtAddress64)},
00257 
00258     {ACPI_RSC_INITSET,  ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64,
00259                         sizeof (AML_RESOURCE_EXTENDED_ADDRESS64),
00260                         0},
00261 
00262     /* Resource Type, General Flags, and Type-Specific Flags */
00263 
00264     {ACPI_RSC_ADDRESS,  0, 0, 0},
00265 
00266     /* Revision ID */
00267 
00268     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.ExtAddress64.RevisionID),
00269                         AML_OFFSET (ExtAddress64.RevisionID),
00270                         1},
00271     /*
00272      * These fields are contiguous in both the source and destination:
00273      * Address Granularity
00274      * Address Range Minimum
00275      * Address Range Maximum
00276      * Address Translation Offset
00277      * Address Length
00278      * Type-Specific Attribute
00279      */
00280     {ACPI_RSC_MOVE64,   ACPI_RS_OFFSET (Data.ExtAddress64.Granularity),
00281                         AML_OFFSET (ExtAddress64.Granularity),
00282                         6}
00283 };
00284 
00285 
00286 /*******************************************************************************
00287  *
00288  * AcpiRsConvertGeneralFlags - Flags common to all address descriptors
00289  *
00290  ******************************************************************************/
00291 
00292 static ACPI_RSCONVERT_INFO  AcpiRsConvertGeneralFlags[6] =
00293 {
00294     {ACPI_RSC_FLAGINIT, 0, AML_OFFSET (Address.Flags),
00295                         ACPI_RSC_TABLE_SIZE (AcpiRsConvertGeneralFlags)},
00296 
00297     /* Resource Type (Memory, Io, BusNumber, etc.) */
00298 
00299     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.Address.ResourceType),
00300                         AML_OFFSET (Address.ResourceType),
00301                         1},
00302 
00303     /* General Flags - Consume, Decode, MinFixed, MaxFixed */
00304 
00305     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.ProducerConsumer),
00306                         AML_OFFSET (Address.Flags),
00307                         0},
00308 
00309     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.Decode),
00310                         AML_OFFSET (Address.Flags),
00311                         1},
00312 
00313     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.MinAddressFixed),
00314                         AML_OFFSET (Address.Flags),
00315                         2},
00316 
00317     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.MaxAddressFixed),
00318                         AML_OFFSET (Address.Flags),
00319                         3}
00320 };
00321 
00322 
00323 /*******************************************************************************
00324  *
00325  * AcpiRsConvertMemFlags - Flags common to Memory address descriptors
00326  *
00327  ******************************************************************************/
00328 
00329 static ACPI_RSCONVERT_INFO  AcpiRsConvertMemFlags[5] =
00330 {
00331     {ACPI_RSC_FLAGINIT, 0, AML_OFFSET (Address.SpecificFlags),
00332                         ACPI_RSC_TABLE_SIZE (AcpiRsConvertMemFlags)},
00333 
00334     /* Memory-specific flags */
00335 
00336     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Mem.WriteProtect),
00337                         AML_OFFSET (Address.SpecificFlags),
00338                         0},
00339 
00340     {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Mem.Caching),
00341                         AML_OFFSET (Address.SpecificFlags),
00342                         1},
00343 
00344     {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Mem.RangeType),
00345                         AML_OFFSET (Address.SpecificFlags),
00346                         3},
00347 
00348     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Mem.Translation),
00349                         AML_OFFSET (Address.SpecificFlags),
00350                         5}
00351 };
00352 
00353 
00354 /*******************************************************************************
00355  *
00356  * AcpiRsConvertIoFlags - Flags common to I/O address descriptors
00357  *
00358  ******************************************************************************/
00359 
00360 static ACPI_RSCONVERT_INFO  AcpiRsConvertIoFlags[4] =
00361 {
00362     {ACPI_RSC_FLAGINIT, 0, AML_OFFSET (Address.SpecificFlags),
00363                         ACPI_RSC_TABLE_SIZE (AcpiRsConvertIoFlags)},
00364 
00365     /* I/O-specific flags */
00366 
00367     {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Io.RangeType),
00368                         AML_OFFSET (Address.SpecificFlags),
00369                         0},
00370 
00371     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Io.Translation),
00372                         AML_OFFSET (Address.SpecificFlags),
00373                         4},
00374 
00375     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Io.TranslationType),
00376                         AML_OFFSET (Address.SpecificFlags),
00377                         5}
00378 };
00379 
00380 
00381 /*******************************************************************************
00382  *
00383  * FUNCTION:    AcpiRsGetAddressCommon
00384  *
00385  * PARAMETERS:  Resource            - Pointer to the internal resource struct
00386  *              Aml                 - Pointer to the AML resource descriptor
00387  *
00388  * RETURN:      TRUE if the ResourceType field is OK, FALSE otherwise
00389  *
00390  * DESCRIPTION: Convert common flag fields from a raw AML resource descriptor
00391  *              to an internal resource descriptor
00392  *
00393  ******************************************************************************/
00394 
00395 BOOLEAN
00396 AcpiRsGetAddressCommon (
00397     ACPI_RESOURCE           *Resource,
00398     AML_RESOURCE            *Aml)
00399 {
00400     ACPI_FUNCTION_ENTRY ();
00401 
00402 
00403     /* Validate the Resource Type */
00404 
00405     if ((Aml->Address.ResourceType > 2) && (Aml->Address.ResourceType < 0xC0))
00406     {
00407         return (FALSE);
00408     }
00409 
00410     /* Get the Resource Type and General Flags */
00411 
00412     (void) AcpiRsConvertAmlToResource (Resource, Aml, AcpiRsConvertGeneralFlags);
00413 
00414     /* Get the Type-Specific Flags (Memory and I/O descriptors only) */
00415 
00416     if (Resource->Data.Address.ResourceType == ACPI_MEMORY_RANGE)
00417     {
00418         (void) AcpiRsConvertAmlToResource (Resource, Aml, AcpiRsConvertMemFlags);
00419     }
00420     else if (Resource->Data.Address.ResourceType == ACPI_IO_RANGE)
00421     {
00422         (void) AcpiRsConvertAmlToResource (Resource, Aml, AcpiRsConvertIoFlags);
00423     }
00424     else
00425     {
00426         /* Generic resource type, just grab the TypeSpecific byte */
00427 
00428         Resource->Data.Address.Info.TypeSpecific = Aml->Address.SpecificFlags;
00429     }
00430 
00431     return (TRUE);
00432 }
00433 
00434 
00435 /*******************************************************************************
00436  *
00437  * FUNCTION:    AcpiRsSetAddressCommon
00438  *
00439  * PARAMETERS:  Aml                 - Pointer to the AML resource descriptor
00440  *              Resource            - Pointer to the internal resource struct
00441  *
00442  * RETURN:      None
00443  *
00444  * DESCRIPTION: Convert common flag fields from a resource descriptor to an
00445  *              AML descriptor
00446  *
00447  ******************************************************************************/
00448 
00449 void
00450 AcpiRsSetAddressCommon (
00451     AML_RESOURCE            *Aml,
00452     ACPI_RESOURCE           *Resource)
00453 {
00454     ACPI_FUNCTION_ENTRY ();
00455 
00456 
00457     /* Set the Resource Type and General Flags */
00458 
00459     (void) AcpiRsConvertResourceToAml (Resource, Aml, AcpiRsConvertGeneralFlags);
00460 
00461     /* Set the Type-Specific Flags (Memory and I/O descriptors only) */
00462 
00463     if (Resource->Data.Address.ResourceType == ACPI_MEMORY_RANGE)
00464     {
00465         (void) AcpiRsConvertResourceToAml (Resource, Aml, AcpiRsConvertMemFlags);
00466     }
00467     else if (Resource->Data.Address.ResourceType == ACPI_IO_RANGE)
00468     {
00469         (void) AcpiRsConvertResourceToAml (Resource, Aml, AcpiRsConvertIoFlags);
00470     }
00471     else
00472     {
00473         /* Generic resource type, just copy the TypeSpecific byte */
00474 
00475         Aml->Address.SpecificFlags = Resource->Data.Address.Info.TypeSpecific;
00476     }
00477 }
00478 
00479 

Generated on Sun May 27 2012 04:27:22 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.