Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. /*
  2.  * badcode.asl
  3.  *
  4.  * This file contains examples of the extended error checking and
  5.  * typechecking capabilities of the iASL compiler. Other ASL compilers
  6.  * may ignore these errors completely. Note - this is not an exhaustive
  7.  * list of errors detected by iASL, it shows many of the errors that
  8.  * are not detected by other ASL compilers.
  9.  *
  10.  * To compile, use:
  11.  * iasl badcode.asl
  12.  */
  13. DefinitionBlock ("badcode.aml", "DSDT", 1, "Intel", "Example", 0x00000001)
  14. {
  15.     Name (INT1, 0)
  16.     Name (BUF1, Buffer() {0,1,2,3})
  17.     Event (EVT1)
  18.  
  19.     // Invalid SyncLevel in Mutex declaration
  20.  
  21.     Mutex (MTX1, 32)
  22.  
  23.     // Integer beyond the table integer size (32 bits)
  24.  
  25.     Name (BIG, 0x1234567887654321)
  26.  
  27.     // CPackage length does not match initializer list length
  28.  
  29.     Name (PKG1, Package(5) {0,1})
  30.  
  31.     // Inadvertent use of single backslash in a string
  32.  
  33.     Name (PATH, Buffer() {"\_SB_.PCI2._CRS"})
  34.  
  35.     // Invalid hex escape sequence
  36.  
  37.     Name (ESC1, "abcdefg\x00hijklmn")
  38.    
  39.     // Field access beyond region bounds
  40.  
  41.     OperationRegion (OPR1, SystemMemory, 0x2000, 6)
  42.     Field (OPR1, DWordAcc, NoLock, Preserve)
  43.     {
  44.         Offset (4),
  45.         FLD1, 8
  46.     }
  47.  
  48.     // Some address spaces support only ByteAcc or BufferAcc
  49.  
  50.     OperationRegion (OPR2, EmbeddedControl, 0x4000, 8)
  51.     Field (OPR2, DWordAcc, NoLock, Preserve)
  52.     {
  53.         FLD2, 8
  54.     }
  55.     OperationRegion (OPR3, SMBus, 0x8000, 16)
  56.     Field (OPR3, WordAcc, NoLock, Preserve)
  57.     {
  58.         FLD3, 8
  59.     }
  60.  
  61.     // Invalid SyncLevel in method declaration
  62.  
  63.     Method (MTH1, 0, NotSerialized, 32)
  64.     {
  65.         // Invalid arguments and uninitialized locals
  66.  
  67.         Store (Arg3, Local0)
  68.         Store (Local1, Local2)
  69.  
  70.         // Parameter typechecking (MTX1 is invalid type)
  71.  
  72.         Subtract (MTX1, 4, Local3)
  73.  
  74.         // Various invalid parameters
  75.  
  76.         CreateField (BUF1, 0, Subtract (4, 4), FLD1)
  77.  
  78.         // Unchecked mutex and event timeouts
  79.  
  80.         Acquire (MTX1, 100)
  81.         Wait (EVT1, 1)
  82.  
  83.         // Result from operation is not used - statement has no effect
  84.  
  85.         Add (INT1, 8)
  86.  
  87.         // Unreachable code
  88.  
  89.         Return (0)
  90.         Store (5, INT1)
  91.     }
  92.  
  93.     Method (MTH2)
  94.     {
  95.         // Switch with no Case statements
  96.  
  97.         Switch (ToInteger (INT1))
  98.         {
  99.             Default
  100.             {
  101.             }
  102.         }
  103.  
  104.         if (LEqual (INT1, 0))
  105.         {
  106.             Return (INT1)
  107.         }
  108.  
  109.         // Fallthrough exit path does not return a value
  110.     }
  111.  
  112.     Method (MTH3)
  113.     {
  114.         // Method MTH2 above does not always return a value
  115.  
  116.         Store (MTH2 (), Local0)
  117.     }
  118.  
  119.     // Invalid _HID value
  120.  
  121.     Name (_HID, "*PNP0C0A")
  122.  
  123.     // Predefined Name typechecking
  124.  
  125.     Name (_PRW, 4)
  126.     Name (_FDI, Buffer () {0})
  127.  
  128.     // Predefined Name argument count validation
  129.     // and return value validation
  130.  
  131.     Method (_OSC, 5)
  132.     {
  133.     }
  134.  
  135.     // Predefined Names that must be implemented as control methods
  136.  
  137.     Name (_L01, 1)
  138.     Name (_E02, 2)
  139.     Name (_Q03, 3)
  140.     Name (_ON,  0)
  141.     Name (_INI, 1)
  142.     Name (_PTP, 2)
  143.  
  144.     /*
  145.      * Resource Descriptor error checking
  146.      */
  147.     Name (RSC1, ResourceTemplate ()
  148.     {
  149.         // Illegal nested StartDependent macros
  150.  
  151.                 StartDependentFn (0, 0)
  152.                 {
  153.                     StartDependentFn (0, 0)
  154.                     {
  155.             }
  156.         }
  157.  
  158.         // Missing EndDependentFn macro
  159.     })
  160.  
  161.     Name (RSC2, ResourceTemplate ()
  162.     {
  163.         // AddressMin is larger than AddressMax
  164.         IO (Decode16,
  165.             0x07D0,             // Range Minimum
  166.             0x03E8,             // Range Maximum
  167.             0x01,               // Alignment
  168.             0x20,               // Length
  169.             )
  170.  
  171.         // Length larger than Min/Max window size
  172.         Memory32 (ReadOnly,
  173.             0x00001000,         // Range Minimum
  174.             0x00002000,         // Range Maximum
  175.             0x00000004,         // Alignment
  176.             0x00002000,         // Length
  177.             )
  178.  
  179.         // Min and Max not multiples of alignment value
  180.         Memory32 (ReadOnly,
  181.             0x00001001,         // Range Minimum
  182.             0x00002002,         // Range Maximum
  183.             0x00000004,         // Alignment
  184.             0x00000200,         // Length
  185.             )
  186.  
  187.         // 10-bit ISA I/O address has a max of 0x3FF
  188.         FixedIO (
  189.             0xFFFF,             // Address
  190.             0x20,               // Length
  191.             )
  192.  
  193.         // Invalid AccessSize parameter
  194.         Register (SystemIO,
  195.             0x08,               // Bit Width
  196.             0x00,               // Bit Offset
  197.             0x0000000000000100, // Address
  198.             0x05                // Access Size
  199.             )
  200.  
  201.         // Invalid ResourceType (0xB0)
  202.         QWordSpace (0xB0, ResourceConsumer, PosDecode, MinFixed, MaxFixed, 0xA5,
  203.             0x0000,             // Granularity
  204.             0xA000,             // Range Minimum
  205.             0xBFFF,             // Range Maximum
  206.             0x0000,             // Translation Offset
  207.             0x2000,             // Length
  208.             ,, )
  209.  
  210.         // AddressMin is larger than AddressMax
  211.         WordIO (ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange,
  212.             0x0000,             // Granularity
  213.             0x0200,             // Range Minimum
  214.             0x0100,             // Range Maximum
  215.             0x0000,             // Translation Offset
  216.             0x0100,             // Length
  217.             ,, , TypeStatic)
  218.  
  219.         // Length larger than Min/Max window size
  220.         DWordSpace (0xC3, ResourceConsumer, PosDecode, MinFixed, MaxFixed, 0xA5,
  221.             0x00000000,         // Granularity
  222.             0x000C8000,         // Range Minimum
  223.             0x000C9000,         // Range Maximum
  224.             0x00000000,         // Translation Offset
  225.             0x00001002,         // Length
  226.             ,, )
  227.  
  228.         // Granularity must be (power-of-two -1)
  229.         DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxNotFixed, NonCacheable, ReadWrite,
  230.             0x00000010,
  231.             0x40000000,
  232.             0xFED9FFFF,
  233.             0x00000000,
  234.             0xBECA0000)
  235.  
  236.         // Address Min (with zero length) not on granularity boundary
  237.         QWordIO (ResourceProducer, MinFixed, MaxNotFixed, PosDecode, EntireRange,
  238.             0x0000000000000003, // Granularity
  239.             0x0000000000000B02, // Range Minimum
  240.             0x0000000000000C00, // Range Maximum
  241.             0x0000000000000000, // Translation Offset
  242.             0x0000000000000000, // Length
  243.             ,, , TypeStatic)
  244.  
  245.         // Address Max (with zero length) not on (granularity boundary -1)
  246.         QWordMemory (ResourceProducer, PosDecode, MinNotFixed, MaxFixed, Cacheable, ReadWrite,
  247.             0x0000000000000001, // Granularity
  248.             0x0000000000100000, // Range Minimum
  249.             0x00000000002FFFFE, // Range Maximum
  250.             0x0000000000000000, // Translation Offset
  251.             0x0000000000000000, // Length
  252.             ,, , AddressRangeMemory, TypeStatic)
  253.  
  254.         // Invalid combination: zero length, both Min and Max are fixed
  255.         DWordIO (ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange,
  256.             0x00000000,         // Granularity
  257.             0x000C8000,         // Range Minimum
  258.             0x000C8FFF,         // Range Maximum
  259.             0x00000000,         // Translation Offset
  260.             0x00000000,         // Length
  261.             ,, )
  262.  
  263.         // Invalid combination: non-zero length, Min Fixed, Max not fixed
  264.         DWordIO (ResourceProducer, MinFixed, MaxNotFixed, PosDecode, EntireRange,
  265.             0x00000001,         // Granularity
  266.             0x000C8000,         // Range Minimum
  267.             0x000C8FFF,         // Range Maximum
  268.             0x00000000,         // Translation Offset
  269.             0x00000100,         // Length
  270.             ,, )
  271.  
  272.         // Invalid combination: non-zero length, Min not Fixed, Max fixed
  273.         DWordIO (ResourceProducer, MinNotFixed, MaxFixed, PosDecode, EntireRange,
  274.             0x00000001,         // Granularity
  275.             0x000C8000,         // Range Minimum
  276.             0x000C8FFF,         // Range Maximum
  277.             0x00000000,         // Translation Offset
  278.             0x00000200,         // Length
  279.             ,, )
  280.  
  281.         // Granularity must be zero if non-zero length, min/max fixed
  282.         DWordIO (ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange,
  283.             0x0000000F,         // Granularity
  284.             0x000C8000,         // Range Minimum
  285.             0x000C8FFF,         // Range Maximum
  286.             0x00000000,         // Translation Offset
  287.             0x00001000,         // Length
  288.             ,, )
  289.  
  290.         // Missing StartDependentFn macro
  291.  
  292.         EndDependentFn ()
  293.     })
  294. }
  295.  
  296.