An invalid opcode indicates something seriously wrong with the
input AML file. The AML parser is immediately confused and lost,
causing the resulting parse tree to be ill-formed. The actual
disassembly can then cause numerous unrelated errors and faults.
This change aborts the disassembly upon discovery of such an
opcode during the AML parse phase.
Both UtLocalCalloc and UtStringCacheCalloc will abort the
compiler on an allocation failure. Therefore, there is no
need to check for a non-allocation after these calls. This
change makes this consistent across the compiler.
The runtime errors caused when acpica tools are compiled with
-fsanitize=shift imply that these 1s are stored in integers.
This cast insures that 1 is stored in unsigned integers.
Signed-off-by: Erik Schmauss <erik.schmauss@intel.com>
It is reported that on Linux, RTC driver complains wrong errors on
hardware reduced platform:
[ 4.085420] ACPI Warning: Could not enable fixed event - RealTimeClock (4) (20160422/evxface-654)
This patch fixes this by correctly adding runtime reduced hardware check.
Reported by Chandan Tagore, fixed by Lv Zheng.
Tested-by: Chandan Tagore <tagore.chandan@gmail.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Some hosts may choose not to include stdarg.h, implementing a
configurability in acgcc.h, allowing OSen like Solaris to exclude stdarg.h.
This patch also fixes acintel.h accordingly without providing builtin
support as Intel compiler is similar as GCC. Reported by Dana Myers, fixed
by Lv Zheng.
Reported-by: Dana Myers <dana.myers@oracle.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Acpiexec gives this warning when resources containing GPIOs are extracted
using Resource command:
**** Data mismatch in descriptor [00] type 8C, Offset 00000000 ****
Mismatch at byte offset 13: is 00, should be 25
**** Data mismatch in descriptor [01] type 8C, Offset 00000025 ****
Mismatch at byte offset 13: is 00, should be 25
This happens because we do not set VendorOffset when doing resource to AML
conversion. Fix this by always setting VendorOffset.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
PinGroupConfig() is analogous to PinGroupFunction() but instead of mode
(muxing), it is used to apply specific fine-grained configuration to a
set of referenced pins.
The format of this new resource is:
PinGroupConfig (Shared/Exclusive, PinConfigType, PinConfigValue,
ResourceSource, ResourceSourceIndex, ResourceSourceLabel,
ResourceUsage, DescriptorName, VendorData)
The PinConfigType/PinConfigValue are the same used by PinConfig()
resource.
Here also the combination of ResourceSource and ResourceSourceLabel is
used to specify the PinGroup() this resource refers to.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
PinGroupFunction() is a new resource introduced with ACPI 6.2. It is
used with PinGroup() to configure specific mode for a set of pins
exposed by a GPIO controller.
The format of the resource is:
PinGroupFunction (Shared/Exclusive, FunctionNumber, ResourceSource,
ResourceSourceIndex, ResourceSourceLabel,
ResourceUsage, DescriptorName, VendorData)
The ResourceSource and ResourceSourceLabel fields are used to specify
the PinGroup() resource referenced by PinGroupFunction().
Device (GPIO)
{
Name (_CRS, ResourceTemplate () {
PinGroup ("group1") {2, 3}
PinGroup ("group2") {4, 5}
...
})
}
Device (I2C)
{
Name (_CRS, ResourceTemplate () {
PinGroupFunction (Exclusive, 6, "^GPIO", 0, "mygroup2")
})
}
In the above example the PinGroupFunction() references the second
PinGroup() resource (using label "mygroup2" and configures pins 4 and 5
into mode 6.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
ACPI 6.2 introduced a new resource that is used to declare set of pins
belonging to a GPIO controller. This resource is referenced by new
PinGroupFunction() and PinGroupConfig() resources using ResourceSource
and ResourceLabel fields.
The PinGroup() resource looks like this:
PinGroup (ResourceLabel, ResourceUsage, DescriptorName,
VendorData) {Pin List}
This resource should be listed in _CRS under the GPIO/pincontroller
device providing these pins.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
ACPI 6.2 introduced a new resource that is used to specify fine-grained
configuration of a pin or set of pins used by a device. The ASL syntax of
this new resource looks like:
PinConfig (Shared/Exclusive, PinConfigType, PinConfigValue,
ResourceSource, ResourceSourceIndex, ResourceUsage,
DescriptorName, VendorData) {Pin List}
PinConfigType is an integer with following accepted values:
0x00 (Default) - No configuration is applied to the pin
0x01 (Bias Pull-up) - Pin is pulled up using certain size resistor
0x02 (Bias Pull-down) - Pin is pulled down using certain size resistor
0x03 (Bias Default) - Set to default biasing
0x04 (Bias Disable) - All bias settings will be disabled
0x05 (Bias High Impedance) - Configure the pin as HiZ
0x06 (Bias Bus Hold) - Configure the pin in a weak latch state where
it drives the last value on a tristate bus
0x07 (Drive Open Drain) - Configure the pin into open drain state
0x08 (Drive Open Source) - Configure the pin into open source state
0x09 (Drive Push Pull) - Configure the pin into push-pull state
0x0a (Drive Strength) - How much the pin can supply current
0x0b (Slew Rate) - Configure slew rate of the pin
0x0c (Input Debounce) - Enable input debouncer for the pin
0x0d (Input Schmitt Trigger) - Enable schmitt trigger for the pin
0x0e - 0x7f - Reserved
0x80 - 0xff - Vendor defined types
The PinConfigValue depends on the type and is expressed as units
suitable for that type (for example bias uses Ohms).
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
ACPI 6.2 introduced a new resource that is used to describe how certain
pins are muxed for a device. The ASL syntax of this new resource looks
like below:
PinFunction(Shared, PinConfig, FunctionNumber, ResourceSource,
ResourceSourceIndex, ResourceUsage, DescriptorName,
VendorData) {Pin List}
Which is pretty similar to GpioIo()/GpioInt() resources.
Teach ACPICA about this new resource.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
We are going to use this function also when parsing PinFunction() resource
where pin list starts at different location. To support that pass
StartIndex as parameter instead of hard-coding it to be 10.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
acpisrc can only convert the followings:
typedef union/struct foo {
int bar;
} FOO;
Into:
union struct foo {
int bar;
};
It cannot detect the followings:
typedef union/struct foo FOO;
And convert it into:
typedef union/struct foo foo;
This patch facilitates acpisrc to detect such forms, thus allows some
typedefs to be converted using the latter style with "SIMPLE" conversion
(see ACPI_EFI_FILE in astable.c as a demo). Lv Zheng.
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
The .c files contain snippets of ASL code. This has been extracted and placed as a
comment within DECL.asl. Note the style of this comment does not adhere to our
normal style so that it is easy to copy/paste, if needed.
Signed-off-by: Erik Schmauss <erik.schmauss@intel.com>
The disassembler emits hex bytes, then the ascii equivalent
within a comment. Change the comment type from /* */ to //
This is perfectly legal ASL, and prevents problems when a
buffer contains a /* or */.
When performing the binary comparison test sequence, the compilation
will use the -oE flag to compile the externals in place (rather than
emitting external aml bytecode at the top of the definition block.
The disassembly will use the -oe flag to disassemble externals in place.
The final re-compilation will use the same flags as the normal test case
compilation.
The -oe and -oE flags ensures that the externals within ASL will remain
in the same location throughout the compilation and disassembly. This is
needed for binary comparisons to match for several test cases such as bdemo
and table.
Signed-off-by: Erik Schmauss <erik.schmauss@intel.com>
Changes the resource descriptor parse tree walk to a general
preprocessing walk and calls the Switch conversion code from here.
Move Switch code to new dmswitch.c file. Also improves algorithm to
handle multiple levels of Switch statements and perform legacy
disassembly for older or otherwise non-spec compliant Switch
implementations.
Signed-off-by: David E. Box <david.e.box@linux.intel.com>