ReactOS 0.4.15-dev-7958-gcd0bb1a
rsaddr.c
Go to the documentation of this file.
1/*******************************************************************************
2 *
3 * Module Name: rsaddr - Address resource descriptors (16/32/64)
4 *
5 ******************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2022, 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 MERCHANTABILITY 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 ("rsaddr")
50
51
52/*******************************************************************************
53 *
54 * AcpiRsConvertAddress16 - All WORD (16-bit) address resources
55 *
56 ******************************************************************************/
57
59{
63
66 0},
67
68 /* Resource Type, General Flags, and Type-Specific Flags */
69
70 {ACPI_RSC_ADDRESS, 0, 0, 0},
71
72 /*
73 * These fields are contiguous in both the source and destination:
74 * Address Granularity
75 * Address Range Minimum
76 * Address Range Maximum
77 * Address Translation Offset
78 * Address Length
79 */
80 {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.Address16.Address.Granularity),
81 AML_OFFSET (Address16.Granularity),
82 5},
83
84 /* Optional ResourceSource (Index and String) */
85
86 {ACPI_RSC_SOURCE, ACPI_RS_OFFSET (Data.Address16.ResourceSource),
87 0,
89};
90
91
92/*******************************************************************************
93 *
94 * AcpiRsConvertAddress32 - All DWORD (32-bit) address resources
95 *
96 ******************************************************************************/
97
99{
103
105 sizeof (AML_RESOURCE_ADDRESS32),
106 0},
107
108 /* Resource Type, General Flags, and Type-Specific Flags */
109
110 {ACPI_RSC_ADDRESS, 0, 0, 0},
111
112 /*
113 * These fields are contiguous in both the source and destination:
114 * Address Granularity
115 * Address Range Minimum
116 * Address Range Maximum
117 * Address Translation Offset
118 * Address Length
119 */
120 {ACPI_RSC_MOVE32, ACPI_RS_OFFSET (Data.Address32.Address.Granularity),
121 AML_OFFSET (Address32.Granularity),
122 5},
123
124 /* Optional ResourceSource (Index and String) */
125
126 {ACPI_RSC_SOURCE, ACPI_RS_OFFSET (Data.Address32.ResourceSource),
127 0,
128 sizeof (AML_RESOURCE_ADDRESS32)}
129};
130
131
132/*******************************************************************************
133 *
134 * AcpiRsConvertAddress64 - All QWORD (64-bit) address resources
135 *
136 ******************************************************************************/
137
139{
143
145 sizeof (AML_RESOURCE_ADDRESS64),
146 0},
147
148 /* Resource Type, General Flags, and Type-Specific Flags */
149
150 {ACPI_RSC_ADDRESS, 0, 0, 0},
151
152 /*
153 * These fields are contiguous in both the source and destination:
154 * Address Granularity
155 * Address Range Minimum
156 * Address Range Maximum
157 * Address Translation Offset
158 * Address Length
159 */
160 {ACPI_RSC_MOVE64, ACPI_RS_OFFSET (Data.Address64.Address.Granularity),
161 AML_OFFSET (Address64.Granularity),
162 5},
163
164 /* Optional ResourceSource (Index and String) */
165
166 {ACPI_RSC_SOURCE, ACPI_RS_OFFSET (Data.Address64.ResourceSource),
167 0,
168 sizeof (AML_RESOURCE_ADDRESS64)}
169};
170
171
172/*******************************************************************************
173 *
174 * AcpiRsConvertExtAddress64 - All Extended (64-bit) address resources
175 *
176 ******************************************************************************/
177
179{
183
186 0},
187
188 /* Resource Type, General Flags, and Type-Specific Flags */
189
190 {ACPI_RSC_ADDRESS, 0, 0, 0},
191
192 /* Revision ID */
193
194 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.ExtAddress64.RevisionID),
195 AML_OFFSET (ExtAddress64.RevisionID),
196 1},
197 /*
198 * These fields are contiguous in both the source and destination:
199 * Address Granularity
200 * Address Range Minimum
201 * Address Range Maximum
202 * Address Translation Offset
203 * Address Length
204 * Type-Specific Attribute
205 */
206 {ACPI_RSC_MOVE64, ACPI_RS_OFFSET (Data.ExtAddress64.Address.Granularity),
207 AML_OFFSET (ExtAddress64.Granularity),
208 6}
209};
210
211
212/*******************************************************************************
213 *
214 * AcpiRsConvertGeneralFlags - Flags common to all address descriptors
215 *
216 ******************************************************************************/
217
219{
222
223 /* Resource Type (Memory, Io, BusNumber, etc.) */
224
225 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.Address.ResourceType),
226 AML_OFFSET (Address.ResourceType),
227 1},
228
229 /* General Flags - Consume, Decode, MinFixed, MaxFixed */
230
231 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.ProducerConsumer),
232 AML_OFFSET (Address.Flags),
233 0},
234
235 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.Decode),
236 AML_OFFSET (Address.Flags),
237 1},
238
239 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.MinAddressFixed),
240 AML_OFFSET (Address.Flags),
241 2},
242
243 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.MaxAddressFixed),
244 AML_OFFSET (Address.Flags),
245 3}
246};
247
248
249/*******************************************************************************
250 *
251 * AcpiRsConvertMemFlags - Flags common to Memory address descriptors
252 *
253 ******************************************************************************/
254
256{
257 {ACPI_RSC_FLAGINIT, 0, AML_OFFSET (Address.SpecificFlags),
259
260 /* Memory-specific flags */
261
262 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Mem.WriteProtect),
263 AML_OFFSET (Address.SpecificFlags),
264 0},
265
266 {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Mem.Caching),
267 AML_OFFSET (Address.SpecificFlags),
268 1},
269
270 {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Mem.RangeType),
271 AML_OFFSET (Address.SpecificFlags),
272 3},
273
274 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Mem.Translation),
275 AML_OFFSET (Address.SpecificFlags),
276 5}
277};
278
279
280/*******************************************************************************
281 *
282 * AcpiRsConvertIoFlags - Flags common to I/O address descriptors
283 *
284 ******************************************************************************/
285
287{
288 {ACPI_RSC_FLAGINIT, 0, AML_OFFSET (Address.SpecificFlags),
290
291 /* I/O-specific flags */
292
293 {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Io.RangeType),
294 AML_OFFSET (Address.SpecificFlags),
295 0},
296
297 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Io.Translation),
298 AML_OFFSET (Address.SpecificFlags),
299 4},
300
301 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Io.TranslationType),
302 AML_OFFSET (Address.SpecificFlags),
303 5}
304};
305
306
307/*******************************************************************************
308 *
309 * FUNCTION: AcpiRsGetAddressCommon
310 *
311 * PARAMETERS: Resource - Pointer to the internal resource struct
312 * Aml - Pointer to the AML resource descriptor
313 *
314 * RETURN: TRUE if the ResourceType field is OK, FALSE otherwise
315 *
316 * DESCRIPTION: Convert common flag fields from a raw AML resource descriptor
317 * to an internal resource descriptor
318 *
319 ******************************************************************************/
320
325{
327
328
329 /* Validate the Resource Type */
330
331 if ((Aml->Address.ResourceType > 2) &&
332 (Aml->Address.ResourceType < 0xC0))
333 {
334 return (FALSE);
335 }
336
337 /* Get the Resource Type and General Flags */
338
341
342 /* Get the Type-Specific Flags (Memory and I/O descriptors only) */
343
344 if (Resource->Data.Address.ResourceType == ACPI_MEMORY_RANGE)
345 {
348 }
349 else if (Resource->Data.Address.ResourceType == ACPI_IO_RANGE)
350 {
353 }
354 else
355 {
356 /* Generic resource type, just grab the TypeSpecific byte */
357
358 Resource->Data.Address.Info.TypeSpecific =
359 Aml->Address.SpecificFlags;
360 }
361
362 return (TRUE);
363}
364
365
366/*******************************************************************************
367 *
368 * FUNCTION: AcpiRsSetAddressCommon
369 *
370 * PARAMETERS: Aml - Pointer to the AML resource descriptor
371 * Resource - Pointer to the internal resource struct
372 *
373 * RETURN: None
374 *
375 * DESCRIPTION: Convert common flag fields from a resource descriptor to an
376 * AML descriptor
377 *
378 ******************************************************************************/
379
380void
384{
386
387
388 /* Set the Resource Type and General Flags */
389
392
393 /* Set the Type-Specific Flags (Memory and I/O descriptors only) */
394
395 if (Resource->Data.Address.ResourceType == ACPI_MEMORY_RANGE)
396 {
399 }
400 else if (Resource->Data.Address.ResourceType == ACPI_IO_RANGE)
401 {
404 }
405 else
406 {
407 /* Generic resource type, just copy the TypeSpecific byte */
408
409 Aml->Address.SpecificFlags =
410 Resource->Data.Address.Info.TypeSpecific;
411 }
412}
unsigned char BOOLEAN
#define ACPI_RESOURCE_NAME_ADDRESS64
Definition: aclocal.h:1338
#define ACPI_RESOURCE_NAME_ADDRESS32
Definition: aclocal.h:1335
#define ACPI_RESOURCE_NAME_ADDRESS16
Definition: aclocal.h:1336
#define ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64
Definition: aclocal.h:1339
#define ACPI_MODULE_NAME(Name)
Definition: acoutput.h:216
#define ACPI_FUNCTION_ENTRY()
Definition: acoutput.h:484
ACPI_BUFFER *RetBuffer ACPI_BUFFER *RetBuffer char ACPI_WALK_RESOURCE_CALLBACK void *Context ACPI_BUFFER *RetBuffer UINT16 ACPI_RESOURCE **ResourcePtr ACPI_GENERIC_ADDRESS *Reg UINT32 *ReturnValue UINT8 UINT8 *Slp_TypB ACPI_PHYSICAL_ADDRESS PhysicalAddress64 UINT32 UINT32 *TimeElapsed UINT32 ACPI_STATUS const char UINT32 ACPI_STATUS const char UINT32 const char const char UINT32 const char BOOLEAN UINT8 * Aml
Definition: acpixf.h:1302
ACPI_STATUS AcpiRsConvertResourceToAml(ACPI_RESOURCE *Resource, AML_RESOURCE *Aml, ACPI_RSCONVERT_INFO *Info)
Definition: rsmisc.c:478
@ ACPI_RSC_INITSET
Definition: acresrc.h:81
@ ACPI_RSC_MOVE64
Definition: acresrc.h:109
@ ACPI_RSC_2BITFLAG
Definition: acresrc.h:84
@ ACPI_RSC_FLAGINIT
Definition: acresrc.h:82
@ ACPI_RSC_MOVE8
Definition: acresrc.h:106
@ ACPI_RSC_SOURCE
Definition: acresrc.h:111
@ ACPI_RSC_ADDRESS
Definition: acresrc.h:87
@ ACPI_RSC_MOVE16
Definition: acresrc.h:107
@ ACPI_RSC_MOVE32
Definition: acresrc.h:108
@ ACPI_RSC_1BITFLAG
Definition: acresrc.h:83
@ ACPI_RSC_INITGET
Definition: acresrc.h:80
#define ACPI_RSC_TABLE_SIZE(d)
Definition: acresrc.h:121
#define ACPI_RS_OFFSET(f)
Definition: acresrc.h:123
#define AML_OFFSET(f)
Definition: acresrc.h:124
ACPI_STATUS AcpiRsConvertAmlToResource(ACPI_RESOURCE *Resource, AML_RESOURCE *Aml, ACPI_RSCONVERT_INFO *Info)
Definition: rsmisc.c:77
#define ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64
Definition: acrestyp.h:737
#define ACPI_RESOURCE_TYPE_ADDRESS64
Definition: acrestyp.h:736
#define ACPI_RS_SIZE(Type)
Definition: acrestyp.h:808
#define ACPI_IO_RANGE
Definition: acrestyp.h:138
#define ACPI_RESOURCE_TYPE_ADDRESS32
Definition: acrestyp.h:735
#define ACPI_RESOURCE_TYPE_ADDRESS16
Definition: acrestyp.h:734
#define ACPI_MEMORY_RANGE
Definition: acrestyp.h:137
struct aml_resource_address64 AML_RESOURCE_ADDRESS64
struct aml_resource_extended_address64 AML_RESOURCE_EXTENDED_ADDRESS64
struct aml_resource_address16 AML_RESOURCE_ADDRESS16
struct aml_resource_address32 AML_RESOURCE_ADDRESS32
_Acquires_exclusive_lock_ Resource _Acquires_shared_lock_ Resource _Inout_ PERESOURCE Resource
Definition: cdprocs.h:843
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static WCHAR Address[46]
Definition: ping.c:68
static ACPI_RSCONVERT_INFO AcpiRsConvertGeneralFlags[6]
Definition: rsaddr.c:218
static ACPI_RSCONVERT_INFO AcpiRsConvertIoFlags[4]
Definition: rsaddr.c:286
ACPI_RSCONVERT_INFO AcpiRsConvertAddress16[5]
Definition: rsaddr.c:58
static ACPI_RSCONVERT_INFO AcpiRsConvertMemFlags[5]
Definition: rsaddr.c:255
ACPI_RSCONVERT_INFO AcpiRsConvertExtAddress64[5]
Definition: rsaddr.c:178
BOOLEAN AcpiRsGetAddressCommon(ACPI_RESOURCE *Resource, AML_RESOURCE *Aml)
Definition: rsaddr.c:322
void AcpiRsSetAddressCommon(AML_RESOURCE *Aml, ACPI_RESOURCE *Resource)
Definition: rsaddr.c:381
ACPI_RSCONVERT_INFO AcpiRsConvertAddress64[5]
Definition: rsaddr.c:138
ACPI_RSCONVERT_INFO AcpiRsConvertAddress32[5]
Definition: rsaddr.c:98