Warning, cross-references for /kernel/drivers/acpica/rsmisc.c need to be fixed.
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116 #define __RSMISC_C__
0117
0118 #include "acpi.h"
0119 #include "accommon.h"
0120 #include "acresrc.h"
0121
0122 #define _COMPONENT ACPI_RESOURCES
0123 ACPI_MODULE_NAME ("rsmisc")
0124
0125
0126 #define INIT_RESOURCE_TYPE(i) i->ResourceOffset
0127 #define INIT_RESOURCE_LENGTH(i) i->AmlOffset
0128 #define INIT_TABLE_LENGTH(i) i->Value
0129
0130 #define COMPARE_OPCODE(i) i->ResourceOffset
0131 #define COMPARE_TARGET(i) i->AmlOffset
0132 #define COMPARE_VALUE(i) i->Value
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150 ACPI_STATUS
0151 AcpiRsConvertAmlToResource (
0152 ACPI_RESOURCE *Resource,
0153 AML_RESOURCE *Aml,
0154 ACPI_RSCONVERT_INFO *Info)
0155 {
0156 ACPI_RS_LENGTH AmlResourceLength;
0157 void *Source;
0158 void *Destination;
0159 char *Target;
0160 UINT8 Count;
0161 UINT8 FlagsMode = FALSE;
0162 UINT16 ItemCount = 0;
0163 UINT16 Temp16 = 0;
0164
0165
0166 ACPI_FUNCTION_TRACE (RsConvertAmlToResource);
0167
0168
0169 if (((ACPI_SIZE) Resource) & 0x3)
0170 {
0171
0172
0173 ACPI_WARNING ((AE_INFO,
0174 "Misaligned resource pointer (get): %p Type %2.2X Len %X",
0175 Resource, Resource->Type, Resource->Length));
0176 }
0177
0178
0179
0180 AmlResourceLength = AcpiUtGetResourceLength (Aml);
0181
0182
0183
0184
0185
0186 Count = INIT_TABLE_LENGTH (Info);
0187
0188 while (Count)
0189 {
0190
0191
0192
0193
0194 Source = ACPI_ADD_PTR (void, Aml, Info->AmlOffset);
0195 Destination = ACPI_ADD_PTR (void, Resource, Info->ResourceOffset);
0196
0197 switch (Info->Opcode)
0198 {
0199 case ACPI_RSC_INITGET:
0200
0201
0202
0203 ACPI_MEMSET (Resource, 0, INIT_RESOURCE_LENGTH (Info));
0204 Resource->Type = INIT_RESOURCE_TYPE (Info);
0205 Resource->Length = INIT_RESOURCE_LENGTH (Info);
0206 break;
0207
0208
0209 case ACPI_RSC_INITSET:
0210 break;
0211
0212
0213 case ACPI_RSC_FLAGINIT:
0214
0215 FlagsMode = TRUE;
0216 break;
0217
0218
0219 case ACPI_RSC_1BITFLAG:
0220
0221
0222
0223 ACPI_SET8 (Destination) = (UINT8)
0224 ((ACPI_GET8 (Source) >> Info->Value) & 0x01);
0225 break;
0226
0227
0228 case ACPI_RSC_2BITFLAG:
0229
0230
0231
0232 ACPI_SET8 (Destination) = (UINT8)
0233 ((ACPI_GET8 (Source) >> Info->Value) & 0x03);
0234 break;
0235
0236
0237 case ACPI_RSC_COUNT:
0238
0239 ItemCount = ACPI_GET8 (Source);
0240 ACPI_SET8 (Destination) = (UINT8) ItemCount;
0241
0242 Resource->Length = Resource->Length +
0243 (Info->Value * (ItemCount - 1));
0244 break;
0245
0246
0247 case ACPI_RSC_COUNT16:
0248
0249 ItemCount = AmlResourceLength;
0250 ACPI_SET16 (Destination) = ItemCount;
0251
0252 Resource->Length = Resource->Length +
0253 (Info->Value * (ItemCount - 1));
0254 break;
0255
0256
0257 case ACPI_RSC_LENGTH:
0258
0259 Resource->Length = Resource->Length + Info->Value;
0260 break;
0261
0262
0263 case ACPI_RSC_MOVE8:
0264 case ACPI_RSC_MOVE16:
0265 case ACPI_RSC_MOVE32:
0266 case ACPI_RSC_MOVE64:
0267
0268
0269
0270
0271 if (Info->Value)
0272 {
0273 ItemCount = Info->Value;
0274 }
0275 AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode);
0276 break;
0277
0278
0279 case ACPI_RSC_SET8:
0280
0281 ACPI_MEMSET (Destination, Info->AmlOffset, Info->Value);
0282 break;
0283
0284
0285 case ACPI_RSC_DATA8:
0286
0287 Target = ACPI_ADD_PTR (char, Resource, Info->Value);
0288 ACPI_MEMCPY (Destination, Source, ACPI_GET16 (Target));
0289 break;
0290
0291
0292 case ACPI_RSC_ADDRESS:
0293
0294
0295
0296 if (!AcpiRsGetAddressCommon (Resource, Aml))
0297 {
0298 return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE);
0299 }
0300 break;
0301
0302
0303 case ACPI_RSC_SOURCE:
0304
0305
0306
0307 Resource->Length +=
0308 AcpiRsGetResourceSource (AmlResourceLength, Info->Value,
0309 Destination, Aml, NULL);
0310 break;
0311
0312
0313 case ACPI_RSC_SOURCEX:
0314
0315
0316
0317
0318 Target = ACPI_ADD_PTR (char, Resource, Info->AmlOffset + (ItemCount * 4));
0319
0320 Resource->Length +=
0321 AcpiRsGetResourceSource (AmlResourceLength,
0322 (ACPI_RS_LENGTH) (((ItemCount - 1) * sizeof (UINT32)) + Info->Value),
0323 Destination, Aml, Target);
0324 break;
0325
0326
0327 case ACPI_RSC_BITMASK:
0328
0329
0330
0331 ItemCount = AcpiRsDecodeBitmask (ACPI_GET8 (Source), Destination);
0332 if (ItemCount)
0333 {
0334 Resource->Length += (ItemCount - 1);
0335 }
0336
0337 Target = ACPI_ADD_PTR (char, Resource, Info->Value);
0338 ACPI_SET8 (Target) = (UINT8) ItemCount;
0339 break;
0340
0341
0342 case ACPI_RSC_BITMASK16:
0343
0344
0345
0346 ACPI_MOVE_16_TO_16 (&Temp16, Source);
0347
0348 ItemCount = AcpiRsDecodeBitmask (Temp16, Destination);
0349 if (ItemCount)
0350 {
0351 Resource->Length += (ItemCount - 1);
0352 }
0353
0354 Target = ACPI_ADD_PTR (char, Resource, Info->Value);
0355 ACPI_SET8 (Target) = (UINT8) ItemCount;
0356 break;
0357
0358
0359 case ACPI_RSC_EXIT_NE:
0360
0361
0362
0363 switch (Info->ResourceOffset)
0364 {
0365 case ACPI_RSC_COMPARE_AML_LENGTH:
0366 if (AmlResourceLength != Info->Value)
0367 {
0368 goto Exit;
0369 }
0370 break;
0371
0372 case ACPI_RSC_COMPARE_VALUE:
0373 if (ACPI_GET8 (Source) != Info->Value)
0374 {
0375 goto Exit;
0376 }
0377 break;
0378
0379 default:
0380
0381 ACPI_ERROR ((AE_INFO, "Invalid conversion sub-opcode"));
0382 return_ACPI_STATUS (AE_BAD_PARAMETER);
0383 }
0384 break;
0385
0386
0387 default:
0388
0389 ACPI_ERROR ((AE_INFO, "Invalid conversion opcode"));
0390 return_ACPI_STATUS (AE_BAD_PARAMETER);
0391 }
0392
0393 Count--;
0394 Info++;
0395 }
0396
0397 Exit:
0398 if (!FlagsMode)
0399 {
0400
0401
0402 Resource->Length = (UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (Resource->Length);
0403 }
0404 return_ACPI_STATUS (AE_OK);
0405 }
0406
0407
0408
0409
0410
0411
0412
0413
0414
0415
0416
0417
0418
0419
0420
0421
0422
0423 ACPI_STATUS
0424 AcpiRsConvertResourceToAml (
0425 ACPI_RESOURCE *Resource,
0426 AML_RESOURCE *Aml,
0427 ACPI_RSCONVERT_INFO *Info)
0428 {
0429 void *Source = NULL;
0430 void *Destination;
0431 ACPI_RSDESC_SIZE AmlLength = 0;
0432 UINT8 Count;
0433 UINT16 Temp16 = 0;
0434 UINT16 ItemCount = 0;
0435
0436
0437 ACPI_FUNCTION_TRACE (RsConvertResourceToAml);
0438
0439
0440
0441
0442
0443
0444 Count = INIT_TABLE_LENGTH (Info);
0445
0446 while (Count)
0447 {
0448
0449
0450
0451
0452 Source = ACPI_ADD_PTR (void, Resource, Info->ResourceOffset);
0453 Destination = ACPI_ADD_PTR (void, Aml, Info->AmlOffset);
0454
0455 switch (Info->Opcode)
0456 {
0457 case ACPI_RSC_INITSET:
0458
0459 ACPI_MEMSET (Aml, 0, INIT_RESOURCE_LENGTH (Info));
0460 AmlLength = INIT_RESOURCE_LENGTH (Info);
0461 AcpiRsSetResourceHeader (INIT_RESOURCE_TYPE (Info), AmlLength, Aml);
0462 break;
0463
0464
0465 case ACPI_RSC_INITGET:
0466 break;
0467
0468
0469 case ACPI_RSC_FLAGINIT:
0470
0471
0472
0473 ACPI_SET8 (Destination) = 0;
0474 break;
0475
0476
0477 case ACPI_RSC_1BITFLAG:
0478
0479
0480
0481 ACPI_SET8 (Destination) |= (UINT8)
0482 ((ACPI_GET8 (Source) & 0x01) << Info->Value);
0483 break;
0484
0485
0486 case ACPI_RSC_2BITFLAG:
0487
0488
0489
0490 ACPI_SET8 (Destination) |= (UINT8)
0491 ((ACPI_GET8 (Source) & 0x03) << Info->Value);
0492 break;
0493
0494
0495 case ACPI_RSC_COUNT:
0496
0497 ItemCount = ACPI_GET8 (Source);
0498 ACPI_SET8 (Destination) = (UINT8) ItemCount;
0499
0500 AmlLength = (UINT16) (AmlLength + (Info->Value * (ItemCount - 1)));
0501 break;
0502
0503
0504 case ACPI_RSC_COUNT16:
0505
0506 ItemCount = ACPI_GET16 (Source);
0507 AmlLength = (UINT16) (AmlLength + ItemCount);
0508 AcpiRsSetResourceLength (AmlLength, Aml);
0509 break;
0510
0511
0512 case ACPI_RSC_LENGTH:
0513
0514 AcpiRsSetResourceLength (Info->Value, Aml);
0515 break;
0516
0517
0518 case ACPI_RSC_MOVE8:
0519 case ACPI_RSC_MOVE16:
0520 case ACPI_RSC_MOVE32:
0521 case ACPI_RSC_MOVE64:
0522
0523 if (Info->Value)
0524 {
0525 ItemCount = Info->Value;
0526 }
0527 AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode);
0528 break;
0529
0530
0531 case ACPI_RSC_ADDRESS:
0532
0533
0534
0535 AcpiRsSetAddressCommon (Aml, Resource);
0536 break;
0537
0538
0539 case ACPI_RSC_SOURCEX:
0540
0541
0542
0543 AmlLength = AcpiRsSetResourceSource (
0544 Aml, (ACPI_RS_LENGTH) AmlLength, Source);
0545 AcpiRsSetResourceLength (AmlLength, Aml);
0546 break;
0547
0548
0549 case ACPI_RSC_SOURCE:
0550
0551
0552
0553
0554 AmlLength = AcpiRsSetResourceSource (Aml, Info->Value, Source);
0555 AcpiRsSetResourceLength (AmlLength, Aml);
0556 break;
0557
0558
0559 case ACPI_RSC_BITMASK:
0560
0561
0562
0563 ACPI_SET8 (Destination) = (UINT8)
0564 AcpiRsEncodeBitmask (Source,
0565 *ACPI_ADD_PTR (UINT8, Resource, Info->Value));
0566 break;
0567
0568
0569 case ACPI_RSC_BITMASK16:
0570
0571
0572
0573 Temp16 = AcpiRsEncodeBitmask (Source,
0574 *ACPI_ADD_PTR (UINT8, Resource, Info->Value));
0575 ACPI_MOVE_16_TO_16 (Destination, &Temp16);
0576 break;
0577
0578
0579 case ACPI_RSC_EXIT_LE:
0580
0581
0582
0583 if (ItemCount <= Info->Value)
0584 {
0585 goto Exit;
0586 }
0587 break;
0588
0589
0590 case ACPI_RSC_EXIT_NE:
0591
0592
0593
0594 switch (COMPARE_OPCODE (Info))
0595 {
0596 case ACPI_RSC_COMPARE_VALUE:
0597
0598 if (*ACPI_ADD_PTR (UINT8, Resource,
0599 COMPARE_TARGET (Info)) != COMPARE_VALUE (Info))
0600 {
0601 goto Exit;
0602 }
0603 break;
0604
0605 default:
0606
0607 ACPI_ERROR ((AE_INFO, "Invalid conversion sub-opcode"));
0608 return_ACPI_STATUS (AE_BAD_PARAMETER);
0609 }
0610 break;
0611
0612
0613 case ACPI_RSC_EXIT_EQ:
0614
0615
0616
0617 if (*ACPI_ADD_PTR (UINT8, Resource,
0618 COMPARE_TARGET (Info)) == COMPARE_VALUE (Info))
0619 {
0620 goto Exit;
0621 }
0622 break;
0623
0624
0625 default:
0626
0627 ACPI_ERROR ((AE_INFO, "Invalid conversion opcode"));
0628 return_ACPI_STATUS (AE_BAD_PARAMETER);
0629 }
0630
0631 Count--;
0632 Info++;
0633 }
0634
0635 Exit:
0636 return_ACPI_STATUS (AE_OK);
0637 }
0638
0639
0640 #if 0
0641
0642
0643 if (Aml->ExtAddress64.RevisionID != AML_RESOURCE_EXTENDED_ADDRESS_REVISION)
0644 {
0645 return_ACPI_STATUS (AE_SUPPORT);
0646 }
0647
0648 if (Resource->Data.StartDpf.PerformanceRobustness >= 3)
0649 {
0650 return_ACPI_STATUS (AE_AML_BAD_RESOURCE_VALUE);
0651 }
0652
0653 if (((Aml->Irq.Flags & 0x09) == 0x00) ||
0654 ((Aml->Irq.Flags & 0x09) == 0x09))
0655 {
0656
0657
0658
0659
0660
0661 ACPI_ERROR ((AE_INFO,
0662 "Invalid interrupt polarity/trigger in resource list, %X",
0663 Aml->Irq.Flags));
0664 return_ACPI_STATUS (AE_BAD_DATA);
0665 }
0666
0667 Resource->Data.ExtendedIrq.InterruptCount = Temp8;
0668 if (Temp8 < 1)
0669 {
0670
0671
0672 return_ACPI_STATUS (AE_AML_BAD_RESOURCE_LENGTH);
0673 }
0674
0675 if (Resource->Data.Dma.Transfer == 0x03)
0676 {
0677 ACPI_ERROR ((AE_INFO,
0678 "Invalid DMA.Transfer preference (3)"));
0679 return_ACPI_STATUS (AE_BAD_DATA);
0680 }
0681 #endif
0682
0683