xref: /titanic_41/usr/src/uts/intel/io/acpica/resources/rsmemory.c (revision de5d74c22760a6d2cefd94d0e7f0fd87214fb71f)
1 /*******************************************************************************
2  *
3  * Module Name: rsmem24 - Memory resource descriptors
4  *
5  ******************************************************************************/
6 
7 /*
8  * Copyright (C) 2000 - 2016, Intel Corp.
9  * All rights reserved.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  * 1. Redistributions of source code must retain the above copyright
15  *    notice, this list of conditions, and the following disclaimer,
16  *    without modification.
17  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18  *    substantially similar to the "NO WARRANTY" disclaimer below
19  *    ("Disclaimer") and any redistribution must be conditioned upon
20  *    including a substantially similar Disclaimer requirement for further
21  *    binary redistribution.
22  * 3. Neither the names of the above-listed copyright holders nor the names
23  *    of any contributors may be used to endorse or promote products derived
24  *    from this software without specific prior written permission.
25  *
26  * Alternatively, this software may be distributed under the terms of the
27  * GNU General Public License ("GPL") version 2 as published by the Free
28  * Software Foundation.
29  *
30  * NO WARRANTY
31  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41  * POSSIBILITY OF SUCH DAMAGES.
42  */
43 
44 #include "acpi.h"
45 #include "accommon.h"
46 #include "acresrc.h"
47 
48 #define _COMPONENT          ACPI_RESOURCES
49         ACPI_MODULE_NAME    ("rsmemory")
50 
51 
52 /*******************************************************************************
53  *
54  * AcpiRsConvertMemory24
55  *
56  ******************************************************************************/
57 
58 ACPI_RSCONVERT_INFO     AcpiRsConvertMemory24[4] =
59 {
60     {ACPI_RSC_INITGET,  ACPI_RESOURCE_TYPE_MEMORY24,
61                         ACPI_RS_SIZE (ACPI_RESOURCE_MEMORY24),
62                         ACPI_RSC_TABLE_SIZE (AcpiRsConvertMemory24)},
63 
64     {ACPI_RSC_INITSET,  ACPI_RESOURCE_NAME_MEMORY24,
65                         sizeof (AML_RESOURCE_MEMORY24),
66                         0},
67 
68     /* Read/Write bit */
69 
70     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Memory24.WriteProtect),
71                         AML_OFFSET (Memory24.Flags),
72                         0},
73     /*
74      * These fields are contiguous in both the source and destination:
75      * Minimum Base Address
76      * Maximum Base Address
77      * Address Base Alignment
78      * Range Length
79      */
80     {ACPI_RSC_MOVE16,   ACPI_RS_OFFSET (Data.Memory24.Minimum),
81                         AML_OFFSET (Memory24.Minimum),
82                         4}
83 };
84 
85 
86 /*******************************************************************************
87  *
88  * AcpiRsConvertMemory32
89  *
90  ******************************************************************************/
91 
92 ACPI_RSCONVERT_INFO     AcpiRsConvertMemory32[4] =
93 {
94     {ACPI_RSC_INITGET,  ACPI_RESOURCE_TYPE_MEMORY32,
95                         ACPI_RS_SIZE (ACPI_RESOURCE_MEMORY32),
96                         ACPI_RSC_TABLE_SIZE (AcpiRsConvertMemory32)},
97 
98     {ACPI_RSC_INITSET,  ACPI_RESOURCE_NAME_MEMORY32,
99                         sizeof (AML_RESOURCE_MEMORY32),
100                         0},
101 
102     /* Read/Write bit */
103 
104     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Memory32.WriteProtect),
105                         AML_OFFSET (Memory32.Flags),
106                         0},
107     /*
108      * These fields are contiguous in both the source and destination:
109      * Minimum Base Address
110      * Maximum Base Address
111      * Address Base Alignment
112      * Range Length
113      */
114     {ACPI_RSC_MOVE32,   ACPI_RS_OFFSET (Data.Memory32.Minimum),
115                         AML_OFFSET (Memory32.Minimum),
116                         4}
117 };
118 
119 
120 /*******************************************************************************
121  *
122  * AcpiRsConvertFixedMemory32
123  *
124  ******************************************************************************/
125 
126 ACPI_RSCONVERT_INFO     AcpiRsConvertFixedMemory32[4] =
127 {
128     {ACPI_RSC_INITGET,  ACPI_RESOURCE_TYPE_FIXED_MEMORY32,
129                         ACPI_RS_SIZE (ACPI_RESOURCE_FIXED_MEMORY32),
130                         ACPI_RSC_TABLE_SIZE (AcpiRsConvertFixedMemory32)},
131 
132     {ACPI_RSC_INITSET,  ACPI_RESOURCE_NAME_FIXED_MEMORY32,
133                         sizeof (AML_RESOURCE_FIXED_MEMORY32),
134                         0},
135 
136     /* Read/Write bit */
137 
138     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.FixedMemory32.WriteProtect),
139                         AML_OFFSET (FixedMemory32.Flags),
140                         0},
141     /*
142      * These fields are contiguous in both the source and destination:
143      * Base Address
144      * Range Length
145      */
146     {ACPI_RSC_MOVE32,   ACPI_RS_OFFSET (Data.FixedMemory32.Address),
147                         AML_OFFSET (FixedMemory32.Address),
148                         2}
149 };
150 
151 
152 /*******************************************************************************
153  *
154  * AcpiRsGetVendorSmall
155  *
156  ******************************************************************************/
157 
158 ACPI_RSCONVERT_INFO     AcpiRsGetVendorSmall[3] =
159 {
160     {ACPI_RSC_INITGET,  ACPI_RESOURCE_TYPE_VENDOR,
161                         ACPI_RS_SIZE (ACPI_RESOURCE_VENDOR),
162                         ACPI_RSC_TABLE_SIZE (AcpiRsGetVendorSmall)},
163 
164     /* Length of the vendor data (byte count) */
165 
166     {ACPI_RSC_COUNT16,  ACPI_RS_OFFSET (Data.Vendor.ByteLength),
167                         0,
168                         sizeof (UINT8)},
169 
170     /* Vendor data */
171 
172     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.Vendor.ByteData[0]),
173                         sizeof (AML_RESOURCE_SMALL_HEADER),
174                         0}
175 };
176 
177 
178 /*******************************************************************************
179  *
180  * AcpiRsGetVendorLarge
181  *
182  ******************************************************************************/
183 
184 ACPI_RSCONVERT_INFO     AcpiRsGetVendorLarge[3] =
185 {
186     {ACPI_RSC_INITGET,  ACPI_RESOURCE_TYPE_VENDOR,
187                         ACPI_RS_SIZE (ACPI_RESOURCE_VENDOR),
188                         ACPI_RSC_TABLE_SIZE (AcpiRsGetVendorLarge)},
189 
190     /* Length of the vendor data (byte count) */
191 
192     {ACPI_RSC_COUNT16,  ACPI_RS_OFFSET (Data.Vendor.ByteLength),
193                         0,
194                         sizeof (UINT8)},
195 
196     /* Vendor data */
197 
198     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.Vendor.ByteData[0]),
199                         sizeof (AML_RESOURCE_LARGE_HEADER),
200                         0}
201 };
202 
203 
204 /*******************************************************************************
205  *
206  * AcpiRsSetVendor
207  *
208  ******************************************************************************/
209 
210 ACPI_RSCONVERT_INFO     AcpiRsSetVendor[7] =
211 {
212     /* Default is a small vendor descriptor */
213 
214     {ACPI_RSC_INITSET,  ACPI_RESOURCE_NAME_VENDOR_SMALL,
215                         sizeof (AML_RESOURCE_SMALL_HEADER),
216                         ACPI_RSC_TABLE_SIZE (AcpiRsSetVendor)},
217 
218     /* Get the length and copy the data */
219 
220     {ACPI_RSC_COUNT16,  ACPI_RS_OFFSET (Data.Vendor.ByteLength),
221                         0,
222                         0},
223 
224     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.Vendor.ByteData[0]),
225                         sizeof (AML_RESOURCE_SMALL_HEADER),
226                         0},
227 
228     /*
229      * All done if the Vendor byte length is 7 or less, meaning that it will
230      * fit within a small descriptor
231      */
232     {ACPI_RSC_EXIT_LE,  0, 0, 7},
233 
234     /* Must create a large vendor descriptor */
235 
236     {ACPI_RSC_INITSET,  ACPI_RESOURCE_NAME_VENDOR_LARGE,
237                         sizeof (AML_RESOURCE_LARGE_HEADER),
238                         0},
239 
240     {ACPI_RSC_COUNT16,  ACPI_RS_OFFSET (Data.Vendor.ByteLength),
241                         0,
242                         0},
243 
244     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.Vendor.ByteData[0]),
245                         sizeof (AML_RESOURCE_LARGE_HEADER),
246                         0}
247 };
248