ReactOS 0.4.16-dev-88-ga65b6ae
acresrc.h File Reference
#include "amlresrc.h"
Include dependency graph for acresrc.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  acpi_rsconvert_info
 
struct  acpi_rsdump_info
 
struct  acpi_vendor_walk_info
 

Macros

#define ACPI_RSC_COMPARE_AML_LENGTH   0
 
#define ACPI_RSC_COMPARE_VALUE   1
 
#define ACPI_RSC_TABLE_SIZE(d)   (sizeof (d) / sizeof (ACPI_RSCONVERT_INFO))
 
#define ACPI_RS_OFFSET(f)   (UINT8) ACPI_OFFSET (ACPI_RESOURCE,f)
 
#define AML_OFFSET(f)   (UINT8) ACPI_OFFSET (AML_RESOURCE,f)
 

Typedefs

typedef const struct acpi_rsconvert_info ACPI_RSCONVERT_INFO
 
typedef const struct acpi_rsdump_info ACPI_RSDUMP_INFO
 
typedef struct acpi_vendor_walk_info ACPI_VENDOR_WALK_INFO
 

Enumerations

enum  ACPI_RSCONVERT_OPCODES {
  ACPI_RSC_INITGET = 0 , ACPI_RSC_INITSET , ACPI_RSC_FLAGINIT , ACPI_RSC_1BITFLAG ,
  ACPI_RSC_2BITFLAG , ACPI_RSC_3BITFLAG , ACPI_RSC_6BITFLAG , ACPI_RSC_ADDRESS ,
  ACPI_RSC_BITMASK , ACPI_RSC_BITMASK16 , ACPI_RSC_COUNT , ACPI_RSC_COUNT16 ,
  ACPI_RSC_COUNT_GPIO_PIN , ACPI_RSC_COUNT_GPIO_RES , ACPI_RSC_COUNT_GPIO_VEN , ACPI_RSC_COUNT_SERIAL_RES ,
  ACPI_RSC_COUNT_SERIAL_VEN , ACPI_RSC_DATA8 , ACPI_RSC_EXIT_EQ , ACPI_RSC_EXIT_LE ,
  ACPI_RSC_EXIT_NE , ACPI_RSC_LENGTH , ACPI_RSC_MOVE_GPIO_PIN , ACPI_RSC_MOVE_GPIO_RES ,
  ACPI_RSC_MOVE_SERIAL_RES , ACPI_RSC_MOVE_SERIAL_VEN , ACPI_RSC_MOVE8 , ACPI_RSC_MOVE16 ,
  ACPI_RSC_MOVE32 , ACPI_RSC_MOVE64 , ACPI_RSC_SET8 , ACPI_RSC_SOURCE ,
  ACPI_RSC_SOURCEX
}
 
enum  ACPI_RSDUMP_OPCODES {
  ACPI_RSD_TITLE = 0 , ACPI_RSD_1BITFLAG , ACPI_RSD_2BITFLAG , ACPI_RSD_3BITFLAG ,
  ACPI_RSD_6BITFLAG , ACPI_RSD_ADDRESS , ACPI_RSD_DWORDLIST , ACPI_RSD_LITERAL ,
  ACPI_RSD_LONGLIST , ACPI_RSD_SHORTLIST , ACPI_RSD_SHORTLISTX , ACPI_RSD_SOURCE ,
  ACPI_RSD_STRING , ACPI_RSD_UINT8 , ACPI_RSD_UINT16 , ACPI_RSD_UINT32 ,
  ACPI_RSD_UINT64 , ACPI_RSD_WORDLIST , ACPI_RSD_LABEL , ACPI_RSD_SOURCE_LABEL
}
 

Functions

ACPI_STATUS AcpiRsCreateResourceList (ACPI_OPERAND_OBJECT *AmlBuffer, ACPI_BUFFER *OutputBuffer)
 
ACPI_STATUS AcpiRsCreateAmlResources (ACPI_BUFFER *ResourceList, ACPI_BUFFER *OutputBuffer)
 
ACPI_STATUS AcpiRsCreatePciRoutingTable (ACPI_OPERAND_OBJECT *PackageObject, ACPI_BUFFER *OutputBuffer)
 
ACPI_STATUS AcpiRsGetPrtMethodData (ACPI_NAMESPACE_NODE *Node, ACPI_BUFFER *RetBuffer)
 
ACPI_STATUS AcpiRsGetCrsMethodData (ACPI_NAMESPACE_NODE *Node, ACPI_BUFFER *RetBuffer)
 
ACPI_STATUS AcpiRsGetPrsMethodData (ACPI_NAMESPACE_NODE *Node, ACPI_BUFFER *RetBuffer)
 
ACPI_STATUS AcpiRsGetMethodData (ACPI_HANDLE Handle, const char *Path, ACPI_BUFFER *RetBuffer)
 
ACPI_STATUS AcpiRsSetSrsMethodData (ACPI_NAMESPACE_NODE *Node, ACPI_BUFFER *RetBuffer)
 
ACPI_STATUS AcpiRsGetAeiMethodData (ACPI_NAMESPACE_NODE *Node, ACPI_BUFFER *RetBuffer)
 
ACPI_STATUS AcpiRsGetListLength (UINT8 *AmlBuffer, UINT32 AmlBufferLength, ACPI_SIZE *SizeNeeded)
 
ACPI_STATUS AcpiRsGetAmlLength (ACPI_RESOURCE *ResourceList, ACPI_SIZE ResourceListSize, ACPI_SIZE *SizeNeeded)
 
ACPI_STATUS AcpiRsGetPciRoutingTableLength (ACPI_OPERAND_OBJECT *PackageObject, ACPI_SIZE *BufferSizeNeeded)
 
ACPI_STATUS AcpiRsConvertAmlToResources (UINT8 *Aml, UINT32 Length, UINT32 Offset, UINT8 ResourceIndex, void **Context)
 
ACPI_STATUS AcpiRsConvertResourcesToAml (ACPI_RESOURCE *Resource, ACPI_SIZE AmlSizeNeeded, UINT8 *OutputBuffer)
 
void AcpiRsSetAddressCommon (AML_RESOURCE *Aml, ACPI_RESOURCE *Resource)
 
BOOLEAN AcpiRsGetAddressCommon (ACPI_RESOURCE *Resource, AML_RESOURCE *Aml)
 
ACPI_STATUS AcpiRsConvertAmlToResource (ACPI_RESOURCE *Resource, AML_RESOURCE *Aml, ACPI_RSCONVERT_INFO *Info)
 
ACPI_STATUS AcpiRsConvertResourceToAml (ACPI_RESOURCE *Resource, AML_RESOURCE *Aml, ACPI_RSCONVERT_INFO *Info)
 
void AcpiRsMoveData (void *Destination, void *Source, UINT16 ItemCount, UINT8 MoveType)
 
UINT8 AcpiRsDecodeBitmask (UINT16 Mask, UINT8 *List)
 
UINT16 AcpiRsEncodeBitmask (UINT8 *List, UINT8 Count)
 
ACPI_RS_LENGTH AcpiRsGetResourceSource (ACPI_RS_LENGTH ResourceLength, ACPI_RS_LENGTH MinimumLength, ACPI_RESOURCE_SOURCE *ResourceSource, AML_RESOURCE *Aml, char *StringPtr)
 
ACPI_RSDESC_SIZE AcpiRsSetResourceSource (AML_RESOURCE *Aml, ACPI_RS_LENGTH MinimumLength, ACPI_RESOURCE_SOURCE *ResourceSource)
 
void AcpiRsSetResourceHeader (UINT8 DescriptorType, ACPI_RSDESC_SIZE TotalLength, AML_RESOURCE *Aml)
 
void AcpiRsSetResourceLength (ACPI_RSDESC_SIZE TotalLength, AML_RESOURCE *Aml)
 

Variables

const UINT8 AcpiGbl_AmlResourceSizes []
 
const UINT8 AcpiGbl_AmlResourceSerialBusSizes []
 
ACPI_RSCONVERT_INFOAcpiGbl_SetResourceDispatch []
 
const UINT8 AcpiGbl_ResourceStructSizes []
 
const UINT8 AcpiGbl_ResourceStructSerialBusSizes []
 
ACPI_RSCONVERT_INFOAcpiGbl_GetResourceDispatch []
 
ACPI_RSCONVERT_INFOAcpiGbl_ConvertResourceSerialBusDispatch []
 
ACPI_RSCONVERT_INFO AcpiRsConvertDma []
 
ACPI_RSCONVERT_INFO AcpiRsConvertEndDpf []
 
ACPI_RSCONVERT_INFO AcpiRsConvertIo []
 
ACPI_RSCONVERT_INFO AcpiRsConvertFixedIo []
 
ACPI_RSCONVERT_INFO AcpiRsConvertEndTag []
 
ACPI_RSCONVERT_INFO AcpiRsConvertMemory24 []
 
ACPI_RSCONVERT_INFO AcpiRsConvertGenericReg []
 
ACPI_RSCONVERT_INFO AcpiRsConvertMemory32 []
 
ACPI_RSCONVERT_INFO AcpiRsConvertFixedMemory32 []
 
ACPI_RSCONVERT_INFO AcpiRsConvertAddress32 []
 
ACPI_RSCONVERT_INFO AcpiRsConvertAddress16 []
 
ACPI_RSCONVERT_INFO AcpiRsConvertExtIrq []
 
ACPI_RSCONVERT_INFO AcpiRsConvertAddress64 []
 
ACPI_RSCONVERT_INFO AcpiRsConvertExtAddress64 []
 
ACPI_RSCONVERT_INFO AcpiRsConvertGpio []
 
ACPI_RSCONVERT_INFO AcpiRsConvertFixedDma []
 
ACPI_RSCONVERT_INFO AcpiRsConvertCsi2SerialBus []
 
ACPI_RSCONVERT_INFO AcpiRsConvertI2cSerialBus []
 
ACPI_RSCONVERT_INFO AcpiRsConvertSpiSerialBus []
 
ACPI_RSCONVERT_INFO AcpiRsConvertUartSerialBus []
 
ACPI_RSCONVERT_INFO AcpiRsConvertPinFunction []
 
ACPI_RSCONVERT_INFO AcpiRsConvertPinConfig []
 
ACPI_RSCONVERT_INFO AcpiRsConvertPinGroup []
 
ACPI_RSCONVERT_INFO AcpiRsConvertPinGroupFunction []
 
ACPI_RSCONVERT_INFO AcpiRsConvertPinGroupConfig []
 
ACPI_RSCONVERT_INFO AcpiRsGetIrq []
 
ACPI_RSCONVERT_INFO AcpiRsGetStartDpf []
 
ACPI_RSCONVERT_INFO AcpiRsGetVendorSmall []
 
ACPI_RSCONVERT_INFO AcpiRsGetVendorLarge []
 
ACPI_RSCONVERT_INFO AcpiRsSetIrq []
 
ACPI_RSCONVERT_INFO AcpiRsSetStartDpf []
 
ACPI_RSCONVERT_INFO AcpiRsSetVendor []
 

Macro Definition Documentation

◆ ACPI_RS_OFFSET

#define ACPI_RS_OFFSET (   f)    (UINT8) ACPI_OFFSET (ACPI_RESOURCE,f)

Definition at line 123 of file acresrc.h.

◆ ACPI_RSC_COMPARE_AML_LENGTH

#define ACPI_RSC_COMPARE_AML_LENGTH   0

Definition at line 118 of file acresrc.h.

◆ ACPI_RSC_COMPARE_VALUE

#define ACPI_RSC_COMPARE_VALUE   1

Definition at line 119 of file acresrc.h.

◆ ACPI_RSC_TABLE_SIZE

#define ACPI_RSC_TABLE_SIZE (   d)    (sizeof (d) / sizeof (ACPI_RSCONVERT_INFO))

Definition at line 121 of file acresrc.h.

◆ AML_OFFSET

#define AML_OFFSET (   f)    (UINT8) ACPI_OFFSET (AML_RESOURCE,f)

Definition at line 124 of file acresrc.h.

Typedef Documentation

◆ ACPI_RSCONVERT_INFO

◆ ACPI_RSDUMP_INFO

◆ ACPI_VENDOR_WALK_INFO

Enumeration Type Documentation

◆ ACPI_RSCONVERT_OPCODES

Enumerator
ACPI_RSC_INITGET 
ACPI_RSC_INITSET 
ACPI_RSC_FLAGINIT 
ACPI_RSC_1BITFLAG 
ACPI_RSC_2BITFLAG 
ACPI_RSC_3BITFLAG 
ACPI_RSC_6BITFLAG 
ACPI_RSC_ADDRESS 
ACPI_RSC_BITMASK 
ACPI_RSC_BITMASK16 
ACPI_RSC_COUNT 
ACPI_RSC_COUNT16 
ACPI_RSC_COUNT_GPIO_PIN 
ACPI_RSC_COUNT_GPIO_RES 
ACPI_RSC_COUNT_GPIO_VEN 
ACPI_RSC_COUNT_SERIAL_RES 
ACPI_RSC_COUNT_SERIAL_VEN 
ACPI_RSC_DATA8 
ACPI_RSC_EXIT_EQ 
ACPI_RSC_EXIT_LE 
ACPI_RSC_EXIT_NE 
ACPI_RSC_LENGTH 
ACPI_RSC_MOVE_GPIO_PIN 
ACPI_RSC_MOVE_GPIO_RES 
ACPI_RSC_MOVE_SERIAL_RES 
ACPI_RSC_MOVE_SERIAL_VEN 
ACPI_RSC_MOVE8 
ACPI_RSC_MOVE16 
ACPI_RSC_MOVE32 
ACPI_RSC_MOVE64 
ACPI_RSC_SET8 
ACPI_RSC_SOURCE 
ACPI_RSC_SOURCEX 

Definition at line 78 of file acresrc.h.

79{
113
ACPI_RSCONVERT_OPCODES
Definition: acresrc.h:79
@ ACPI_RSC_INITSET
Definition: acresrc.h:81
@ ACPI_RSC_COUNT_GPIO_PIN
Definition: acresrc.h:92
@ ACPI_RSC_COUNT_GPIO_RES
Definition: acresrc.h:93
@ ACPI_RSC_EXIT_NE
Definition: acresrc.h:100
@ ACPI_RSC_MOVE64
Definition: acresrc.h:109
@ ACPI_RSC_2BITFLAG
Definition: acresrc.h:84
@ ACPI_RSC_FLAGINIT
Definition: acresrc.h:82
@ ACPI_RSC_EXIT_LE
Definition: acresrc.h:99
@ ACPI_RSC_3BITFLAG
Definition: acresrc.h:85
@ ACPI_RSC_MOVE_SERIAL_VEN
Definition: acresrc.h:105
@ ACPI_RSC_BITMASK16
Definition: acresrc.h:89
@ ACPI_RSC_COUNT_SERIAL_VEN
Definition: acresrc.h:96
@ ACPI_RSC_LENGTH
Definition: acresrc.h:101
@ ACPI_RSC_DATA8
Definition: acresrc.h:97
@ ACPI_RSC_MOVE_GPIO_RES
Definition: acresrc.h:103
@ ACPI_RSC_MOVE8
Definition: acresrc.h:106
@ ACPI_RSC_6BITFLAG
Definition: acresrc.h:86
@ ACPI_RSC_SOURCE
Definition: acresrc.h:111
@ ACPI_RSC_SOURCEX
Definition: acresrc.h:112
@ ACPI_RSC_COUNT_SERIAL_RES
Definition: acresrc.h:95
@ ACPI_RSC_ADDRESS
Definition: acresrc.h:87
@ ACPI_RSC_EXIT_EQ
Definition: acresrc.h:98
@ ACPI_RSC_COUNT_GPIO_VEN
Definition: acresrc.h:94
@ ACPI_RSC_COUNT16
Definition: acresrc.h:91
@ ACPI_RSC_COUNT
Definition: acresrc.h:90
@ ACPI_RSC_MOVE16
Definition: acresrc.h:107
@ ACPI_RSC_MOVE32
Definition: acresrc.h:108
@ ACPI_RSC_BITMASK
Definition: acresrc.h:88
@ ACPI_RSC_1BITFLAG
Definition: acresrc.h:83
@ ACPI_RSC_MOVE_SERIAL_RES
Definition: acresrc.h:104
@ ACPI_RSC_INITGET
Definition: acresrc.h:80
@ ACPI_RSC_SET8
Definition: acresrc.h:110
@ ACPI_RSC_MOVE_GPIO_PIN
Definition: acresrc.h:102

◆ ACPI_RSDUMP_OPCODES

Enumerator
ACPI_RSD_TITLE 
ACPI_RSD_1BITFLAG 
ACPI_RSD_2BITFLAG 
ACPI_RSD_3BITFLAG 
ACPI_RSD_6BITFLAG 
ACPI_RSD_ADDRESS 
ACPI_RSD_DWORDLIST 
ACPI_RSD_LITERAL 
ACPI_RSD_LONGLIST 
ACPI_RSD_SHORTLIST 
ACPI_RSD_SHORTLISTX 
ACPI_RSD_SOURCE 
ACPI_RSD_STRING 
ACPI_RSD_UINT8 
ACPI_RSD_UINT16 
ACPI_RSD_UINT32 
ACPI_RSD_UINT64 
ACPI_RSD_WORDLIST 
ACPI_RSD_LABEL 
ACPI_RSD_SOURCE_LABEL 

Definition at line 141 of file acresrc.h.

142{
143 ACPI_RSD_TITLE = 0,
163
ACPI_RSDUMP_OPCODES
Definition: acresrc.h:142
@ ACPI_RSD_SOURCE
Definition: acresrc.h:154
@ ACPI_RSD_LITERAL
Definition: acresrc.h:150
@ ACPI_RSD_ADDRESS
Definition: acresrc.h:148
@ ACPI_RSD_6BITFLAG
Definition: acresrc.h:147
@ ACPI_RSD_SHORTLIST
Definition: acresrc.h:152
@ ACPI_RSD_LABEL
Definition: acresrc.h:161
@ ACPI_RSD_LONGLIST
Definition: acresrc.h:151
@ ACPI_RSD_SHORTLISTX
Definition: acresrc.h:153
@ ACPI_RSD_1BITFLAG
Definition: acresrc.h:144
@ ACPI_RSD_UINT16
Definition: acresrc.h:157
@ ACPI_RSD_UINT8
Definition: acresrc.h:156
@ ACPI_RSD_3BITFLAG
Definition: acresrc.h:146
@ ACPI_RSD_UINT32
Definition: acresrc.h:158
@ ACPI_RSD_WORDLIST
Definition: acresrc.h:160
@ ACPI_RSD_DWORDLIST
Definition: acresrc.h:149
@ ACPI_RSD_UINT64
Definition: acresrc.h:159
@ ACPI_RSD_2BITFLAG
Definition: acresrc.h:145
@ ACPI_RSD_TITLE
Definition: acresrc.h:143
@ ACPI_RSD_STRING
Definition: acresrc.h:155
@ ACPI_RSD_SOURCE_LABEL
Definition: acresrc.h:162

Function Documentation

◆ AcpiRsConvertAmlToResource()

ACPI_STATUS AcpiRsConvertAmlToResource ( ACPI_RESOURCE Resource,
AML_RESOURCE Aml,
ACPI_RSCONVERT_INFO Info 
)

Definition at line 77 of file rsmisc.c.

81{
82 ACPI_RS_LENGTH AmlResourceLength;
83 void *Source;
84 void *Destination;
85 char *Target;
87 UINT8 FlagsMode = FALSE;
88 UINT16 ItemCount = 0;
89 UINT16 Temp16 = 0;
90
91
92 ACPI_FUNCTION_TRACE (RsConvertAmlToResource);
93
94
95 if (!Info)
96 {
98 }
99
100 if (((ACPI_SIZE) Resource) & 0x3)
101 {
102 /* Each internal resource struct is expected to be 32-bit aligned */
103
105 "Misaligned resource pointer (get): %p Type 0x%2.2X Length %u",
106 Resource, Resource->Type, Resource->Length));
107 }
108
109 /* Extract the resource Length field (does not include header length) */
110
111 AmlResourceLength = AcpiUtGetResourceLength (Aml);
112
113 /*
114 * First table entry must be ACPI_RSC_INITxxx and must contain the
115 * table length (# of table entries)
116 */
118 while (Count)
119 {
120 Target = NULL;
121
122 /*
123 * Source is the external AML byte stream buffer,
124 * destination is the internal resource descriptor
125 */
126 Source = ACPI_ADD_PTR (void, Aml, Info->AmlOffset);
127 Destination = ACPI_ADD_PTR (void, Resource, Info->ResourceOffset);
128
129 switch (Info->Opcode)
130 {
131 case ACPI_RSC_INITGET:
132 /*
133 * Get the resource type and the initial (minimum) length
134 */
138 break;
139
140 case ACPI_RSC_INITSET:
141 break;
142
144
145 FlagsMode = TRUE;
146 break;
147
149 /*
150 * Mask and shift the flag bit
151 */
153 ((ACPI_GET8 (Source) >> Info->Value) & 0x01));
154 break;
155
157 /*
158 * Mask and shift the flag bits
159 */
161 ((ACPI_GET8 (Source) >> Info->Value) & 0x03));
162 break;
163
165 /*
166 * Mask and shift the flag bits
167 */
169 ((ACPI_GET8 (Source) >> Info->Value) & 0x07));
170 break;
171
173 /*
174 * Mask and shift the flag bits
175 */
177 ((ACPI_GET8 (Source) >> Info->Value) & 0x3F));
178 break;
179
180 case ACPI_RSC_COUNT:
181
182 ItemCount = ACPI_GET8 (Source);
183 ACPI_SET8 (Destination, ItemCount);
184
185 Resource->Length = Resource->Length +
186 (Info->Value * (ItemCount - 1));
187 break;
188
189 case ACPI_RSC_COUNT16:
190
191 ItemCount = AmlResourceLength;
192 ACPI_SET16 (Destination, ItemCount);
193
194 Resource->Length = Resource->Length +
195 (Info->Value * (ItemCount - 1));
196 break;
197
199
200 Target = ACPI_ADD_PTR (void, Aml, Info->Value);
201 ItemCount = ACPI_GET16 (Target) - ACPI_GET16 (Source);
202
203 Resource->Length = Resource->Length + ItemCount;
204 ItemCount = ItemCount / 2;
205 ACPI_SET16 (Destination, ItemCount);
206 break;
207
209
210 ItemCount = ACPI_GET8 (Source);
211 ACPI_SET8 (Destination, ItemCount);
212
213 Resource->Length = Resource->Length + (Info->Value * ItemCount);
214 break;
215
217 /*
218 * Vendor data is optional (length/offset may both be zero)
219 * Examine vendor data length field first
220 */
221 Target = ACPI_ADD_PTR (void, Aml, (Info->Value + 2));
222 if (ACPI_GET16 (Target))
223 {
224 /* Use vendor offset to get resource source length */
225
226 Target = ACPI_ADD_PTR (void, Aml, Info->Value);
227 ItemCount = ACPI_GET16 (Target) - ACPI_GET16 (Source);
228 }
229 else
230 {
231 /* No vendor data to worry about */
232
233 ItemCount = Aml->LargeHeader.ResourceLength +
236 }
237
238 Resource->Length = Resource->Length + ItemCount;
239 ACPI_SET16 (Destination, ItemCount);
240 break;
241
243
244 ItemCount = ACPI_GET16 (Source) - Info->Value;
245
246 Resource->Length = Resource->Length + ItemCount;
247 ACPI_SET16 (Destination, ItemCount);
248 break;
249
251
252 ItemCount = (AmlResourceLength +
253 sizeof (AML_RESOURCE_LARGE_HEADER)) -
254 ACPI_GET16 (Source) - Info->Value;
255
256 Resource->Length = Resource->Length + ItemCount;
257 ACPI_SET16 (Destination, ItemCount);
258 break;
259
260 case ACPI_RSC_LENGTH:
261
262 Resource->Length = Resource->Length + Info->Value;
263 break;
264
265 case ACPI_RSC_MOVE8:
266 case ACPI_RSC_MOVE16:
267 case ACPI_RSC_MOVE32:
268 case ACPI_RSC_MOVE64:
269 /*
270 * Raw data move. Use the Info value field unless ItemCount has
271 * been previously initialized via a COUNT opcode
272 */
273 if (Info->Value)
274 {
275 ItemCount = Info->Value;
276 }
277 AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode);
278 break;
279
281
282 /* Generate and set the PIN data pointer */
283
284 Target = (char *) ACPI_ADD_PTR (void, Resource,
285 (Resource->Length - ItemCount * 2));
287
288 /* Copy the PIN data */
289
291 AcpiRsMoveData (Target, Source, ItemCount, Info->Opcode);
292 break;
293
295
296 /* Generate and set the ResourceSource string pointer */
297
298 Target = (char *) ACPI_ADD_PTR (void, Resource,
299 (Resource->Length - ItemCount));
301
302 /* Copy the ResourceSource string */
303
305 AcpiRsMoveData (Target, Source, ItemCount, Info->Opcode);
306 break;
307
309
310 /* Generate and set the Vendor Data pointer */
311
312 Target = (char *) ACPI_ADD_PTR (void, Resource,
313 (Resource->Length - ItemCount));
315
316 /* Copy the Vendor Data */
317
318 Source = ACPI_ADD_PTR (void, Aml, Info->Value);
319 AcpiRsMoveData (Target, Source, ItemCount, Info->Opcode);
320 break;
321
323
324 /* Generate and set the ResourceSource string pointer */
325
326 Target = (char *) ACPI_ADD_PTR (void, Resource,
327 (Resource->Length - ItemCount));
329
330 /* Copy the ResourceSource string */
331
333 void, Aml, (ACPI_GET16 (Source) + Info->Value));
334 AcpiRsMoveData (Target, Source, ItemCount, Info->Opcode);
335 break;
336
337 case ACPI_RSC_SET8:
338
339 memset (Destination, Info->AmlOffset, Info->Value);
340 break;
341
342 case ACPI_RSC_DATA8:
343
344 Target = ACPI_ADD_PTR (char, Resource, Info->Value);
346 break;
347
348 case ACPI_RSC_ADDRESS:
349 /*
350 * Common handler for address descriptor flags
351 */
353 {
355 }
356 break;
357
358 case ACPI_RSC_SOURCE:
359 /*
360 * Optional ResourceSource (Index and String)
361 */
362 Resource->Length +=
363 AcpiRsGetResourceSource (AmlResourceLength, Info->Value,
365 break;
366
367 case ACPI_RSC_SOURCEX:
368 /*
369 * Optional ResourceSource (Index and String). This is the more
370 * complicated case used by the Interrupt() macro
371 */
373 Info->AmlOffset + (ItemCount * 4));
374
375 Resource->Length +=
376 AcpiRsGetResourceSource (AmlResourceLength, (ACPI_RS_LENGTH)
377 (((ItemCount - 1) * sizeof (UINT32)) + Info->Value),
379 break;
380
381 case ACPI_RSC_BITMASK:
382 /*
383 * 8-bit encoded bitmask (DMA macro)
384 */
386 if (ItemCount)
387 {
388 Resource->Length += (ItemCount - 1);
389 }
390
391 Target = ACPI_ADD_PTR (char, Resource, Info->Value);
392 ACPI_SET8 (Target, ItemCount);
393 break;
394
396 /*
397 * 16-bit encoded bitmask (IRQ macro)
398 */
399 ACPI_MOVE_16_TO_16 (&Temp16, Source);
400
401 ItemCount = AcpiRsDecodeBitmask (Temp16, Destination);
402 if (ItemCount)
403 {
404 Resource->Length += (ItemCount - 1);
405 }
406
407 Target = ACPI_ADD_PTR (char, Resource, Info->Value);
408 ACPI_SET8 (Target, ItemCount);
409 break;
410
411 case ACPI_RSC_EXIT_NE:
412 /*
413 * Control - Exit conversion if not equal
414 */
415 switch (Info->ResourceOffset)
416 {
418
419 if (AmlResourceLength != Info->Value)
420 {
421 goto Exit;
422 }
423 break;
424
426
427 if (ACPI_GET8 (Source) != Info->Value)
428 {
429 goto Exit;
430 }
431 break;
432
433 default:
434
435 ACPI_ERROR ((AE_INFO, "Invalid conversion sub-opcode"));
437 }
438 break;
439
440 default:
441
442 ACPI_ERROR ((AE_INFO, "Invalid conversion opcode"));
444 }
445
446 Count--;
447 Info++;
448 }
449
450Exit:
451 if (!FlagsMode)
452 {
453 /* Round the resource struct length up to the next boundary (32 or 64) */
454
455 Resource->Length = (UINT32)
457 }
459}
unsigned short UINT16
unsigned char UINT8
unsigned int UINT32
#define AE_AML_INVALID_RESOURCE_TYPE
Definition: acexcep.h:202
#define AE_BAD_PARAMETER
Definition: acexcep.h:151
#define AE_OK
Definition: acexcep.h:97
#define ACPI_GET16(ptr)
Definition: acmacros.h:58
#define ACPI_SET8(ptr, val)
Definition: acmacros.h:61
#define ACPI_GET8(ptr)
Definition: acmacros.h:57
#define ACPI_MOVE_16_TO_16(d, s)
Definition: acmacros.h:141
#define ACPI_ROUND_UP_TO_NATIVE_WORD(a)
Definition: acmacros.h:254
#define ACPI_SET16(ptr, val)
Definition: acmacros.h:62
#define ACPI_WARNING(plist)
Definition: acoutput.h:238
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
#define ACPI_ERROR(plist)
Definition: acoutput.h:240
#define AE_INFO
Definition: acoutput.h:230
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
#define ACPI_RSC_COMPARE_AML_LENGTH
Definition: acresrc.h:118
#define ACPI_RSC_COMPARE_VALUE
Definition: acresrc.h:119
UINT8 AcpiRsDecodeBitmask(UINT16 Mask, UINT8 *List)
Definition: rsutils.c:68
BOOLEAN AcpiRsGetAddressCommon(ACPI_RESOURCE *Resource, AML_RESOURCE *Aml)
Definition: rsaddr.c:322
ACPI_RS_LENGTH AcpiRsGetResourceSource(ACPI_RS_LENGTH ResourceLength, ACPI_RS_LENGTH MinimumLength, ACPI_RESOURCE_SOURCE *ResourceSource, AML_RESOURCE *Aml, char *StringPtr)
Definition: rsutils.c:366
void AcpiRsMoveData(void *Destination, void *Source, UINT16 ItemCount, UINT8 MoveType)
Definition: rsutils.c:150
UINT16 ACPI_RS_LENGTH
Definition: acrestyp.h:51
#define ACPI_ADD_PTR(t, a, b)
Definition: actypes.h:546
#define ACPI_CAST_PTR(t, p)
Definition: actypes.h:544
UINT16 AcpiUtGetResourceLength(void *Aml)
Definition: utresrc.c:527
struct aml_resource_large_header AML_RESOURCE_LARGE_HEADER
_Acquires_exclusive_lock_ Resource _Acquires_shared_lock_ Resource _Inout_ PERESOURCE Resource
Definition: cdprocs.h:843
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3169
_In_ PUNICODE_STRING _Inout_ PUNICODE_STRING Destination
Definition: rtlfuncs.h:3016
int Count
Definition: noreturn.cpp:7
#define INIT_RESOURCE_LENGTH(i)
Definition: rsmisc.c:53
#define INIT_TABLE_LENGTH(i)
Definition: rsmisc.c:54
#define INIT_RESOURCE_TYPE(i)
Definition: rsmisc.c:52
#define memset(x, y, z)
Definition: compat.h:39
static void Exit(void)
Definition: sock.c:1330
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:690
_In_ WDFIOTARGET Target
Definition: wdfrequest.h:306

Referenced by AcpiRsConvertAmlToResources(), and AcpiRsGetAddressCommon().

◆ AcpiRsConvertAmlToResources()

ACPI_STATUS AcpiRsConvertAmlToResources ( UINT8 Aml,
UINT32  Length,
UINT32  Offset,
UINT8  ResourceIndex,
void **  Context 
)

Definition at line 68 of file rslist.c.

74{
78 AML_RESOURCE *AmlResource;
79 ACPI_RSCONVERT_INFO *ConversionTable;
81
82
83 ACPI_FUNCTION_TRACE (RsConvertAmlToResources);
84
85
86 /*
87 * Check that the input buffer and all subsequent pointers into it
88 * are aligned on a native word boundary. Most important on IA64
89 */
90 Resource = *ResourcePtr;
92 {
94 "Misaligned resource pointer %p", Resource));
95 }
96
97 /* Get the appropriate conversion info table */
98
99 AmlResource = ACPI_CAST_PTR (AML_RESOURCE, Aml);
100
103 {
104 if (AmlResource->CommonSerialBus.Type >
106 {
107 ConversionTable = NULL;
108 }
109 else
110 {
111 /* This is an I2C, SPI, UART, or CSI2 SerialBus descriptor */
112
114 AmlResource->CommonSerialBus.Type];
115 }
116 }
117 else
118 {
119 ConversionTable = AcpiGbl_GetResourceDispatch[ResourceIndex];
120 }
121
122 if (!ConversionTable)
123 {
125 "Invalid/unsupported resource descriptor: Type 0x%2.2X",
126 ResourceIndex));
128 }
129
130 /* Convert the AML byte stream resource to a local resource struct */
131
133 Resource, AmlResource, ConversionTable);
134 if (ACPI_FAILURE (Status))
135 {
137 "Could not convert AML resource (Type 0x%X)", *Aml));
139 }
140
141 if (!Resource->Length)
142 {
144 "Zero-length resource returned from RsConvertAmlToResource"));
145 }
146
148 "Type %.2X, AmlLength %.2X InternalLength %.2X\n",
150 Resource->Length));
151
152 /* Point to the next structure in the output buffer */
153
154 *ResourcePtr = ACPI_NEXT_RESOURCE (Resource);
156}
#define ACPI_FAILURE(a)
Definition: acexcep.h:95
#define ACPI_RESOURCE_NAME_SERIAL_BUS
Definition: aclocal.h:1342
#define ACPI_IS_MISALIGNED(value)
Definition: acmacros.h:265
#define ACPI_DEBUG_PRINT(pl)
Definition: acoutput.h:475
#define ACPI_EXCEPTION(plist)
Definition: acoutput.h:239
#define ACPI_DB_RESOURCES
Definition: acoutput.h:176
ACPI_RSCONVERT_INFO * AcpiGbl_ConvertResourceSerialBusDispatch[]
Definition: rsinfo.c:142
ACPI_RSCONVERT_INFO * AcpiGbl_GetResourceDispatch[]
Definition: rsinfo.c:96
ACPI_STATUS AcpiRsConvertAmlToResource(ACPI_RESOURCE *Resource, AML_RESOURCE *Aml, ACPI_RSCONVERT_INFO *Info)
Definition: rsmisc.c:77
#define ACPI_NEXT_RESOURCE(Res)
Definition: acrestyp.h:812
#define ACPI_CAST_INDIRECT_PTR(t, p)
Definition: actypes.h:545
UINT32 ACPI_STATUS
Definition: actypes.h:460
UINT8 AcpiUtGetResourceType(void *Aml)
Definition: utresrc.c:487
#define AML_RESOURCE_MAX_SERIALBUSTYPE
Definition: amlresrc.h:466
Status
Definition: gdiplustypes.h:25
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
AML_RESOURCE_COMMON_SERIALBUS CommonSerialBus
Definition: amlresrc.h:708

Referenced by AcpiBufferToResource(), and AcpiRsCreateResourceList().

◆ AcpiRsConvertResourcesToAml()

ACPI_STATUS AcpiRsConvertResourcesToAml ( ACPI_RESOURCE Resource,
ACPI_SIZE  AmlSizeNeeded,
UINT8 OutputBuffer 
)

Definition at line 179 of file rslist.c.

183{
185 UINT8 *EndAml = OutputBuffer + AmlSizeNeeded;
186 ACPI_RSCONVERT_INFO *ConversionTable;
188
189
190 ACPI_FUNCTION_TRACE (RsConvertResourcesToAml);
191
192
193 /* Walk the resource descriptor list, convert each descriptor */
194
195 while (Aml < EndAml)
196 {
197 /* Validate the (internal) Resource Type */
198
200 {
202 "Invalid descriptor type (0x%X) in resource list",
203 Resource->Type));
205 }
206
207 /* Sanity check the length. It must not be zero, or we loop forever */
208
209 if (!Resource->Length)
210 {
212 "Invalid zero length descriptor in resource list\n"));
214 }
215
216 /* Perform the conversion */
217
219 {
220 if (Resource->Data.CommonSerialBus.Type >
222 {
223 ConversionTable = NULL;
224 }
225 else
226 {
227 /* This is an I2C, SPI, UART or CSI2 SerialBus descriptor */
228
230 Resource->Data.CommonSerialBus.Type];
231 }
232 }
233 else
234 {
235 ConversionTable = AcpiGbl_SetResourceDispatch[Resource->Type];
236 }
237
238 if (!ConversionTable)
239 {
241 "Invalid/unsupported resource descriptor: Type 0x%2.2X",
242 Resource->Type));
244 }
245
247 ACPI_CAST_PTR (AML_RESOURCE, Aml), ConversionTable);
248 if (ACPI_FAILURE (Status))
249 {
251 "Could not convert resource (type 0x%X) to AML",
252 Resource->Type));
254 }
255
256 /* Perform final sanity check on the new AML resource descriptor */
257
260 if (ACPI_FAILURE (Status))
261 {
263 }
264
265 /* Check for end-of-list, normal exit */
266
268 {
269 /* An End Tag indicates the end of the input Resource Template */
270
272 }
273
274 /*
275 * Extract the total length of the new descriptor and set the
276 * Aml to point to the next (output) resource descriptor
277 */
279
280 /* Point to the next input resource descriptor */
281
283 }
284
285 /* Completed buffer, but did not find an EndTag resource descriptor */
286
288}
#define AE_BAD_DATA
Definition: acexcep.h:154
#define AE_AML_BAD_RESOURCE_LENGTH
Definition: acexcep.h:210
#define AE_AML_NO_RESOURCE_END_TAG
Definition: acexcep.h:207
ACPI_STATUS AcpiRsConvertResourceToAml(ACPI_RESOURCE *Resource, AML_RESOURCE *Aml, ACPI_RSCONVERT_INFO *Info)
Definition: rsmisc.c:478
ACPI_RSCONVERT_INFO * AcpiGbl_SetResourceDispatch[]
Definition: rsinfo.c:65
#define ACPI_RESOURCE_TYPE_SERIAL_BUS
Definition: acrestyp.h:742
#define ACPI_RESOURCE_TYPE_END_TAG
Definition: acrestyp.h:730
#define ACPI_RESOURCE_TYPE_MAX
Definition: acrestyp.h:748
UINT32 AcpiUtGetDescriptorLength(void *Aml)
Definition: utresrc.c:606
ACPI_STATUS AcpiUtValidateResource(ACPI_WALK_STATE *WalkState, void *Aml, UINT8 *ReturnIndex)
Definition: utresrc.c:314
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR OutputBuffer
Definition: wdfiotarget.h:863

Referenced by AcpiRsCreateAmlResources().

◆ AcpiRsConvertResourceToAml()

ACPI_STATUS AcpiRsConvertResourceToAml ( ACPI_RESOURCE Resource,
AML_RESOURCE Aml,
ACPI_RSCONVERT_INFO Info 
)

Definition at line 478 of file rsmisc.c.

482{
483 void *Source = NULL;
484 void *Destination;
485 char *Target;
486 ACPI_RSDESC_SIZE AmlLength = 0;
487 UINT8 Count;
488 UINT16 Temp16 = 0;
489 UINT16 ItemCount = 0;
490
491
492 ACPI_FUNCTION_TRACE (RsConvertResourceToAml);
493
494
495 if (!Info)
496 {
498 }
499
500 /*
501 * First table entry must be ACPI_RSC_INITxxx and must contain the
502 * table length (# of table entries)
503 */
505
506 while (Count)
507 {
508 /*
509 * Source is the internal resource descriptor,
510 * destination is the external AML byte stream buffer
511 */
512 Source = ACPI_ADD_PTR (void, Resource, Info->ResourceOffset);
513 Destination = ACPI_ADD_PTR (void, Aml, Info->AmlOffset);
514
515 switch (Info->Opcode)
516 {
517 case ACPI_RSC_INITSET:
518
520 AmlLength = INIT_RESOURCE_LENGTH (Info);
522 INIT_RESOURCE_TYPE (Info), AmlLength, Aml);
523 break;
524
525 case ACPI_RSC_INITGET:
526 break;
527
529 /*
530 * Clear the flag byte
531 */
533 break;
534
536 /*
537 * Mask and shift the flag bit
538 */
540 ((ACPI_GET8 (Source) & 0x01) << Info->Value));
541 break;
542
544 /*
545 * Mask and shift the flag bits
546 */
548 ((ACPI_GET8 (Source) & 0x03) << Info->Value));
549 break;
550
552 /*
553 * Mask and shift the flag bits
554 */
556 ((ACPI_GET8 (Source) & 0x07) << Info->Value));
557 break;
558
560 /*
561 * Mask and shift the flag bits
562 */
564 ((ACPI_GET8 (Source) & 0x3F) << Info->Value));
565 break;
566
567 case ACPI_RSC_COUNT:
568
569 ItemCount = ACPI_GET8 (Source);
570 ACPI_SET8 (Destination, ItemCount);
571
572 AmlLength = (UINT16)
573 (AmlLength + (Info->Value * (ItemCount - 1)));
574 break;
575
576 case ACPI_RSC_COUNT16:
577
578 ItemCount = ACPI_GET16 (Source);
579 AmlLength = (UINT16) (AmlLength + ItemCount);
580 AcpiRsSetResourceLength (AmlLength, Aml);
581 break;
582
584
585 ItemCount = ACPI_GET16 (Source);
586 ACPI_SET16 (Destination, AmlLength);
587
588 AmlLength = (UINT16) (AmlLength + ItemCount * 2);
589 Target = ACPI_ADD_PTR (void, Aml, Info->Value);
590 ACPI_SET16 (Target, AmlLength);
591 AcpiRsSetResourceLength (AmlLength, Aml);
592 break;
593
595
596 ItemCount = ACPI_GET16 (Source);
597 ACPI_SET16 (Destination, ItemCount);
598
599 AmlLength = (UINT16) (
600 AmlLength + (Info->Value * ItemCount));
601 AcpiRsSetResourceLength (AmlLength, Aml);
602 break;
603
605
606 /* Set resource source string length */
607
608 ItemCount = ACPI_GET16 (Source);
609 ACPI_SET16 (Destination, AmlLength);
610
611 /* Compute offset for the Vendor Data */
612
613 AmlLength = (UINT16) (AmlLength + ItemCount);
614 Target = ACPI_ADD_PTR (void, Aml, Info->Value);
615
616 /* Set vendor offset only if there is vendor data */
617
618 ACPI_SET16 (Target, AmlLength);
619
620 AcpiRsSetResourceLength (AmlLength, Aml);
621 break;
622
624
625 ItemCount = ACPI_GET16 (Source);
626 ACPI_SET16 (Destination, ItemCount + Info->Value);
627 AmlLength = (UINT16) (AmlLength + ItemCount);
628 AcpiRsSetResourceLength (AmlLength, Aml);
629 break;
630
632
633 ItemCount = ACPI_GET16 (Source);
634 AmlLength = (UINT16) (AmlLength + ItemCount);
635 AcpiRsSetResourceLength (AmlLength, Aml);
636 break;
637
638 case ACPI_RSC_LENGTH:
639
641 break;
642
643 case ACPI_RSC_MOVE8:
644 case ACPI_RSC_MOVE16:
645 case ACPI_RSC_MOVE32:
646 case ACPI_RSC_MOVE64:
647
648 if (Info->Value)
649 {
650 ItemCount = Info->Value;
651 }
652 AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode);
653 break;
654
656
657 Destination = (char *) ACPI_ADD_PTR (void, Aml,
659 Source = * (UINT16 **) Source;
660 AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode);
661 break;
662
664
665 /* Used for both ResourceSource string and VendorData */
666
667 Destination = (char *) ACPI_ADD_PTR (void, Aml,
669 Source = * (UINT8 **) Source;
670 AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode);
671 break;
672
674
675 Destination = (char *) ACPI_ADD_PTR (void, Aml,
676 (AmlLength - ItemCount));
677 Source = * (UINT8 **) Source;
678 AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode);
679 break;
680
682
683 Destination = (char *) ACPI_ADD_PTR (void, Aml,
684 (AmlLength - ItemCount));
685 Source = * (UINT8 **) Source;
686 AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode);
687 break;
688
689 case ACPI_RSC_ADDRESS:
690
691 /* Set the Resource Type, General Flags, and Type-Specific Flags */
692
694 break;
695
696 case ACPI_RSC_SOURCEX:
697 /*
698 * Optional ResourceSource (Index and String)
699 */
700 AmlLength = AcpiRsSetResourceSource (
701 Aml, (ACPI_RS_LENGTH) AmlLength, Source);
702 AcpiRsSetResourceLength (AmlLength, Aml);
703 break;
704
705 case ACPI_RSC_SOURCE:
706 /*
707 * Optional ResourceSource (Index and String). This is the more
708 * complicated case used by the Interrupt() macro
709 */
710 AmlLength = AcpiRsSetResourceSource (Aml, Info->Value, Source);
711 AcpiRsSetResourceLength (AmlLength, Aml);
712 break;
713
714 case ACPI_RSC_BITMASK:
715 /*
716 * 8-bit encoded bitmask (DMA macro)
717 */
720 *ACPI_ADD_PTR (UINT8, Resource, Info->Value)));
721 break;
722
724 /*
725 * 16-bit encoded bitmask (IRQ macro)
726 */
727 Temp16 = AcpiRsEncodeBitmask (
728 Source, *ACPI_ADD_PTR (UINT8, Resource, Info->Value));
730 break;
731
732 case ACPI_RSC_EXIT_LE:
733 /*
734 * Control - Exit conversion if less than or equal
735 */
736 if (ItemCount <= Info->Value)
737 {
738 goto Exit;
739 }
740 break;
741
742 case ACPI_RSC_EXIT_NE:
743 /*
744 * Control - Exit conversion if not equal
745 */
746 switch (COMPARE_OPCODE (Info))
747 {
749
752 {
753 goto Exit;
754 }
755 break;
756
757 default:
758
759 ACPI_ERROR ((AE_INFO, "Invalid conversion sub-opcode"));
761 }
762 break;
763
764 case ACPI_RSC_EXIT_EQ:
765 /*
766 * Control - Exit conversion if equal
767 */
770 {
771 goto Exit;
772 }
773 break;
774
775 default:
776
777 ACPI_ERROR ((AE_INFO, "Invalid conversion opcode"));
779 }
780
781 Count--;
782 Info++;
783 }
784
785Exit:
787}
#define ACPI_CAST8(ptr)
Definition: acmacros.h:53
void AcpiRsSetResourceLength(ACPI_RSDESC_SIZE TotalLength, AML_RESOURCE *Aml)
Definition: rsutils.c:233
ACPI_RSDESC_SIZE AcpiRsSetResourceSource(AML_RESOURCE *Aml, ACPI_RS_LENGTH MinimumLength, ACPI_RESOURCE_SOURCE *ResourceSource)
Definition: rsutils.c:457
void AcpiRsSetResourceHeader(UINT8 DescriptorType, ACPI_RSDESC_SIZE TotalLength, AML_RESOURCE *Aml)
Definition: rsutils.c:289
UINT16 AcpiRsEncodeBitmask(UINT8 *List, UINT8 Count)
Definition: rsutils.c:110
void AcpiRsSetAddressCommon(AML_RESOURCE *Aml, ACPI_RESOURCE *Resource)
Definition: rsaddr.c:381
UINT32 ACPI_RSDESC_SIZE
Definition: acrestyp.h:52
#define ACPI_SET_BIT(target, bit)
Definition: actypes.h:533
#define COMPARE_TARGET(i)
Definition: rsmisc.c:57
#define COMPARE_OPCODE(i)
Definition: rsmisc.c:56
#define COMPARE_VALUE(i)
Definition: rsmisc.c:58
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413

Referenced by AcpiRsConvertResourcesToAml(), and AcpiRsSetAddressCommon().

◆ AcpiRsCreateAmlResources()

ACPI_STATUS AcpiRsCreateAmlResources ( ACPI_BUFFER ResourceList,
ACPI_BUFFER OutputBuffer 
)

Definition at line 462 of file rscreate.c.

465{
467 ACPI_SIZE AmlSizeNeeded = 0;
468
469
470 ACPI_FUNCTION_TRACE (RsCreateAmlResources);
471
472
473 /* Params already validated, no need to re-validate here */
474
475 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "ResourceList Buffer = %p\n",
476 ResourceList->Pointer));
477
478 /* Get the buffer size needed for the AML byte stream */
479
481 ResourceList->Pointer, ResourceList->Length, &AmlSizeNeeded);
482
483 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "AmlSizeNeeded=%X, %s\n",
484 (UINT32) AmlSizeNeeded, AcpiFormatException (Status)));
485 if (ACPI_FAILURE (Status))
486 {
488 }
489
490 /* Validate/Allocate/Clear caller buffer */
491
492 Status = AcpiUtInitializeBuffer (OutputBuffer, AmlSizeNeeded);
493 if (ACPI_FAILURE (Status))
494 {
496 }
497
498 /* Do the conversion */
499
501 AmlSizeNeeded, OutputBuffer->Pointer);
502 if (ACPI_FAILURE (Status))
503 {
505 }
506
507 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer %p Length %X\n",
508 OutputBuffer->Pointer, (UINT32) OutputBuffer->Length));
510}
#define ACPI_DB_INFO
Definition: acoutput.h:153
ACPI_STATUS AcpiRsConvertResourcesToAml(ACPI_RESOURCE *Resource, ACPI_SIZE AmlSizeNeeded, UINT8 *OutputBuffer)
Definition: rslist.c:179
ACPI_STATUS AcpiRsGetAmlLength(ACPI_RESOURCE *ResourceList, ACPI_SIZE ResourceListSize, ACPI_SIZE *SizeNeeded)
Definition: rscalc.c:211
ACPI_STATUS AcpiUtInitializeBuffer(ACPI_BUFFER *Buffer, ACPI_SIZE RequiredLength)
Definition: utalloc.c:336
const char * AcpiFormatException(ACPI_STATUS Status)
Definition: utexcep.c:70
_Must_inspect_result_ _In_ WDFIORESREQLIST _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFIORESLIST * ResourceList
Definition: wdfresource.h:309

Referenced by AcpiRsSetSrsMethodData().

◆ AcpiRsCreatePciRoutingTable()

ACPI_STATUS AcpiRsCreatePciRoutingTable ( ACPI_OPERAND_OBJECT PackageObject,
ACPI_BUFFER OutputBuffer 
)

Definition at line 234 of file rscreate.c.

237{
238 UINT8 *Buffer;
239 ACPI_OPERAND_OBJECT **TopObjectList;
240 ACPI_OPERAND_OBJECT **SubObjectList;
241 ACPI_OPERAND_OBJECT *ObjDesc;
242 ACPI_SIZE BufferSizeNeeded = 0;
243 UINT32 NumberOfElements;
245 ACPI_PCI_ROUTING_TABLE *UserPrt;
248 ACPI_BUFFER PathBuffer;
249
250
251 ACPI_FUNCTION_TRACE (RsCreatePciRoutingTable);
252
253
254 /* Params already validated, so we don't re-validate here */
255
256 /* Get the required buffer length */
257
259 PackageObject,&BufferSizeNeeded);
260 if (ACPI_FAILURE (Status))
261 {
263 }
264
265 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "BufferSizeNeeded = %X\n",
267
268 /* Validate/Allocate/Clear caller buffer */
269
271 if (ACPI_FAILURE (Status))
272 {
274 }
275
276 /*
277 * Loop through the ACPI_INTERNAL_OBJECTS - Each object should be a
278 * package that in turn contains an UINT64 Address, a UINT8 Pin,
279 * a Name, and a UINT8 SourceIndex.
280 */
281 TopObjectList = PackageObject->Package.Elements;
282 NumberOfElements = PackageObject->Package.Count;
283 Buffer = OutputBuffer->Pointer;
285
286 for (Index = 0; Index < NumberOfElements; Index++)
287 {
288 /*
289 * Point UserPrt past this current structure
290 *
291 * NOTE: On the first iteration, UserPrt->Length will
292 * be zero because we cleared the return buffer earlier
293 */
294 Buffer += UserPrt->Length;
296
297 /*
298 * Fill in the Length field with the information we have at this
299 * point. The minus four is to subtract the size of the UINT8
300 * Source[4] member because it is added below.
301 */
302 UserPrt->Length = (sizeof (ACPI_PCI_ROUTING_TABLE) - 4);
303
304 /* Each subpackage must be of length 4 */
305
306 if ((*TopObjectList)->Package.Count != 4)
307 {
309 "(PRT[%u]) Need package of length 4, found length %u",
310 Index, (*TopObjectList)->Package.Count));
312 }
313
314 /*
315 * Dereference the subpackage.
316 * The SubObjectList will now point to an array of the four IRQ
317 * elements: [Address, Pin, Source, SourceIndex]
318 */
319 SubObjectList = (*TopObjectList)->Package.Elements;
320
321 /* 1) First subobject: Dereference the PRT.Address */
322
323 ObjDesc = SubObjectList[0];
324 if (!ObjDesc || ObjDesc->Common.Type != ACPI_TYPE_INTEGER)
325 {
327 "(PRT[%u].Address) Need Integer, found %s",
328 Index, AcpiUtGetObjectTypeName (ObjDesc)));
330 }
331
332 UserPrt->Address = ObjDesc->Integer.Value;
333
334 /* 2) Second subobject: Dereference the PRT.Pin */
335
336 ObjDesc = SubObjectList[1];
337 if (!ObjDesc || ObjDesc->Common.Type != ACPI_TYPE_INTEGER)
338 {
339 ACPI_ERROR ((AE_INFO, "(PRT[%u].Pin) Need Integer, found %s",
340 Index, AcpiUtGetObjectTypeName (ObjDesc)));
342 }
343
344 UserPrt->Pin = (UINT32) ObjDesc->Integer.Value;
345
346 /*
347 * 3) Third subobject: Dereference the PRT.SourceName
348 * The name may be unresolved (slack mode), so allow a null object
349 */
350 ObjDesc = SubObjectList[2];
351 if (ObjDesc)
352 {
353 switch (ObjDesc->Common.Type)
354 {
356
357 if (ObjDesc->Reference.Class != ACPI_REFCLASS_NAME)
358 {
360 "(PRT[%u].Source) Need name, found Reference Class 0x%X",
361 Index, ObjDesc->Reference.Class));
363 }
364
365 Node = ObjDesc->Reference.Node;
366
367 /* Use *remaining* length of the buffer as max for pathname */
368
369 PathBuffer.Length = OutputBuffer->Length -
370 (UINT32) ((UINT8 *) UserPrt->Source -
371 (UINT8 *) OutputBuffer->Pointer);
372 PathBuffer.Pointer = UserPrt->Source;
373
375 (ACPI_HANDLE) Node, &PathBuffer, FALSE);
376 if (ACPI_FAILURE (Status))
377 {
379 }
380
381 /* +1 to include null terminator */
382
383 UserPrt->Length += (UINT32) strlen (UserPrt->Source) + 1;
384 break;
385
386 case ACPI_TYPE_STRING:
387
388 strcpy (UserPrt->Source, ObjDesc->String.Pointer);
389
390 /*
391 * Add to the Length field the length of the string
392 * (add 1 for terminator)
393 */
394 UserPrt->Length += ObjDesc->String.Length + 1;
395 break;
396
398 /*
399 * If this is a number, then the Source Name is NULL, since
400 * the entire buffer was zeroed out, we can leave this alone.
401 *
402 * Add to the Length field the length of the UINT32 NULL
403 */
404 UserPrt->Length += sizeof (UINT32);
405 break;
406
407 default:
408
410 "(PRT[%u].Source) Need Ref/String/Integer, found %s",
411 Index, AcpiUtGetObjectTypeName (ObjDesc)));
413 }
414 }
415
416 /* Now align the current length */
417
418 UserPrt->Length = (UINT32) ACPI_ROUND_UP_TO_64BIT (UserPrt->Length);
419
420 /* 4) Fourth subobject: Dereference the PRT.SourceIndex */
421
422 ObjDesc = SubObjectList[3];
423 if (!ObjDesc || ObjDesc->Common.Type != ACPI_TYPE_INTEGER)
424 {
426 "(PRT[%u].SourceIndex) Need Integer, found %s",
427 Index, AcpiUtGetObjectTypeName (ObjDesc)));
429 }
430
431 UserPrt->SourceIndex = (UINT32) ObjDesc->Integer.Value;
432
433 /* Point to the next ACPI_OPERAND_OBJECT in the top level package */
434
435 TopObjectList++;
436 }
437
438 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer %p Length %X\n",
439 OutputBuffer->Pointer, (UINT32) OutputBuffer->Length));
441}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define AE_AML_PACKAGE_LIMIT
Definition: acexcep.h:190
#define ACPI_ROUND_UP_TO_64BIT(a)
Definition: acmacros.h:253
ACPI_STATUS AcpiNsHandleToPathname(ACPI_HANDLE TargetHandle, ACPI_BUFFER *Buffer, BOOLEAN NoTrailing)
Definition: nsnames.c:187
@ ACPI_REFCLASS_NAME
Definition: acobject.h:464
ACPI_STATUS AcpiRsGetPciRoutingTableLength(ACPI_OPERAND_OBJECT *PackageObject, ACPI_SIZE *BufferSizeNeeded)
Definition: rscalc.c:746
struct acpi_pci_routing_table ACPI_PCI_ROUTING_TABLE
#define ACPI_TYPE_LOCAL_REFERENCE
Definition: actypes.h:719
#define ACPI_TYPE_STRING
Definition: actypes.h:689
#define ACPI_TYPE_INTEGER
Definition: actypes.h:688
const char * AcpiUtGetObjectTypeName(ACPI_OPERAND_OBJECT *ObjDesc)
Definition: utdecode.c:264
Definition: bufpool.h:45
union node Node
Definition: types.h:1255
_Must_inspect_result_ _Inout_opt_ PUNICODE_STRING _Out_opt_ PULONG BufferSizeNeeded
Definition: fltkernel.h:1118
if(dx< 0)
Definition: linetemp.h:194
void * Pointer
Definition: actypes.h:1054
ACPI_SIZE Length
Definition: actypes.h:1053
union acpi_operand_object ** Elements
Definition: acobject.h:161
ACPI_NAMESPACE_NODE * Node
Definition: acobject.h:447
ACPI_OBJECT_COMMON_HEADER UINT8 Class
Definition: acobject.h:443
ACPI_OBJECT_INTEGER Integer
Definition: acobject.h:520
ACPI_OBJECT_REFERENCE Reference
Definition: acobject.h:540
ACPI_OBJECT_COMMON Common
Definition: acobject.h:519
ACPI_OBJECT_PACKAGE Package
Definition: acobject.h:523
ACPI_OBJECT_STRING String
Definition: acobject.h:521
Definition: dlist.c:348
_In_ WDFCOLLECTION _In_ ULONG Index

Referenced by AcpiRsGetPrtMethodData().

◆ AcpiRsCreateResourceList()

ACPI_STATUS AcpiRsCreateResourceList ( ACPI_OPERAND_OBJECT AmlBuffer,
ACPI_BUFFER OutputBuffer 
)

Definition at line 151 of file rscreate.c.

154{
155
157 UINT8 *AmlStart;
158 ACPI_SIZE ListSizeNeeded = 0;
160 void *Resource;
161
162
163 ACPI_FUNCTION_TRACE (RsCreateResourceList);
164
165
166 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "AmlBuffer = %p\n",
167 AmlBuffer));
168
169 /* Params already validated, so we don't re-validate here */
170
171 AmlBufferLength = AmlBuffer->Buffer.Length;
172 AmlStart = AmlBuffer->Buffer.Pointer;
173
174 /*
175 * Pass the AmlBuffer into a module that can calculate
176 * the buffer size needed for the linked list
177 */
179 &ListSizeNeeded);
180
181 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Status=%X ListSizeNeeded=%X\n",
182 Status, (UINT32) ListSizeNeeded));
183 if (ACPI_FAILURE (Status))
184 {
186 }
187
188 /* Validate/Allocate/Clear caller buffer */
189
190 Status = AcpiUtInitializeBuffer (OutputBuffer, ListSizeNeeded);
191 if (ACPI_FAILURE (Status))
192 {
194 }
195
196 /* Do the conversion */
197
198 Resource = OutputBuffer->Pointer;
201 if (ACPI_FAILURE (Status))
202 {
204 }
205
206 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer %p Length %X\n",
207 OutputBuffer->Pointer, (UINT32) OutputBuffer->Length));
209}
ACPI_BUFFER *RetBuffer ACPI_BUFFER *RetBuffer char ACPI_WALK_RESOURCE_CALLBACK void *Context ACPI_BUFFER *RetBuffer UINT16 AmlBufferLength
Definition: acpixf.h:1103
ACPI_STATUS AcpiRsGetListLength(UINT8 *AmlBuffer, UINT32 AmlBufferLength, ACPI_SIZE *SizeNeeded)
Definition: rscalc.c:460
ACPI_STATUS AcpiRsConvertAmlToResources(UINT8 *Aml, UINT32 Length, UINT32 Offset, UINT8 ResourceIndex, void **Context)
Definition: rslist.c:68
ACPI_STATUS AcpiUtWalkAmlResources(ACPI_WALK_STATE *WalkState, UINT8 *Aml, ACPI_SIZE AmlLength, ACPI_WALK_AML_CALLBACK UserFunction, void **Context)
Definition: utresrc.c:181
ACPI_OBJECT_BUFFER Buffer
Definition: acobject.h:522

Referenced by AcpiRsGetAeiMethodData(), AcpiRsGetCrsMethodData(), AcpiRsGetMethodData(), and AcpiRsGetPrsMethodData().

◆ AcpiRsDecodeBitmask()

UINT8 AcpiRsDecodeBitmask ( UINT16  Mask,
UINT8 List 
)

Definition at line 68 of file rsutils.c.

71{
72 UINT8 i;
73 UINT8 BitCount;
74
75
77
78
79 /* Decode the mask bits */
80
81 for (i = 0, BitCount = 0; Mask; i++)
82 {
83 if (Mask & 0x0001)
84 {
85 List[BitCount] = i;
86 BitCount++;
87 }
88
89 Mask >>= 1;
90 }
91
92 return (BitCount);
93}
#define ACPI_FUNCTION_ENTRY()
Definition: acoutput.h:484
unsigned int Mask
Definition: fpcontrol.c:82
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550

Referenced by AcpiRsConvertAmlToResource().

◆ AcpiRsEncodeBitmask()

UINT16 AcpiRsEncodeBitmask ( UINT8 List,
UINT8  Count 
)

Definition at line 110 of file rsutils.c.

113{
114 UINT32 i;
115 UINT16 Mask;
116
117
119
120
121 /* Encode the list into a single bitmask */
122
123 for (i = 0, Mask = 0; i < Count; i++)
124 {
125 Mask |= (0x1 << List[i]);
126 }
127
128 return (Mask);
129}

Referenced by AcpiRsConvertResourceToAml().

◆ AcpiRsGetAddressCommon()

BOOLEAN AcpiRsGetAddressCommon ( ACPI_RESOURCE Resource,
AML_RESOURCE Aml 
)

Definition at line 322 of file rsaddr.c.

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}
#define ACPI_IO_RANGE
Definition: acrestyp.h:138
#define ACPI_MEMORY_RANGE
Definition: acrestyp.h:137
static ACPI_RSCONVERT_INFO AcpiRsConvertGeneralFlags[6]
Definition: rsaddr.c:218
static ACPI_RSCONVERT_INFO AcpiRsConvertIoFlags[4]
Definition: rsaddr.c:286
static ACPI_RSCONVERT_INFO AcpiRsConvertMemFlags[5]
Definition: rsaddr.c:255

Referenced by AcpiRsConvertAmlToResource().

◆ AcpiRsGetAeiMethodData()

ACPI_STATUS AcpiRsGetAeiMethodData ( ACPI_NAMESPACE_NODE Node,
ACPI_BUFFER RetBuffer 
)

Definition at line 685 of file rsutils.c.

688{
689 ACPI_OPERAND_OBJECT *ObjDesc;
691
692
693 ACPI_FUNCTION_TRACE (RsGetAeiMethodData);
694
695
696 /* Parameters guaranteed valid by caller */
697
698 /* Execute the method, no parameters */
699
702 if (ACPI_FAILURE (Status))
703 {
705 }
706
707 /*
708 * Make the call to create a resource linked list from the
709 * byte stream buffer that comes back from the _CRS method
710 * execution.
711 */
712 Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer);
713
714 /* On exit, we must delete the object returned by evaluateObject */
715
716 AcpiUtRemoveReference (ObjDesc);
718}
#define ACPI_BTYPE_BUFFER
Definition: aclocal.h:334
#define METHOD_NAME__AEI
Definition: acnames.h:50
ACPI_STATUS AcpiRsCreateResourceList(ACPI_OPERAND_OBJECT *AmlBuffer, ACPI_BUFFER *OutputBuffer)
Definition: rscreate.c:151
ACPI_STATUS AcpiUtEvaluateObject(ACPI_NAMESPACE_NODE *PrefixNode, const char *Path, UINT32 ExpectedReturnBtypes, ACPI_OPERAND_OBJECT **ReturnDesc)
Definition: uteval.c:73
void AcpiUtRemoveReference(ACPI_OPERAND_OBJECT *Object)
Definition: utdelete.c:790

Referenced by AcpiGetEventResources().

◆ AcpiRsGetAmlLength()

ACPI_STATUS AcpiRsGetAmlLength ( ACPI_RESOURCE ResourceList,
ACPI_SIZE  ResourceListSize,
ACPI_SIZE *  SizeNeeded 
)

Definition at line 211 of file rscalc.c.

215{
216 ACPI_SIZE AmlSizeNeeded = 0;
217 ACPI_RESOURCE *ResourceEnd;
218 ACPI_RS_LENGTH TotalSize;
219
220
221 ACPI_FUNCTION_TRACE (RsGetAmlLength);
222
223
224 /* Traverse entire list of internal resource descriptors */
225
226 ResourceEnd = ACPI_ADD_PTR (ACPI_RESOURCE, Resource, ResourceListSize);
227 while (Resource < ResourceEnd)
228 {
229 /* Validate the descriptor type */
230
232 {
234 }
235
236 /* Sanity check the length. It must not be zero, or we loop forever */
237
238 if (!Resource->Length)
239 {
241 }
242
243 /* Get the base size of the (external stream) resource descriptor */
244
245 TotalSize = AcpiGbl_AmlResourceSizes [Resource->Type];
246
247 /*
248 * Augment the base size for descriptors with optional and/or
249 * variable-length fields
250 */
251 switch (Resource->Type)
252 {
254
255 /* Length can be 3 or 2 */
256
257 if (Resource->Data.Irq.DescriptorLength == 2)
258 {
259 TotalSize--;
260 }
261 break;
262
263
265
266 /* Length can be 1 or 0 */
267
268 if (Resource->Data.Irq.DescriptorLength == 0)
269 {
270 TotalSize--;
271 }
272 break;
273
274
276 /*
277 * Vendor Defined Resource:
278 * For a Vendor Specific resource, if the Length is between 1 and 7
279 * it will be created as a Small Resource data type, otherwise it
280 * is a Large Resource data type.
281 */
282 if (Resource->Data.Vendor.ByteLength > 7)
283 {
284 /* Base size of a Large resource descriptor */
285
286 TotalSize = sizeof (AML_RESOURCE_LARGE_HEADER);
287 }
288
289 /* Add the size of the vendor-specific data */
290
291 TotalSize = (ACPI_RS_LENGTH)
292 (TotalSize + Resource->Data.Vendor.ByteLength);
293 break;
294
295
297 /*
298 * End Tag:
299 * We are done -- return the accumulated total size.
300 */
301 *SizeNeeded = AmlSizeNeeded + TotalSize;
302
303 /* Normal exit */
304
306
307
309 /*
310 * 16-Bit Address Resource:
311 * Add the size of the optional ResourceSource info
312 */
313 TotalSize = (ACPI_RS_LENGTH) (TotalSize +
315 &Resource->Data.Address16.ResourceSource));
316 break;
317
318
320 /*
321 * 32-Bit Address Resource:
322 * Add the size of the optional ResourceSource info
323 */
324 TotalSize = (ACPI_RS_LENGTH) (TotalSize +
326 &Resource->Data.Address32.ResourceSource));
327 break;
328
329
331 /*
332 * 64-Bit Address Resource:
333 * Add the size of the optional ResourceSource info
334 */
335 TotalSize = (ACPI_RS_LENGTH) (TotalSize +
337 &Resource->Data.Address64.ResourceSource));
338 break;
339
340
342 /*
343 * Extended IRQ Resource:
344 * Add the size of each additional optional interrupt beyond the
345 * required 1 (4 bytes for each UINT32 interrupt number)
346 */
347 TotalSize = (ACPI_RS_LENGTH) (TotalSize +
348 ((Resource->Data.ExtendedIrq.InterruptCount - 1) * 4) +
349
350 /* Add the size of the optional ResourceSource info */
351
353 &Resource->Data.ExtendedIrq.ResourceSource));
354 break;
355
356
358
359 TotalSize = (ACPI_RS_LENGTH) (TotalSize +
360 (Resource->Data.Gpio.PinTableLength * 2) +
361 Resource->Data.Gpio.ResourceSource.StringLength +
362 Resource->Data.Gpio.VendorLength);
363
364 break;
365
367
368 TotalSize = (ACPI_RS_LENGTH) (TotalSize +
369 (Resource->Data.PinFunction.PinTableLength * 2) +
370 Resource->Data.PinFunction.ResourceSource.StringLength +
371 Resource->Data.PinFunction.VendorLength);
372
373 break;
374
375
377
379 Resource->Data.CommonSerialBus.Type];
380
381 TotalSize = (ACPI_RS_LENGTH) (TotalSize +
382 Resource->Data.I2cSerialBus.ResourceSource.StringLength +
383 Resource->Data.I2cSerialBus.VendorLength);
384
385 break;
386
388
389 TotalSize = (ACPI_RS_LENGTH) (TotalSize +
390 (Resource->Data.PinConfig.PinTableLength * 2) +
391 Resource->Data.PinConfig.ResourceSource.StringLength +
392 Resource->Data.PinConfig.VendorLength);
393
394 break;
395
397
398 TotalSize = (ACPI_RS_LENGTH) (TotalSize +
399 (Resource->Data.PinGroup.PinTableLength * 2) +
400 Resource->Data.PinGroup.ResourceLabel.StringLength +
401 Resource->Data.PinGroup.VendorLength);
402
403 break;
404
406
407 TotalSize = (ACPI_RS_LENGTH) (TotalSize +
408 Resource->Data.PinGroupFunction.ResourceSource.StringLength +
409 Resource->Data.PinGroupFunction.ResourceSourceLabel.StringLength +
410 Resource->Data.PinGroupFunction.VendorLength);
411
412 break;
413
415
416 TotalSize = (ACPI_RS_LENGTH) (TotalSize +
417 Resource->Data.PinGroupConfig.ResourceSource.StringLength +
418 Resource->Data.PinGroupConfig.ResourceSourceLabel.StringLength +
419 Resource->Data.PinGroupConfig.VendorLength);
420
421 break;
422
423 default:
424
425 break;
426 }
427
428 /* Update the total */
429
430 AmlSizeNeeded += TotalSize;
431
432 /* Point to the next object */
433
435 }
436
437 /* Did not find an EndTag resource descriptor */
438
440}
const UINT8 AcpiGbl_AmlResourceSizes[]
Definition: rsinfo.c:201
const UINT8 AcpiGbl_AmlResourceSerialBusSizes[]
Definition: rsinfo.c:275
#define ACPI_RESOURCE_TYPE_PIN_FUNCTION
Definition: acrestyp.h:743
#define ACPI_RESOURCE_TYPE_GPIO
Definition: acrestyp.h:740
#define ACPI_RESOURCE_TYPE_EXTENDED_IRQ
Definition: acrestyp.h:738
#define ACPI_RESOURCE_TYPE_PIN_CONFIG
Definition: acrestyp.h:744
#define ACPI_RESOURCE_TYPE_PIN_GROUP_CONFIG
Definition: acrestyp.h:747
#define ACPI_RESOURCE_TYPE_IRQ
Definition: acrestyp.h:723
#define ACPI_RESOURCE_TYPE_START_DEPENDENT
Definition: acrestyp.h:725
#define ACPI_RESOURCE_TYPE_VENDOR
Definition: acrestyp.h:729
#define ACPI_RESOURCE_TYPE_PIN_GROUP_FUNCTION
Definition: acrestyp.h:746
#define ACPI_RESOURCE_TYPE_ADDRESS64
Definition: acrestyp.h:736
#define ACPI_RESOURCE_TYPE_PIN_GROUP
Definition: acrestyp.h:745
#define ACPI_RESOURCE_TYPE_ADDRESS32
Definition: acrestyp.h:735
#define ACPI_RESOURCE_TYPE_ADDRESS16
Definition: acrestyp.h:734
static ACPI_RS_LENGTH AcpiRsStructOptionLength(ACPI_RESOURCE_SOURCE *ResourceSource)
Definition: rscalc.c:119

Referenced by AcpiRsCreateAmlResources().

◆ AcpiRsGetCrsMethodData()

ACPI_STATUS AcpiRsGetCrsMethodData ( ACPI_NAMESPACE_NODE Node,
ACPI_BUFFER RetBuffer 
)

Definition at line 575 of file rsutils.c.

578{
579 ACPI_OPERAND_OBJECT *ObjDesc;
581
582
583 ACPI_FUNCTION_TRACE (RsGetCrsMethodData);
584
585
586 /* Parameters guaranteed valid by caller */
587
588 /* Execute the method, no parameters */
589
592 if (ACPI_FAILURE (Status))
593 {
595 }
596
597 /*
598 * Make the call to create a resource linked list from the
599 * byte stream buffer that comes back from the _CRS method
600 * execution.
601 */
602 Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer);
603
604 /* On exit, we must delete the object returned by evaluateObject */
605
606 AcpiUtRemoveReference (ObjDesc);
608}
#define METHOD_NAME__CRS
Definition: acnames.h:55

Referenced by AcpiGetCurrentResources().

◆ AcpiRsGetListLength()

ACPI_STATUS AcpiRsGetListLength ( UINT8 AmlBuffer,
UINT32  AmlBufferLength,
ACPI_SIZE *  SizeNeeded 
)

Definition at line 460 of file rscalc.c.

464{
466 UINT8 *EndAml;
467 UINT8 *Buffer;
469 UINT16 Temp16;
470 UINT16 ResourceLength;
471 UINT32 ExtraStructBytes;
472 UINT8 ResourceIndex;
473 UINT8 MinimumAmlResourceLength;
474 AML_RESOURCE *AmlResource;
475
476
477 ACPI_FUNCTION_TRACE (RsGetListLength);
478
479
480 *SizeNeeded = ACPI_RS_SIZE_MIN; /* Minimum size is one EndTag */
481 EndAml = AmlBuffer + AmlBufferLength;
482
483 /* Walk the list of AML resource descriptors */
484
485 while (AmlBuffer < EndAml)
486 {
487 /* Validate the Resource Type and Resource Length */
488
489 Status = AcpiUtValidateResource (NULL, AmlBuffer, &ResourceIndex);
490 if (ACPI_FAILURE (Status))
491 {
492 /*
493 * Exit on failure. Cannot continue because the descriptor length
494 * may be bogus also.
495 */
497 }
498
499 AmlResource = (void *) AmlBuffer;
500
501 /* Get the resource length and base (minimum) AML size */
502
503 ResourceLength = AcpiUtGetResourceLength (AmlBuffer);
504 MinimumAmlResourceLength = AcpiGbl_ResourceAmlSizes[ResourceIndex];
505
506 /*
507 * Augment the size for descriptors with optional
508 * and/or variable length fields
509 */
510 ExtraStructBytes = 0;
511 Buffer = AmlBuffer + AcpiUtGetResourceHeaderLength (AmlBuffer);
512
513 switch (AcpiUtGetResourceType (AmlBuffer))
514 {
516 /*
517 * IRQ Resource:
518 * Get the number of bits set in the 16-bit IRQ mask
519 */
520 ACPI_MOVE_16_TO_16 (&Temp16, Buffer);
521 ExtraStructBytes = AcpiRsCountSetBits (Temp16);
522 break;
523
524
526 /*
527 * DMA Resource:
528 * Get the number of bits set in the 8-bit DMA mask
529 */
530 ExtraStructBytes = AcpiRsCountSetBits (*Buffer);
531 break;
532
533
536 /*
537 * Vendor Resource:
538 * Get the number of vendor data bytes
539 */
540 ExtraStructBytes = ResourceLength;
541
542 /*
543 * There is already one byte included in the minimum
544 * descriptor size. If there are extra struct bytes,
545 * subtract one from the count.
546 */
547 if (ExtraStructBytes)
548 {
549 ExtraStructBytes--;
550 }
551 break;
552
553
555 /*
556 * End Tag: This is the normal exit
557 */
559
560
564 /*
565 * Address Resource:
566 * Add the size of the optional ResourceSource
567 */
568 ExtraStructBytes = AcpiRsStreamOptionLength (
569 ResourceLength, MinimumAmlResourceLength);
570 break;
571
572
574 /*
575 * Extended IRQ Resource:
576 * Using the InterruptTableLength, add 4 bytes for each additional
577 * interrupt. Note: at least one interrupt is required and is
578 * included in the minimum descriptor size (reason for the -1)
579 */
580 ExtraStructBytes = (Buffer[1] - 1) * sizeof (UINT32);
581
582 /* Add the size of the optional ResourceSource */
583
584 ExtraStructBytes += AcpiRsStreamOptionLength (
585 ResourceLength - ExtraStructBytes, MinimumAmlResourceLength);
586 break;
587
589
590 /* Vendor data is optional */
591
592 if (AmlResource->Gpio.VendorLength)
593 {
594 ExtraStructBytes +=
595 AmlResource->Gpio.VendorOffset -
596 AmlResource->Gpio.PinTableOffset +
597 AmlResource->Gpio.VendorLength;
598 }
599 else
600 {
601 ExtraStructBytes +=
602 AmlResource->LargeHeader.ResourceLength +
604 AmlResource->Gpio.PinTableOffset;
605 }
606 break;
607
609
610 /* Vendor data is optional */
611
612 if (AmlResource->PinFunction.VendorLength)
613 {
614 ExtraStructBytes +=
615 AmlResource->PinFunction.VendorOffset -
616 AmlResource->PinFunction.PinTableOffset +
617 AmlResource->PinFunction.VendorLength;
618 }
619 else
620 {
621 ExtraStructBytes +=
622 AmlResource->LargeHeader.ResourceLength +
624 AmlResource->PinFunction.PinTableOffset;
625 }
626 break;
627
629
630 MinimumAmlResourceLength = AcpiGbl_ResourceAmlSerialBusSizes[
631 AmlResource->CommonSerialBus.Type];
632 ExtraStructBytes +=
633 AmlResource->CommonSerialBus.ResourceLength -
634 MinimumAmlResourceLength;
635 break;
636
638
639 /* Vendor data is optional */
640
641 if (AmlResource->PinConfig.VendorLength)
642 {
643 ExtraStructBytes +=
644 AmlResource->PinConfig.VendorOffset -
645 AmlResource->PinConfig.PinTableOffset +
646 AmlResource->PinConfig.VendorLength;
647 }
648 else
649 {
650 ExtraStructBytes +=
651 AmlResource->LargeHeader.ResourceLength +
653 AmlResource->PinConfig.PinTableOffset;
654 }
655 break;
656
658
659 ExtraStructBytes +=
660 AmlResource->PinGroup.VendorOffset -
661 AmlResource->PinGroup.PinTableOffset +
662 AmlResource->PinGroup.VendorLength;
663
664 break;
665
667
668 ExtraStructBytes +=
669 AmlResource->PinGroupFunction.VendorOffset -
670 AmlResource->PinGroupFunction.ResSourceOffset +
671 AmlResource->PinGroupFunction.VendorLength;
672
673 break;
674
676
677 ExtraStructBytes +=
678 AmlResource->PinGroupConfig.VendorOffset -
679 AmlResource->PinGroupConfig.ResSourceOffset +
680 AmlResource->PinGroupConfig.VendorLength;
681
682 break;
683
684 default:
685
686 break;
687 }
688
689 /*
690 * Update the required buffer size for the internal descriptor structs
691 *
692 * Important: Round the size up for the appropriate alignment. This
693 * is a requirement on IA64.
694 */
695 if (AcpiUtGetResourceType (AmlBuffer) ==
697 {
699 AmlResource->CommonSerialBus.Type] + ExtraStructBytes;
700 }
701 else
702 {
703 BufferSize = AcpiGbl_ResourceStructSizes[ResourceIndex] +
704 ExtraStructBytes;
705 }
706
708 *SizeNeeded += BufferSize;
709
711 "Type %.2X, AmlLength %.2X InternalLength %.2X%8X\n",
712 AcpiUtGetResourceType (AmlBuffer),
713 AcpiUtGetDescriptorLength (AmlBuffer), ACPI_FORMAT_UINT64(*SizeNeeded)));
714
715 /*
716 * Point to the next resource within the AML stream using the length
717 * contained in the resource descriptor header
718 */
719 AmlBuffer += AcpiUtGetDescriptorLength (AmlBuffer);
720 }
721
722 /* Did not find an EndTag resource descriptor */
723
725}
#define ACPI_RESOURCE_NAME_ADDRESS64
Definition: aclocal.h:1338
#define ACPI_RESOURCE_NAME_VENDOR_LARGE
Definition: aclocal.h:1332
#define ACPI_RESOURCE_NAME_DMA
Definition: aclocal.h:1313
#define ACPI_RESOURCE_NAME_ADDRESS32
Definition: aclocal.h:1335
#define ACPI_RESOURCE_NAME_VENDOR_SMALL
Definition: aclocal.h:1322
#define ACPI_RESOURCE_NAME_END_TAG
Definition: aclocal.h:1323
#define ACPI_RESOURCE_NAME_PIN_FUNCTION
Definition: aclocal.h:1341
#define ACPI_RESOURCE_NAME_PIN_GROUP
Definition: aclocal.h:1344
#define ACPI_RESOURCE_NAME_ADDRESS16
Definition: aclocal.h:1336
#define ACPI_RESOURCE_NAME_PIN_GROUP_CONFIG
Definition: aclocal.h:1346
#define ACPI_RESOURCE_NAME_IRQ
Definition: aclocal.h:1312
#define ACPI_RESOURCE_NAME_PIN_GROUP_FUNCTION
Definition: aclocal.h:1345
#define ACPI_RESOURCE_NAME_GPIO
Definition: aclocal.h:1340
#define ACPI_RESOURCE_NAME_EXTENDED_IRQ
Definition: aclocal.h:1337
#define ACPI_RESOURCE_NAME_PIN_CONFIG
Definition: aclocal.h:1343
#define ACPI_FORMAT_UINT64(i)
Definition: acmacros.h:71
const UINT8 AcpiGbl_ResourceStructSerialBusSizes[]
Definition: rsinfo.c:284
const UINT8 AcpiGbl_ResourceStructSizes[]
Definition: rsinfo.c:231
#define ACPI_RS_SIZE_MIN
Definition: acrestyp.h:807
const UINT8 AcpiGbl_ResourceAmlSizes[]
Definition: utresrc.c:57
UINT8 AcpiUtGetResourceHeaderLength(void *Aml)
Definition: utresrc.c:572
const UINT8 AcpiGbl_ResourceAmlSerialBusSizes[]
Definition: utresrc.c:101
#define BufferSize
Definition: mmc.h:75
static UINT32 AcpiRsStreamOptionLength(UINT32 ResourceLength, UINT32 MinimumTotalLength)
Definition: rscalc.c:156
static UINT8 AcpiRsCountSetBits(UINT16 BitField)
Definition: rscalc.c:84
UINT16 PinTableOffset
Definition: amlresrc.h:426
UINT16 VendorOffset
Definition: amlresrc.h:429
UINT16 VendorLength
Definition: amlresrc.h:430
AML_RESOURCE_PIN_CONFIG PinConfig
Definition: amlresrc.h:710
AML_RESOURCE_PIN_GROUP PinGroup
Definition: amlresrc.h:711
AML_RESOURCE_PIN_GROUP_FUNCTION PinGroupFunction
Definition: amlresrc.h:712
AML_RESOURCE_PIN_GROUP_CONFIG PinGroupConfig
Definition: amlresrc.h:713
AML_RESOURCE_LARGE_HEADER LargeHeader
Definition: amlresrc.h:677
AML_RESOURCE_GPIO Gpio
Definition: amlresrc.h:703
AML_RESOURCE_PIN_FUNCTION PinFunction
Definition: amlresrc.h:709
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254

Referenced by AcpiBufferToResource(), and AcpiRsCreateResourceList().

◆ AcpiRsGetMethodData()

ACPI_STATUS AcpiRsGetMethodData ( ACPI_HANDLE  Handle,
const char Path,
ACPI_BUFFER RetBuffer 
)

Definition at line 741 of file rsutils.c.

745{
746 ACPI_OPERAND_OBJECT *ObjDesc;
748
749
750 ACPI_FUNCTION_TRACE (RsGetMethodData);
751
752
753 /* Parameters guaranteed valid by caller */
754
755 /* Execute the method, no parameters */
756
759 Path, ACPI_BTYPE_BUFFER, &ObjDesc);
760 if (ACPI_FAILURE (Status))
761 {
763 }
764
765 /*
766 * Make the call to create a resource linked list from the
767 * byte stream buffer that comes back from the method
768 * execution.
769 */
770 Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer);
771
772 /* On exit, we must delete the object returned by EvaluateObject */
773
774 AcpiUtRemoveReference (ObjDesc);
776}
PRTL_UNICODE_STRING_BUFFER Path
ULONG Handle
Definition: gdb_input.c:15

Referenced by AcpiWalkResources().

◆ AcpiRsGetPciRoutingTableLength()

ACPI_STATUS AcpiRsGetPciRoutingTableLength ( ACPI_OPERAND_OBJECT PackageObject,
ACPI_SIZE *  BufferSizeNeeded 
)

Definition at line 746 of file rscalc.c.

749{
750 UINT32 NumberOfElements;
751 ACPI_SIZE TempSizeNeeded = 0;
752 ACPI_OPERAND_OBJECT **TopObjectList;
754 ACPI_OPERAND_OBJECT *PackageElement;
755 ACPI_OPERAND_OBJECT **SubObjectList;
756 BOOLEAN NameFound;
757 UINT32 TableIndex;
758
759
760 ACPI_FUNCTION_TRACE (RsGetPciRoutingTableLength);
761
762
763 NumberOfElements = PackageObject->Package.Count;
764
765 /*
766 * Calculate the size of the return buffer.
767 * The base size is the number of elements * the sizes of the
768 * structures. Additional space for the strings is added below.
769 * The minus one is to subtract the size of the UINT8 Source[1]
770 * member because it is added below.
771 *
772 * But each PRT_ENTRY structure has a pointer to a string and
773 * the size of that string must be found.
774 */
775 TopObjectList = PackageObject->Package.Elements;
776
777 for (Index = 0; Index < NumberOfElements; Index++)
778 {
779 /* Dereference the subpackage */
780
781 PackageElement = *TopObjectList;
782
783 /* We must have a valid Package object */
784
785 if (!PackageElement ||
786 (PackageElement->Common.Type != ACPI_TYPE_PACKAGE))
787 {
789 }
790
791 /*
792 * The SubObjectList will now point to an array of the
793 * four IRQ elements: Address, Pin, Source and SourceIndex
794 */
795 SubObjectList = PackageElement->Package.Elements;
796
797 /* Scan the IrqTableElements for the Source Name String */
798
799 NameFound = FALSE;
800
801 for (TableIndex = 0;
802 TableIndex < PackageElement->Package.Count && !NameFound;
803 TableIndex++)
804 {
805 if (*SubObjectList && /* Null object allowed */
806
808 (*SubObjectList)->Common.Type) ||
809
811 (*SubObjectList)->Common.Type) &&
812
813 ((*SubObjectList)->Reference.Class ==
815 {
816 NameFound = TRUE;
817 }
818 else
819 {
820 /* Look at the next element */
821
822 SubObjectList++;
823 }
824 }
825
826 TempSizeNeeded += (sizeof (ACPI_PCI_ROUTING_TABLE) - 4);
827
828 /* Was a String type found? */
829
830 if (NameFound)
831 {
832 if ((*SubObjectList)->Common.Type == ACPI_TYPE_STRING)
833 {
834 /*
835 * The length String.Length field does not include the
836 * terminating NULL, add 1
837 */
838 TempSizeNeeded += ((ACPI_SIZE)
839 (*SubObjectList)->String.Length + 1);
840 }
841 else
842 {
843 TempSizeNeeded += AcpiNsGetPathnameLength (
844 (*SubObjectList)->Reference.Node);
845 }
846 }
847 else
848 {
849 /*
850 * If no name was found, then this is a NULL, which is
851 * translated as a UINT32 zero.
852 */
853 TempSizeNeeded += sizeof (UINT32);
854 }
855
856 /* Round up the size since each element must be aligned */
857
858 TempSizeNeeded = ACPI_ROUND_UP_TO_64BIT (TempSizeNeeded);
859
860 /* Point to the next ACPI_OPERAND_OBJECT */
861
862 TopObjectList++;
863 }
864
865 /*
866 * Add an extra element to the end of the list, essentially a
867 * NULL terminator
868 */
869 *BufferSizeNeeded = TempSizeNeeded + sizeof (ACPI_PCI_ROUTING_TABLE);
871}
unsigned char BOOLEAN
#define AE_AML_OPERAND_TYPE
Definition: acexcep.h:182
ACPI_SIZE AcpiNsGetPathnameLength(ACPI_NAMESPACE_NODE *Node)
Definition: nsnames.c:97
#define ACPI_TYPE_PACKAGE
Definition: actypes.h:691

Referenced by AcpiRsCreatePciRoutingTable().

◆ AcpiRsGetPrsMethodData()

ACPI_STATUS AcpiRsGetPrsMethodData ( ACPI_NAMESPACE_NODE Node,
ACPI_BUFFER RetBuffer 
)

Definition at line 630 of file rsutils.c.

633{
634 ACPI_OPERAND_OBJECT *ObjDesc;
636
637
638 ACPI_FUNCTION_TRACE (RsGetPrsMethodData);
639
640
641 /* Parameters guaranteed valid by caller */
642
643 /* Execute the method, no parameters */
644
647 if (ACPI_FAILURE (Status))
648 {
650 }
651
652 /*
653 * Make the call to create a resource linked list from the
654 * byte stream buffer that comes back from the _CRS method
655 * execution.
656 */
657 Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer);
658
659 /* On exit, we must delete the object returned by evaluateObject */
660
661 AcpiUtRemoveReference (ObjDesc);
663}
#define METHOD_NAME__PRS
Definition: acnames.h:63

Referenced by AcpiGetPossibleResources().

◆ AcpiRsGetPrtMethodData()

ACPI_STATUS AcpiRsGetPrtMethodData ( ACPI_NAMESPACE_NODE Node,
ACPI_BUFFER RetBuffer 
)

Definition at line 521 of file rsutils.c.

524{
525 ACPI_OPERAND_OBJECT *ObjDesc;
527
528
529 ACPI_FUNCTION_TRACE (RsGetPrtMethodData);
530
531
532 /* Parameters guaranteed valid by caller */
533
534 /* Execute the method, no parameters */
535
538 if (ACPI_FAILURE (Status))
539 {
541 }
542
543 /*
544 * Create a resource linked list from the byte stream buffer that comes
545 * back from the _CRS method execution.
546 */
547 Status = AcpiRsCreatePciRoutingTable (ObjDesc, RetBuffer);
548
549 /* On exit, we must delete the object returned by EvaluateObject */
550
551 AcpiUtRemoveReference (ObjDesc);
553}
#define ACPI_BTYPE_PACKAGE
Definition: aclocal.h:335
#define METHOD_NAME__PRT
Definition: acnames.h:64
ACPI_STATUS AcpiRsCreatePciRoutingTable(ACPI_OPERAND_OBJECT *PackageObject, ACPI_BUFFER *OutputBuffer)
Definition: rscreate.c:234

Referenced by AcpiGetIrqRoutingTable().

◆ AcpiRsGetResourceSource()

ACPI_RS_LENGTH AcpiRsGetResourceSource ( ACPI_RS_LENGTH  ResourceLength,
ACPI_RS_LENGTH  MinimumLength,
ACPI_RESOURCE_SOURCE ResourceSource,
AML_RESOURCE Aml,
char StringPtr 
)

Definition at line 366 of file rsutils.c.

372{
374 UINT8 *AmlResourceSource;
375
376
378
379
380 TotalLength = ResourceLength + sizeof (AML_RESOURCE_LARGE_HEADER);
381 AmlResourceSource = ACPI_ADD_PTR (UINT8, Aml, MinimumLength);
382
383 /*
384 * ResourceSource is present if the length of the descriptor is longer
385 * than the minimum length.
386 *
387 * Note: Some resource descriptors will have an additional null, so
388 * we add 1 to the minimum length.
389 */
390 if (TotalLength > (ACPI_RSDESC_SIZE) (MinimumLength + 1))
391 {
392 /* Get the ResourceSourceIndex */
393
394 ResourceSource->Index = AmlResourceSource[0];
395
396 ResourceSource->StringPtr = StringPtr;
397 if (!StringPtr)
398 {
399 /*
400 * String destination pointer is not specified; Set the String
401 * pointer to the end of the current ResourceSource structure.
402 */
403 ResourceSource->StringPtr = ACPI_ADD_PTR (
404 char, ResourceSource, sizeof (ACPI_RESOURCE_SOURCE));
405 }
406
407 /*
408 * In order for the Resource length to be a multiple of the native
409 * word, calculate the length of the string (+1 for NULL terminator)
410 * and expand to the next word multiple.
411 *
412 * Zero the entire area of the buffer.
413 */
415 ACPI_CAST_PTR (char, &AmlResourceSource[1])) + 1;
416
418
419 memset (ResourceSource->StringPtr, 0, TotalLength);
420
421 /* Copy the ResourceSource string to the destination */
422
423 ResourceSource->StringLength = AcpiRsStrcpy (
424 ResourceSource->StringPtr,
425 ACPI_CAST_PTR (char, &AmlResourceSource[1]));
426
427 return ((ACPI_RS_LENGTH) TotalLength);
428 }
429
430 /* ResourceSource is not present */
431
432 ResourceSource->Index = 0;
433 ResourceSource->StringLength = 0;
434 ResourceSource->StringPtr = NULL;
435 return (0);
436}
static UINT16 AcpiRsStrcpy(char *Destination, char *Source)
Definition: rsutils.c:322
_In_ ULONG TotalLength
Definition: usbdlib.h:158

Referenced by AcpiRsConvertAmlToResource().

◆ AcpiRsMoveData()

void AcpiRsMoveData ( void Destination,
void Source,
UINT16  ItemCount,
UINT8  MoveType 
)

Definition at line 150 of file rsutils.c.

155{
156 UINT32 i;
157
158
160
161
162 /* One move per item */
163
164 for (i = 0; i < ItemCount; i++)
165 {
166 switch (MoveType)
167 {
168 /*
169 * For the 8-bit case, we can perform the move all at once
170 * since there are no alignment or endian issues
171 */
172 case ACPI_RSC_MOVE8:
176
177 memcpy (Destination, Source, ItemCount);
178 return;
179
180 /*
181 * 16-, 32-, and 64-bit cases must use the move macros that perform
182 * endian conversion and/or accommodate hardware that cannot perform
183 * misaligned memory transfers
184 */
185 case ACPI_RSC_MOVE16:
187
191 break;
192
193 case ACPI_RSC_MOVE32:
194
198 break;
199
200 case ACPI_RSC_MOVE64:
201
205 break;
206
207 default:
208
209 return;
210 }
211 }
212}
unsigned long long UINT64
#define ACPI_MOVE_64_TO_64(d, s)
Definition: acmacros.h:155
#define ACPI_MOVE_32_TO_32(d, s)
Definition: acmacros.h:148

Referenced by AcpiRsConvertAmlToResource(), and AcpiRsConvertResourceToAml().

◆ AcpiRsSetAddressCommon()

void AcpiRsSetAddressCommon ( AML_RESOURCE Aml,
ACPI_RESOURCE Resource 
)

Definition at line 381 of file rsaddr.c.

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}

Referenced by AcpiRsConvertResourceToAml().

◆ AcpiRsSetResourceHeader()

void AcpiRsSetResourceHeader ( UINT8  DescriptorType,
ACPI_RSDESC_SIZE  TotalLength,
AML_RESOURCE Aml 
)

Definition at line 289 of file rsutils.c.

293{
295
296
297 /* Set the Resource Type */
298
299 Aml->SmallHeader.DescriptorType = DescriptorType;
300
301 /* Set the Resource Length */
302
304}
void AcpiRsSetResourceLength(ACPI_RSDESC_SIZE TotalLength, AML_RESOURCE *Aml)
Definition: rsutils.c:233
_In_ ULONG _In_ PVOID _In_ LONG DescriptorType
Definition: usbdlib.h:160

Referenced by AcpiRsConvertResourceToAml().

◆ AcpiRsSetResourceLength()

void AcpiRsSetResourceLength ( ACPI_RSDESC_SIZE  TotalLength,
AML_RESOURCE Aml 
)

Definition at line 233 of file rsutils.c.

236{
237 ACPI_RS_LENGTH ResourceLength;
238
239
241
242
243 /* Length is the total descriptor length minus the header length */
244
245 ResourceLength = (ACPI_RS_LENGTH)
247
248 /* Length is stored differently for large and small descriptors */
249
250 if (Aml->SmallHeader.DescriptorType & ACPI_RESOURCE_NAME_LARGE)
251 {
252 /* Large descriptor -- bytes 1-2 contain the 16-bit length */
253
255 &Aml->LargeHeader.ResourceLength, &ResourceLength);
256 }
257 else
258 {
259 /*
260 * Small descriptor -- bits 2:0 of byte 0 contain the length
261 * Clear any existing length, preserving descriptor type bits
262 */
263 Aml->SmallHeader.DescriptorType = (UINT8)
264 ((Aml->SmallHeader.DescriptorType &
266 | ResourceLength);
267 }
268}
#define ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK
Definition: aclocal.h:1304
#define ACPI_RESOURCE_NAME_LARGE
Definition: aclocal.h:1300

Referenced by AcpiRsConvertResourceToAml(), and AcpiRsSetResourceHeader().

◆ AcpiRsSetResourceSource()

ACPI_RSDESC_SIZE AcpiRsSetResourceSource ( AML_RESOURCE Aml,
ACPI_RS_LENGTH  MinimumLength,
ACPI_RESOURCE_SOURCE ResourceSource 
)

Definition at line 457 of file rsutils.c.

461{
462 UINT8 *AmlResourceSource;
463 ACPI_RSDESC_SIZE DescriptorLength;
464
465
467
468
469 DescriptorLength = MinimumLength;
470
471 /* Non-zero string length indicates presence of a ResourceSource */
472
473 if (ResourceSource->StringLength)
474 {
475 /* Point to the end of the AML descriptor */
476
477 AmlResourceSource = ACPI_ADD_PTR (UINT8, Aml, MinimumLength);
478
479 /* Copy the ResourceSourceIndex */
480
481 AmlResourceSource[0] = (UINT8) ResourceSource->Index;
482
483 /* Copy the ResourceSource string */
484
485 strcpy (ACPI_CAST_PTR (char, &AmlResourceSource[1]),
486 ResourceSource->StringPtr);
487
488 /*
489 * Add the length of the string (+ 1 for null terminator) to the
490 * final descriptor length
491 */
492 DescriptorLength += ((ACPI_RSDESC_SIZE)
493 ResourceSource->StringLength + 1);
494 }
495
496 /* Return the new total length of the AML descriptor */
497
498 return (DescriptorLength);
499}

Referenced by AcpiRsConvertResourceToAml().

◆ AcpiRsSetSrsMethodData()

ACPI_STATUS AcpiRsSetSrsMethodData ( ACPI_NAMESPACE_NODE Node,
ACPI_BUFFER RetBuffer 
)

Definition at line 800 of file rsutils.c.

803{
808
809
810 ACPI_FUNCTION_TRACE (RsSetSrsMethodData);
811
812
813 /* Allocate and initialize the evaluation information block */
814
816 if (!Info)
817 {
819 }
820
821 Info->PrefixNode = Node;
822 Info->RelativePathname = METHOD_NAME__SRS;
823 Info->Parameters = Args;
825
826 /*
827 * The InBuffer parameter will point to a linked list of
828 * resource parameters. It needs to be formatted into a
829 * byte stream to be sent in as an input parameter to _SRS
830 *
831 * Convert the linked list into a byte stream
832 */
835 if (ACPI_FAILURE (Status))
836 {
837 goto Cleanup;
838 }
839
840 /* Create and initialize the method parameter object */
841
843 if (!Args[0])
844 {
845 /*
846 * Must free the buffer allocated above (otherwise it is freed
847 * later)
848 */
849 ACPI_FREE (Buffer.Pointer);
851 goto Cleanup;
852 }
853
854 Args[0]->Buffer.Length = (UINT32) Buffer.Length;
855 Args[0]->Buffer.Pointer = Buffer.Pointer;
856 Args[0]->Common.Flags = AOPOBJ_DATA_VALID;
857 Args[1] = NULL;
858
859 /* Execute the method, no return value is expected */
860
862
863 /* Clean up and return the status from AcpiNsEvaluate */
864
866
867Cleanup:
868 ACPI_FREE (Info);
870}
char ** Args
Definition: acdebug.h:353
#define AE_NO_MEMORY
Definition: acexcep.h:112
#define METHOD_NAME__SRS
Definition: acnames.h:73
ACPI_STATUS AcpiNsEvaluate(ACPI_EVALUATE_INFO *Info)
Definition: nseval.c:82
#define AOPOBJ_DATA_VALID
Definition: acobject.h:96
ACPI_STATUS AcpiRsCreateAmlResources(ACPI_BUFFER *ResourceList, ACPI_BUFFER *OutputBuffer)
Definition: rscreate.c:462
#define ACPI_IGNORE_RETURN_VALUE
Definition: acstruct.h:231
#define ACPI_TYPE_BUFFER
Definition: actypes.h:690
#define ACPI_FREE(a)
Definition: actypes.h:386
#define ACPI_ALLOCATE_LOCAL_BUFFER
Definition: actypes.h:1047
#define ACPI_ALLOCATE_ZEROED(a)
Definition: actypes.h:385
#define AcpiUtCreateInternalObject(t)
Definition: acutils.h:681
static const WCHAR Cleanup[]
Definition: register.c:80

Referenced by AcpiSetCurrentResources().

Variable Documentation

◆ AcpiGbl_AmlResourceSerialBusSizes

const UINT8 AcpiGbl_AmlResourceSerialBusSizes[]
extern

Definition at line 275 of file rsinfo.c.

Referenced by AcpiRsGetAmlLength().

◆ AcpiGbl_AmlResourceSizes

const UINT8 AcpiGbl_AmlResourceSizes[]
extern

Definition at line 201 of file rsinfo.c.

Referenced by AcpiRsGetAmlLength().

◆ AcpiGbl_ConvertResourceSerialBusDispatch

ACPI_RSCONVERT_INFO* AcpiGbl_ConvertResourceSerialBusDispatch[]
extern

Definition at line 142 of file rsinfo.c.

Referenced by AcpiRsConvertAmlToResources(), and AcpiRsConvertResourcesToAml().

◆ AcpiGbl_GetResourceDispatch

ACPI_RSCONVERT_INFO* AcpiGbl_GetResourceDispatch[]
extern

Definition at line 96 of file rsinfo.c.

Referenced by AcpiRsConvertAmlToResources().

◆ AcpiGbl_ResourceStructSerialBusSizes

const UINT8 AcpiGbl_ResourceStructSerialBusSizes[]
extern

Definition at line 284 of file rsinfo.c.

Referenced by AcpiRsGetListLength().

◆ AcpiGbl_ResourceStructSizes

const UINT8 AcpiGbl_ResourceStructSizes[]
extern

Definition at line 231 of file rsinfo.c.

Referenced by AcpiRsGetListLength().

◆ AcpiGbl_SetResourceDispatch

ACPI_RSCONVERT_INFO* AcpiGbl_SetResourceDispatch[]
extern

Definition at line 65 of file rsinfo.c.

Referenced by AcpiRsConvertResourcesToAml().

◆ AcpiRsConvertAddress16

ACPI_RSCONVERT_INFO AcpiRsConvertAddress16[]
extern

Definition at line 58 of file rsaddr.c.

◆ AcpiRsConvertAddress32

ACPI_RSCONVERT_INFO AcpiRsConvertAddress32[]
extern

Definition at line 98 of file rsaddr.c.

◆ AcpiRsConvertAddress64

ACPI_RSCONVERT_INFO AcpiRsConvertAddress64[]
extern

Definition at line 138 of file rsaddr.c.

◆ AcpiRsConvertCsi2SerialBus

ACPI_RSCONVERT_INFO AcpiRsConvertCsi2SerialBus[]
extern

Definition at line 228 of file rsserial.c.

◆ AcpiRsConvertDma

ACPI_RSCONVERT_INFO AcpiRsConvertDma[]
extern

Definition at line 258 of file rsirq.c.

◆ AcpiRsConvertEndDpf

ACPI_RSCONVERT_INFO AcpiRsConvertEndDpf[]
extern

Definition at line 160 of file rsio.c.

◆ AcpiRsConvertEndTag

ACPI_RSCONVERT_INFO AcpiRsConvertEndTag[]
extern

Definition at line 178 of file rsio.c.

◆ AcpiRsConvertExtAddress64

ACPI_RSCONVERT_INFO AcpiRsConvertExtAddress64[]
extern

Definition at line 178 of file rsaddr.c.

◆ AcpiRsConvertExtIrq

ACPI_RSCONVERT_INFO AcpiRsConvertExtIrq[]
extern

Definition at line 198 of file rsirq.c.

◆ AcpiRsConvertFixedDma

ACPI_RSCONVERT_INFO AcpiRsConvertFixedDma[]
extern

Definition at line 296 of file rsirq.c.

◆ AcpiRsConvertFixedIo

ACPI_RSCONVERT_INFO AcpiRsConvertFixedIo[]
extern

Definition at line 96 of file rsio.c.

◆ AcpiRsConvertFixedMemory32

ACPI_RSCONVERT_INFO AcpiRsConvertFixedMemory32[]
extern

Definition at line 126 of file rsmemory.c.

◆ AcpiRsConvertGenericReg

ACPI_RSCONVERT_INFO AcpiRsConvertGenericReg[]
extern

Definition at line 126 of file rsio.c.

◆ AcpiRsConvertGpio

ACPI_RSCONVERT_INFO AcpiRsConvertGpio[]
extern

Definition at line 58 of file rsserial.c.

◆ AcpiRsConvertI2cSerialBus

ACPI_RSCONVERT_INFO AcpiRsConvertI2cSerialBus[]
extern

Definition at line 298 of file rsserial.c.

◆ AcpiRsConvertIo

ACPI_RSCONVERT_INFO AcpiRsConvertIo[]
extern

Definition at line 58 of file rsio.c.

◆ AcpiRsConvertMemory24

ACPI_RSCONVERT_INFO AcpiRsConvertMemory24[]
extern

Definition at line 58 of file rsmemory.c.

◆ AcpiRsConvertMemory32

ACPI_RSCONVERT_INFO AcpiRsConvertMemory32[]
extern

Definition at line 92 of file rsmemory.c.

◆ AcpiRsConvertPinConfig

ACPI_RSCONVERT_INFO AcpiRsConvertPinConfig[]
extern

Definition at line 590 of file rsserial.c.

◆ AcpiRsConvertPinFunction

ACPI_RSCONVERT_INFO AcpiRsConvertPinFunction[]
extern

Definition at line 155 of file rsserial.c.

◆ AcpiRsConvertPinGroup

ACPI_RSCONVERT_INFO AcpiRsConvertPinGroup[]
extern

Definition at line 666 of file rsserial.c.

◆ AcpiRsConvertPinGroupConfig

ACPI_RSCONVERT_INFO AcpiRsConvertPinGroupConfig[]
extern

Definition at line 793 of file rsserial.c.

◆ AcpiRsConvertPinGroupFunction

ACPI_RSCONVERT_INFO AcpiRsConvertPinGroupFunction[]
extern

Definition at line 726 of file rsserial.c.

◆ AcpiRsConvertSpiSerialBus

ACPI_RSCONVERT_INFO AcpiRsConvertSpiSerialBus[]
extern

Definition at line 382 of file rsserial.c.

◆ AcpiRsConvertUartSerialBus

ACPI_RSCONVERT_INFO AcpiRsConvertUartSerialBus[]
extern

Definition at line 482 of file rsserial.c.

◆ AcpiRsGetIrq

ACPI_RSCONVERT_INFO AcpiRsGetIrq[]
extern

Definition at line 58 of file rsirq.c.

◆ AcpiRsGetStartDpf

ACPI_RSCONVERT_INFO AcpiRsGetStartDpf[]
extern

Definition at line 201 of file rsio.c.

◆ AcpiRsGetVendorLarge

ACPI_RSCONVERT_INFO AcpiRsGetVendorLarge[]
extern

Definition at line 184 of file rsmemory.c.

◆ AcpiRsGetVendorSmall

ACPI_RSCONVERT_INFO AcpiRsGetVendorSmall[]
extern

Definition at line 158 of file rsmemory.c.

◆ AcpiRsSetIrq

ACPI_RSCONVERT_INFO AcpiRsSetIrq[]
extern

Definition at line 112 of file rsirq.c.

◆ AcpiRsSetStartDpf

ACPI_RSCONVERT_INFO AcpiRsSetStartDpf[]
extern

Definition at line 241 of file rsio.c.

◆ AcpiRsSetVendor

ACPI_RSCONVERT_INFO AcpiRsSetVendor[]
extern

Definition at line 210 of file rsmemory.c.