Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
0002 /*******************************************************************************
0003  *
0004  * Module Name: rsio - IO and DMA resource descriptors
0005  *
0006  ******************************************************************************/
0007 
0008 #include <acpi/acpi.h>
0009 #include "accommon.h"
0010 #include "acresrc.h"
0011 
0012 #define _COMPONENT          ACPI_RESOURCES
0013 ACPI_MODULE_NAME("rsio")
0014 
0015 /*******************************************************************************
0016  *
0017  * acpi_rs_convert_io
0018  *
0019  ******************************************************************************/
0020 struct acpi_rsconvert_info acpi_rs_convert_io[5] = {
0021     {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_IO,
0022      ACPI_RS_SIZE(struct acpi_resource_io),
0023      ACPI_RSC_TABLE_SIZE(acpi_rs_convert_io)},
0024 
0025     {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_IO,
0026      sizeof(struct aml_resource_io),
0027      0},
0028 
0029     /* Decode flag */
0030 
0031     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.io.io_decode),
0032      AML_OFFSET(io.flags),
0033      0},
0034     /*
0035      * These fields are contiguous in both the source and destination:
0036      * Address Alignment
0037      * Length
0038      * Minimum Base Address
0039      * Maximum Base Address
0040      */
0041     {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.io.alignment),
0042      AML_OFFSET(io.alignment),
0043      2},
0044 
0045     {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.io.minimum),
0046      AML_OFFSET(io.minimum),
0047      2}
0048 };
0049 
0050 /*******************************************************************************
0051  *
0052  * acpi_rs_convert_fixed_io
0053  *
0054  ******************************************************************************/
0055 
0056 struct acpi_rsconvert_info acpi_rs_convert_fixed_io[4] = {
0057     {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_FIXED_IO,
0058      ACPI_RS_SIZE(struct acpi_resource_fixed_io),
0059      ACPI_RSC_TABLE_SIZE(acpi_rs_convert_fixed_io)},
0060 
0061     {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_FIXED_IO,
0062      sizeof(struct aml_resource_fixed_io),
0063      0},
0064     /*
0065      * These fields are contiguous in both the source and destination:
0066      * Base Address
0067      * Length
0068      */
0069     {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.fixed_io.address_length),
0070      AML_OFFSET(fixed_io.address_length),
0071      1},
0072 
0073     {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.fixed_io.address),
0074      AML_OFFSET(fixed_io.address),
0075      1}
0076 };
0077 
0078 /*******************************************************************************
0079  *
0080  * acpi_rs_convert_generic_reg
0081  *
0082  ******************************************************************************/
0083 
0084 struct acpi_rsconvert_info acpi_rs_convert_generic_reg[4] = {
0085     {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_GENERIC_REGISTER,
0086      ACPI_RS_SIZE(struct acpi_resource_generic_register),
0087      ACPI_RSC_TABLE_SIZE(acpi_rs_convert_generic_reg)},
0088 
0089     {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_GENERIC_REGISTER,
0090      sizeof(struct aml_resource_generic_register),
0091      0},
0092     /*
0093      * These fields are contiguous in both the source and destination:
0094      * Address Space ID
0095      * Register Bit Width
0096      * Register Bit Offset
0097      * Access Size
0098      */
0099     {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.generic_reg.space_id),
0100      AML_OFFSET(generic_reg.address_space_id),
0101      4},
0102 
0103     /* Get the Register Address */
0104 
0105     {ACPI_RSC_MOVE64, ACPI_RS_OFFSET(data.generic_reg.address),
0106      AML_OFFSET(generic_reg.address),
0107      1}
0108 };
0109 
0110 /*******************************************************************************
0111  *
0112  * acpi_rs_convert_end_dpf
0113  *
0114  ******************************************************************************/
0115 
0116 struct acpi_rsconvert_info acpi_rs_convert_end_dpf[2] = {
0117     {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_END_DEPENDENT,
0118      ACPI_RS_SIZE_MIN,
0119      ACPI_RSC_TABLE_SIZE(acpi_rs_convert_end_dpf)},
0120 
0121     {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_END_DEPENDENT,
0122      sizeof(struct aml_resource_end_dependent),
0123      0}
0124 };
0125 
0126 /*******************************************************************************
0127  *
0128  * acpi_rs_convert_end_tag
0129  *
0130  ******************************************************************************/
0131 
0132 struct acpi_rsconvert_info acpi_rs_convert_end_tag[2] = {
0133     {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_END_TAG,
0134      ACPI_RS_SIZE_MIN,
0135      ACPI_RSC_TABLE_SIZE(acpi_rs_convert_end_tag)},
0136 
0137     /*
0138      * Note: The checksum field is set to zero, meaning that the resource
0139      * data is treated as if the checksum operation succeeded.
0140      * (ACPI Spec 1.0b Section 6.4.2.8)
0141      */
0142     {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_END_TAG,
0143      sizeof(struct aml_resource_end_tag),
0144      0}
0145 };
0146 
0147 /*******************************************************************************
0148  *
0149  * acpi_rs_get_start_dpf
0150  *
0151  ******************************************************************************/
0152 
0153 struct acpi_rsconvert_info acpi_rs_get_start_dpf[6] = {
0154     {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_START_DEPENDENT,
0155      ACPI_RS_SIZE(struct acpi_resource_start_dependent),
0156      ACPI_RSC_TABLE_SIZE(acpi_rs_get_start_dpf)},
0157 
0158     /* Defaults for Compatibility and Performance priorities */
0159 
0160     {ACPI_RSC_SET8, ACPI_RS_OFFSET(data.start_dpf.compatibility_priority),
0161      ACPI_ACCEPTABLE_CONFIGURATION,
0162      2},
0163 
0164     /* Get the descriptor length (0 or 1 for Start Dpf descriptor) */
0165 
0166     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.start_dpf.descriptor_length),
0167      AML_OFFSET(start_dpf.descriptor_type),
0168      0},
0169 
0170     /* All done if there is no flag byte present in the descriptor */
0171 
0172     {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_AML_LENGTH, 0, 1},
0173 
0174     /* Flag byte is present, get the flags */
0175 
0176     {ACPI_RSC_2BITFLAG,
0177      ACPI_RS_OFFSET(data.start_dpf.compatibility_priority),
0178      AML_OFFSET(start_dpf.flags),
0179      0},
0180 
0181     {ACPI_RSC_2BITFLAG,
0182      ACPI_RS_OFFSET(data.start_dpf.performance_robustness),
0183      AML_OFFSET(start_dpf.flags),
0184      2}
0185 };
0186 
0187 /*******************************************************************************
0188  *
0189  * acpi_rs_set_start_dpf
0190  *
0191  ******************************************************************************/
0192 
0193 struct acpi_rsconvert_info acpi_rs_set_start_dpf[10] = {
0194     /* Start with a default descriptor of length 1 */
0195 
0196     {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_START_DEPENDENT,
0197      sizeof(struct aml_resource_start_dependent),
0198      ACPI_RSC_TABLE_SIZE(acpi_rs_set_start_dpf)},
0199 
0200     /* Set the default flag values */
0201 
0202     {ACPI_RSC_2BITFLAG,
0203      ACPI_RS_OFFSET(data.start_dpf.compatibility_priority),
0204      AML_OFFSET(start_dpf.flags),
0205      0},
0206 
0207     {ACPI_RSC_2BITFLAG,
0208      ACPI_RS_OFFSET(data.start_dpf.performance_robustness),
0209      AML_OFFSET(start_dpf.flags),
0210      2},
0211     /*
0212      * All done if the output descriptor length is required to be 1
0213      * (i.e., optimization to 0 bytes cannot be attempted)
0214      */
0215     {ACPI_RSC_EXIT_EQ, ACPI_RSC_COMPARE_VALUE,
0216      ACPI_RS_OFFSET(data.start_dpf.descriptor_length),
0217      1},
0218 
0219     /* Set length to 0 bytes (no flags byte) */
0220 
0221     {ACPI_RSC_LENGTH, 0, 0,
0222      sizeof(struct aml_resource_start_dependent_noprio)},
0223 
0224     /*
0225      * All done if the output descriptor length is required to be 0.
0226      *
0227      * TBD: Perhaps we should check for error if input flags are not
0228      * compatible with a 0-byte descriptor.
0229      */
0230     {ACPI_RSC_EXIT_EQ, ACPI_RSC_COMPARE_VALUE,
0231      ACPI_RS_OFFSET(data.start_dpf.descriptor_length),
0232      0},
0233 
0234     /* Reset length to 1 byte (descriptor with flags byte) */
0235 
0236     {ACPI_RSC_LENGTH, 0, 0, sizeof(struct aml_resource_start_dependent)},
0237 
0238     /*
0239      * All done if flags byte is necessary -- if either priority value
0240      * is not ACPI_ACCEPTABLE_CONFIGURATION
0241      */
0242     {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE,
0243      ACPI_RS_OFFSET(data.start_dpf.compatibility_priority),
0244      ACPI_ACCEPTABLE_CONFIGURATION},
0245 
0246     {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE,
0247      ACPI_RS_OFFSET(data.start_dpf.performance_robustness),
0248      ACPI_ACCEPTABLE_CONFIGURATION},
0249 
0250     /* Flag byte is not necessary */
0251 
0252     {ACPI_RSC_LENGTH, 0, 0,
0253      sizeof(struct aml_resource_start_dependent_noprio)}
0254 };