iASL patches in Debian
malattia at linux.it
cover iASL patches in Debian
Hello again (this time on the correct mailing list)! Please Cc me on replies as I'm not subscribed to this list.
Here's a re-send of the patches incorrectly sent to linux-acpi@ and with (hopefully better descriptions).
I've been carrying these patches in the iasl Debian package for some time. They are all refreshed and reworked to apply cleanly on top of acpica-unix-20100528. The series consists a couple of trivial patches to fix building on the FreeBSD and Hurd kernel flavours of Debian and some larger ones to enable compiling ASL on big endian architectures.
It would be great if you could apply the patches to your source tree and ship new release with this work included.
Let me know if you want me to run more tests or change something in the patches.
I tested building tests/misc/grammar.asl (plus a number or other DSDTs I have here) with the whole set applied and the results were identical on BE and LE machines as well as being identical to what a clean iasl produces on x86[1].
You can see build logs for all the architectures supported here:
https://buildd.debian.org/status/package.php?p=acpica-unix
[1]: checked with (1) an hex dump of the AML file, (2) the C file generated with -tc and (3) by decompiling the AML to DSL on x86 and comparing the results.
As a side note pristine iasl on x86 sefaults when building test/misc/grammar.asl, with these patches applied it doesn't.
Thanks
Signature · 1 line
mattia
malattia at linux.it
PATCH 1/5 Allow overriding some of the CFLAGS
It makes it easier for package maintainers to override CFLAGS without touching iasl specific defines and includes.
--- compiler/Makefile | 6 +++++- tools/acpiexec/Makefile | 6 +++++- tools/acpisrc/Makefile | 5 ++++- tools/acpixtract/Makefile | 5 ++++- 4 files changed, 18 insertions(+), 4 deletions(-)
compiler/Makefile +5 -1
@@ -125,7 +125,8 @@ ../osunixxf.c NOMAN= YES -CFLAGS+= -Wall -O2 -Wstrict-prototypes -D_LINUX -DACPI_ASL_COMPILER -I../include -I../compiler +MK_CFLAGS = -DACPI_ASL_COMPILER -I../include -I../compiler +CFLAGS= -Wall -Wstrict-prototypes -O2 #YACC= yacc YACC= bison
@@ -141,6 +142,9 @@ LDLIBS = -lpthread -lrt +%.o: %.c + $(CC) $(MK_CFLAGS) $(CFLAGS) -c -o $@ $< + aslmain : $(patsubst %.c,%.o, $(SRCS)) $(CC) $(LDFLAGS) $(patsubst %.c,%.o, $(SRCS)) \ $(LOADLIBES) $(LDLIBS) -o iasl
tools/acpiexec/Makefile +5 -1
@@ -139,8 +139,12 @@ ../../osunixxf.c -CFLAGS+= -Wall -g -D_LINUX -DNDEBUG -D_CONSOLE -DACPI_EXEC_APP -D_MULTI_THREADED -Wstrict-prototypes -I../../include +MK_CFLAGS = -DNDEBUG -D_CONSOLE -DACPI_EXEC_APP -D_MULTI_THREADED \ + -I../../include +CFLAGS = -Wall -Wstrict-prototypes -O2 -g +%.o: %.c + $(CC) $(MK_CFLAGS) $(CFLAGS) -c -o $@ $< acpiexec : $(patsubst %.c,%.o, $(SRCS)) $(CC) $(LDFLAGS) $(patsubst %.c,%.o, $(SRCS)) -lrt -lpthread -o $(PROG)
tools/acpisrc/Makefile +4 -1
@@ -4,8 +4,11 @@ SRCS= ascase.c asconvrt.c asfile.c asmain.c asremove.c astable.c \ asutils.c osunixdir.c ../../common/getopt.c -CFLAGS+= -Wall -O2 -D_LINUX -DACPI_APPLICATION -Wstrict-prototypes -I../../include +MK_CFLAGS= -DACPI_APPLICATION -I../../include +CFLAGS= -Wall -Wstrict-prototypes -O2 +%.o: %.c + $(CC) $(MK_CFLAGS) $(CFLAGS) -c -o $@ $< aslmain : $(patsubst %.c,%.o, $(SRCS)) $(CC) $(LDFLAGS) $(patsubst %.c,%.o, $(SRCS)) -o $(PROG)
tools/acpixtract/Makefile +4 -1
@@ -3,8 +3,11 @@ PROG= acpixtract SRCS= acpixtract.c -CFLAGS+= -Wall -O2 -D_LINUX -DACPI_APPLICATION -Wstrict-prototypes -I../../include +MK_CFLAGS= -DACPI_APPLICATION -I../../include +CFLAGS= -Wall -Wstrict-prototypes -O2 +%.o: %.c + $(CC) $(MK_CFLAGS) $(CFLAGS) -c -o $@ $< acpixtract : $(patsubst %.c,%.o, $(SRCS)) $(CC) $(LDFLAGS) $(patsubst %.c,%.o, $(SRCS)) -o $(PROG)
malattia at linux.it
PATCH 2/5 Small tweak to define uintptr_t and successfully build on debian/kfreebsd
In reply to malattia at linux.itThis is required to build on a FreeBSD kernel running with the GNU userspace toolchain.
--- include/platform/acenv.h | 3 +++ 1 file changed, 3 insertions(+)
include/platform/acenv.h +3 -0
@@ -182,6 +182,9 @@/*! [Begin] no source code translation */ +#if defined(__GLIBC__) +#include <stdint.h> +#endif /****************************************************************************** *
malattia at linux.it
PATCH 3/5 Support compiling DSDT tables on big endian architectures
In reply to malattia at linux.ituse the ACPI_MOVE_<N>_TO_<M> macros to swap the data written to the AML file on big endian architectures (the macros themselves required a few fixes to work correctly).
In some areas the use of temporary variables was necessary to be able to perform sanity checks on the data before actually swapping the bytes.
--- compiler/aslcodegen.c | 107 +++++++++++++++++++++-------------- compiler/aslopcodes.c | 4 + compiler/aslrestype1.c | 68 +++++++++++++++------- compiler/aslrestype1i.c | 29 +++++---- compiler/aslrestype2.c | 25 +++++--- compiler/aslrestype2d.c | 134 +++++++++++++++++++++++++-------------------- compiler/aslrestype2e.c | 117 +++++++++++++++++++++++++++------------ compiler/aslrestype2q.c | 117 +++++++++++++++++++++++++-------------- compiler/aslrestype2w.c | 127 +++++++++++++++++++++++++----------------- include/acmacros.h | 15 +++-- include/platform/aclinux.h | 7 ++ 11 files changed, 470 insertions(+), 280 deletions(-)
include/platform/aclinux.h +6 -1
@@ -156,13 +156,14 @@#include <stdlib.h> #include <ctype.h> #include <unistd.h> +#include <endian.h> /* Host-dependent types and defines for user-space ACPICA */ #define ACPI_FLUSH_CPU_CACHE ()#define ACPI_THREAD_ID pthread_t -#if defined(__ia64__) || defined(__x86_64__) +#if defined(__ia64__) || defined(__x86_64__) || defined(__alpha__)#define ACPI_MACHINE_WIDTH 64#define COMPILER_DEPENDENT_INT64 long#define COMPILER_DEPENDENT_UINT64 unsigned long
@@ -173,6 +174,10 @@#define ACPI_USE_NATIVE_DIVIDE #endif +#if __BYTE_ORDER == __BIG_ENDIAN +#define ACPI_BIG_ENDIAN +#endif +#ifndef __cdecl#define __cdecl#endif
compiler/aslcodegen.c +63 -44
221 lines not on this page · raw message
compiler/aslopcodes.c +3 -1
@@ -449,6 +449,7 @@UINT32 i;UINT8 *AsciiString;UINT16 *UnicodeString; +UINT16 UChar;ACPI_PARSE_OBJECT *BufferLengthOp;
@@ -475,7 +476,8 @@for (i =0 ; i < Count; i++) { - UnicodeString[i] = (UINT16 ) AsciiString[i]; + UChar = (UINT16 ) AsciiString[i]; +ACPI_MOVE_16_TO_16 (&UnicodeString[i], &UChar); }/*
compiler/aslrestype1.c +47 -21
180 lines not on this page · raw message
compiler/aslrestype1i.c +17 -12
@@ -275,6 +275,7 @@ACPI_PARSE_OBJECT *InitializerOp;ACPI_PARSE_OBJECT *AddressOp =NULL ;ASL_RESOURCE_NODE *Rnode; +UINT16 Address =0 ;UINT32 i;
@@ -293,8 +294,7 @@ {case 0 :/* Base Address */ - Descriptor->FixedIo.Address = - (UINT16 ) InitializerOp->Asl.Value.Integer; + Address = InitializerOp->Asl.Value.Integer;RsCreateByteField (InitializerOp,ACPI_RESTAG_BASEADDRESS , CurrentByteOffset +ASL_RESDESC_OFFSET (FixedIo.Address)); AddressOp = InitializerOp;
@@ -324,11 +324,13 @@/* Error checks */ -if (Descriptor->FixedIo.Address >0x03FF ) +if (Address >0x03FF ) {AslError (ASL_WARNING ,ASL_MSG_ISA_ADDRESS , AddressOp,NULL ); } +ACPI_MOVE_16_TO_16 (&Descriptor->FixedIo.Address, &Address); +return (Rnode); }
@@ -359,6 +361,8 @@ACPI_PARSE_OBJECT *LengthOp =NULL ;ACPI_PARSE_OBJECT *AlignOp =NULL ;ASL_RESOURCE_NODE *Rnode; +UINT16 Minimum =0 ; +UINT16 Maximum =0 ;UINT32 i;
@@ -384,8 +388,7 @@case 1 :/* Min Address */ - Descriptor->Io.Minimum = - (UINT16 ) InitializerOp->Asl.Value.Integer; + Minimum = InitializerOp->Asl.Value.Integer;RsCreateByteField (InitializerOp,ACPI_RESTAG_MINADDR , CurrentByteOffset +ASL_RESDESC_OFFSET (Io.Minimum)); MinOp = InitializerOp;
@@ -393,8 +396,7 @@case 2 :/* Max Address */ - Descriptor->Io.Maximum = - (UINT16 ) InitializerOp->Asl.Value.Integer; + Maximum = InitializerOp->Asl.Value.Integer;RsCreateByteField (InitializerOp,ACPI_RESTAG_MAXADDR , CurrentByteOffset +ASL_RESDESC_OFFSET (Io.Maximum)); MaxOp = InitializerOp;
@@ -435,12 +437,15 @@/* Validate the Min/Max/Len/Align values */ RsSmallAddressCheck (ACPI_RESOURCE_NAME_IO , - Descriptor->Io.Minimum, - Descriptor->Io.Maximum, + Minimum, + Maximum, Descriptor->Io.AddressLength, Descriptor->Io.Alignment, MinOp, MaxOp, LengthOp, AlignOp); +ACPI_MOVE_16_TO_16 (&Descriptor->Io.Minimum, &Minimum); +ACPI_MOVE_16_TO_16 (&Descriptor->Io.Maximum, &Maximum); +return (Rnode); }
@@ -561,9 +566,9 @@ InitializerOp =RsCompleteNodeAndGetNext (InitializerOp); } -/* Now we can set the channel mask */ +/* Now we can set the interrupt mask */ - Descriptor->Irq.IrqMask = IrqMask; +ACPI_MOVE_16_TO_16 (&Descriptor->Irq.IrqMask, &IrqMask);return (Rnode); }
@@ -663,6 +668,6 @@/* Now we can set the interrupt mask */ - Descriptor->Irq.IrqMask = IrqMask; +ACPI_MOVE_16_TO_16 (&Descriptor->Irq.IrqMask, &IrqMask);return (Rnode); }
compiler/aslrestype2.c +16 -9
@@ -152,6 +152,7 @@AML_RESOURCE *Descriptor;ACPI_PARSE_OBJECT *InitializerOp;ASL_RESOURCE_NODE *Rnode; +UINT16 ResourceLength;UINT32 i;
@@ -160,7 +161,9 @@ Descriptor = Rnode->Buffer; Descriptor->GenericReg.DescriptorType =ACPI_RESOURCE_NAME_GENERIC_REGISTER ; - Descriptor->GenericReg.ResourceLength =12 ; + ResourceLength =12 ; +ACPI_MOVE_16_TO_16 (&Descriptor->GenericReg.ResourceLength, + &ResourceLength);/* Process all child initialization nodes */
@@ -191,7 +194,8 @@case 3 :/* Register Address */ - Descriptor->GenericReg.Address = InitializerOp->Asl.Value.Integer; +ACPI_MOVE_64_TO_64 (&Descriptor->GenericReg.Address, + &InitializerOp->Asl.Value.Integer);RsCreateByteField (InitializerOp,ACPI_RESTAG_ADDRESS , CurrentByteOffset +ASL_RESDESC_OFFSET (GenericReg.Address));break ;
@@ -249,6 +253,7 @@AML_RESOURCE *Rover =NULL ;ACPI_PARSE_OBJECT *InitializerOp;ASL_RESOURCE_NODE *Rnode; +UINT16 ResourceLength =0 ;UINT16 StringLength =0 ;UINT32 OptionIndex =0 ;UINT32 i;
@@ -295,7 +300,7 @@* Initial descriptor length -- may be enlarged if there are * optional fields present */ - Descriptor->ExtendedIrq.ResourceLength =2 ;/* Flags and table length byte */ + ResourceLength =2 ;/* Flags and table length byte */ Descriptor->ExtendedIrq.InterruptCount =0 ; Rover = ACPI_CAST_PTR (AML_RESOURCE,
@@ -403,10 +408,11 @@/* Save the integer and move pointer to the next one */ - Rover->DwordItem = (UINT32 ) InitializerOp->Asl.Value.Integer; +ACPI_MOVE_64_TO_32 (&Rover->DwordItem, + &InitializerOp->Asl.Value.Integer); Rover =ACPI_ADD_PTR (AML_RESOURCE , &(Rover->DwordItem),4 ); Descriptor->ExtendedIrq.InterruptCount++; - Descriptor->ExtendedIrq.ResourceLength +=4 ; + ResourceLength +=4 ;/* Case 7: First interrupt number in list */
@@ -442,7 +448,7 @@ { Rover->ByteItem = ResSourceIndex; Rover =ACPI_ADD_PTR (AML_RESOURCE , &(Rover->ByteItem),1 ); - Descriptor->ExtendedIrq.ResourceLength +=1 ; + ResourceLength +=1 ; }/* Add optional ResSource string if present */
@@ -454,13 +460,14 @@ Rover =ACPI_ADD_PTR (AML_RESOURCE , &(Rover->ByteItem), StringLength); - Descriptor->ExtendedIrq.ResourceLength = (UINT16 ) - (Descriptor->ExtendedIrq.ResourceLength + StringLength); + ResourceLength = (UINT16 ) (ResourceLength + StringLength); } Rnode->BufferLength = (ASL_RESDESC_OFFSET (ExtendedIrq.Interrupts[0 ]) -ASL_RESDESC_OFFSET (ExtendedIrq.DescriptorType)) + OptionIndex + StringLength; +ACPI_MOVE_16_TO_16 (&Descriptor->ExtendedIrq.ResourceLength, + &ResourceLength);return (Rnode); }
@@ -511,7 +518,7 @@ Descriptor = Rnode->Buffer; Descriptor->VendorLarge.DescriptorType =ACPI_RESOURCE_NAME_VENDOR_LARGE ; - Descriptor->VendorLarge.ResourceLength = (UINT16 ) i; +ACPI_MOVE_32_TO_16 (&Descriptor->VendorLarge.ResourceLength, &i);/* Point to end-of-descriptor for vendor data */
compiler/aslrestype2d.c +76 -58
328 lines not on this page · raw message
compiler/aslrestype2e.c +81 -36
291 lines not on this page · raw message
compiler/aslrestype2q.c +75 -42
310 lines not on this page · raw message
compiler/aslrestype2w.c +75 -52
316 lines not on this page · raw message
include/acmacros.h +11 -4
@@ -175,7 +175,8 @@/* 32-bit source, 16/32/64 destination */ -#define ACPI_MOVE_32_TO_16 (d, s) ACPI_MOVE_16_TO_16(d, s)/* Truncate to 16 */ +#define ACPI_MOVE_32_TO_16 (d, s) {(( UINT8 *)(void *)(d))[0] = ((UINT8 *)(void *)(s))[3];\ + (( UINT8 *)(void *)(d))[1] = ((UINT8 *)(void *)(s))[2];}#define ACPI_MOVE_32_TO_32 (d, s) {(( UINT8 *)(void *)(d))[0] = ((UINT8 *)(void *)(s))[3];\ (( UINT8 *)(void *)(d))[1] = ((UINT8 *)(void *)(s))[2];\
@@ -190,9 +191,13 @@/* 64-bit source, 16/32/64 destination */ -#define ACPI_MOVE_64_TO_16 (d, s) ACPI_MOVE_16_TO_16(d, s)/* Truncate to 16 */ +#define ACPI_MOVE_64_TO_16 (d, s) {(( UINT8 *)(void *)(d))[0] = ((UINT8 *)(void *)(s))[7];\ + (( UINT8 *)(void *)(d))[1] = ((UINT8 *)(void *)(s))[6];} -#define ACPI_MOVE_64_TO_32 (d, s) ACPI_MOVE_32_TO_32(d, s)/* Truncate to 32 */ +#define ACPI_MOVE_64_TO_32 (d, s) {(( UINT8 *)(void *)(d))[0] = ((UINT8 *)(void *)(s))[7];\ + (( UINT8 *)(void *)(d))[1] = ((UINT8 *)(void *)(s))[6];\ + (( UINT8 *)(void *)(d))[2] = ((UINT8 *)(void *)(s))[5];\ + (( UINT8 *)(void *)(d))[3] = ((UINT8 *)(void *)(s))[4];}#define ACPI_MOVE_64_TO_64 (d, s) {(( UINT8 *)(void *)(d))[0] = ((UINT8 *)(void *)(s))[7];\ (( UINT8 *)(void *)(d))[1] = ((UINT8 *)(void *)(s))[6];\
@@ -219,7 +224,9 @@/* 32-bit source, 16/32/64 destination */ -#define ACPI_MOVE_32_TO_16 (d, s) ACPI_MOVE_16_TO_16(d, s)/* Truncate to 16 */ +#define ACPI_MOVE_32_TO_16 (d, s) {(( UINT8 *)(void *)(d))[0] = ((UINT8 *)(void *)(s))[0];\ + (( UINT8 *)(void *)(d))[1] = ((UINT8 *)(void *)(s))[1];} +#define ACPI_MOVE_32_TO_32 (d, s) *(UINT32 *)(void *)(d) = *(UINT32 *)(void *)(s)#define ACPI_MOVE_32_TO_64 (d, s) *(UINT64 *)(void *)(d) = *(UINT32 *)(void *)(s)
malattia at linux.it
PATCH 4/5 Fix aligment issues
In reply to malattia at linux.itAdd more platforms to the list of the ones requiring aligned memory access. Also fix callsites where wrong assumptions where made in terms of aligment.
--- compiler/asltree.c | 15 ++++++++++----- executer/exoparg2.c | 12 +++++++++--- include/actypes.h | 26 +++++++++++++------------- 3 files changed, 32 insertions(+), 21 deletions(-)
include/actypes.h +13 -13
@@ -205,6 +205,19 @@/*! [End] no source code translation !*/ +/* +* In the case of the Itanium Processor Family (IPF), the hardware does not +* support misaligned memory transfers. Set the MISALIGNMENT_NOT_SUPPORTED flag +* to indicate that special precautions must be taken to avoid alignment faults. +* (IA64 or ia64 is currently used by existing compilers to indicate IPF.) +* +* Note: EM64T and other X86-64 processors support misaligned transfers, +* so there is no need to define this flag. +*/ +#if defined (__IA64__) || defined (__ia64__) | defined(__alpha__) || defined(__sparc__) || defined(__hppa__) || defined(__arm__) +#define ACPI_MISALIGNMENT_NOT_SUPPORTED +#endif +/******************************************************************************* *
@@ -231,19 +244,6 @@#define ACPI_SIZE_MAX ACPI_UINT64_MAX#define ACPI_USE_NATIVE_DIVIDE /* Has native 64-bit integer support */ -/* -* In the case of the Itanium Processor Family (IPF), the hardware does not -* support misaligned memory transfers. Set the MISALIGNMENT_NOT_SUPPORTED flag -* to indicate that special precautions must be taken to avoid alignment faults. -* (IA64 or ia64 is currently used by existing compilers to indicate IPF.) -* -* Note: EM64T and other X86-64 processors support misaligned transfers, -* so there is no need to define this flag. -*/ -#if defined (__IA64__) || defined (__ia64__) -#define ACPI_MISALIGNMENT_NOT_SUPPORTED -#endif -/******************************************************************************* *
executer/exoparg2.c +9 -3
@@ -248,6 +248,8 @@ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0 ];ACPI_OPERAND_OBJECT *ReturnDesc1 =NULL ;ACPI_OPERAND_OBJECT *ReturnDesc2 =NULL ; +UINT64 ReturnValue1 =0 ; +UINT64 ReturnValue2 =0 ;ACPI_STATUS Status;
@@ -281,8 +283,10 @@ Status =AcpiUtDivide (Operand[0 ]->Integer.Value, Operand[1 ]->Integer.Value, - &ReturnDesc1->Integer.Value, - &ReturnDesc2->Integer.Value); + &ReturnValue1, &ReturnValue2); + ReturnDesc1->Integer.Value = ReturnValue1; + ReturnDesc2->Integer.Value = ReturnValue2; +if (ACPI_FAILURE (Status)) { goto Cleanup;
@@ -357,6 +361,7 @@ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0 ];ACPI_OPERAND_OBJECT *ReturnDesc =NULL ;UINT64 Index; +UINT64 ReturnValue =0 ;ACPI_STATUS Status =AE_OK ;ACPI_SIZE Length;
@@ -400,7 +405,8 @@ Status =AcpiUtDivide (Operand[0 ]->Integer.Value, Operand[1 ]->Integer.Value,NULL , - &ReturnDesc->Integer.Value); + &ReturnValue); + ReturnDesc->Integer.Value = ReturnValue;break ;
compiler/asltree.c +10 -5
@@ -501,24 +501,27 @@"\nCreateValuedLeafNode Ln/Col %u/%u NewNode %p Op %s Value %8.8X%8.8X " , Op->Asl.LineNumber, Op->Asl.Column, Op,UtGetOpName (ParseOpcode), ACPI_FORMAT_UINT64 (Value)); - Op->Asl.Value.Integer = Value;switch (ParseOpcode) {case PARSEOP_STRING_LITERAL : -DbgPrint (ASL_PARSE_OUTPUT ,"STRING->%s" , Value); + Op->Asl.Value.String = (ACPI_STRING ) Value; +DbgPrint (ASL_PARSE_OUTPUT ,"STRING->%s" , (ACPI_STRING ) Value);break ;case PARSEOP_NAMESEG : -DbgPrint (ASL_PARSE_OUTPUT ,"NAMESEG->%s" , Value); + Op->Asl.Value.String = (ACPI_STRING ) Value; +DbgPrint (ASL_PARSE_OUTPUT ,"NAMESEG->%s" , (ACPI_STRING ) Value);break ;case PARSEOP_NAMESTRING : -DbgPrint (ASL_PARSE_OUTPUT ,"NAMESTRING->%s" , Value); + Op->Asl.Value.String = (ACPI_STRING ) Value; +DbgPrint (ASL_PARSE_OUTPUT ,"NAMESTRING->%s" , (ACPI_STRING ) Value);break ;case PARSEOP_EISAID : -DbgPrint (ASL_PARSE_OUTPUT ,"EISAID->%s" , Value); + Op->Asl.Value.String = (ACPI_STRING ) Value; +DbgPrint (ASL_PARSE_OUTPUT ,"EISAID->%s" , (ACPI_STRING ) Value);break ;case PARSEOP_METHOD :
@@ -526,10 +529,12 @@break ;case PARSEOP_INTEGER : + Op->Asl.Value.Integer = Value;DbgPrint (ASL_PARSE_OUTPUT ,"INTEGER" );break ;default : + Op->Asl.Value.Integer = Value;break ; }
malattia at linux.it
PATCH 5/5 Fix building on GNU/Hurd
In reply to malattia at linux.itgcc on GNU/Hurd defines __GNU__, use the same includes as __linux__ as after all it runs with the same userspace.
--- include/platform/acenv.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/platform/acenv.h +1 -1
@@ -193,7 +193,7 @@* *****************************************************************************/ -#if defined(_LINUX) || defined(__linux__) +#if defined(_LINUX) || defined(__linux__) || defined(__GNU__)#include "aclinux.h" #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
Lin Ming
Re: [Devel] [patch 4/5] Fix aligment issues
In reply to malattia at linux.itQuoted 68 lines · malattia(a)linux.it
Add more platforms to the list of the ones requiring aligned memory access. Also fix callsites where wrong assumptions where made in terms of aligment.
Signed-off-by Mattia Dongili <malattia(a)linux.it>--- compiler/asltree.c | 15 ++++++++++----- executer/exoparg2.c | 12 +++++++++--- include/actypes.h | 26 +++++++++++++------------- 3 files changed, 32 insertions(+), 21 deletions(-)Index:
b/include/actypes.h
===================================================================include/actypes.h +13
-13@@ -205,6 +205,19 @@/*! [End] no source code translation !*/ +/* +* In the case of the Itanium Processor Family (IPF), the hardware does not +* support misaligned memory transfers. Set the MISALIGNMENT_NOT_SUPPORTED flag +* to indicate that special precautions must be taken to avoid alignment faults. +* (IA64 or ia64 is currently used by existing compilers to indicate IPF.) +* +* Note: EM64T and other X86-64 processors support misaligned transfers, +* so there is no need to define this flag. +*/ +#if defined (__IA64__) || defined (__ia64__) | defined(__alpha__) || defined(__sparc__) || defined(__hppa__) || defined(__arm__) +#define ACPI_MISALIGNMENT_NOT_SUPPORTED +#endif +/******************************************************************************* * @@ -231,19 +244,6 @@#define ACPI_SIZE_MAX ACPI_UINT64_MAX#define ACPI_USE_NATIVE_DIVIDE /* Has native 64-bit integer support */ -/* -* In the case of the Itanium Processor Family (IPF), the hardware does not -* support misaligned memory transfers. Set the MISALIGNMENT_NOT_SUPPORTED flag -* to indicate that special precautions must be taken to avoid alignment faults. -* (IA64 or ia64 is currently used by existing compilers to indicate IPF.) -* -* Note: EM64T and other X86-64 processors support misaligned transfers, -* so there is no need to define this flag. -*/ -#if defined (__IA64__) || defined (__ia64__) -#define ACPI_MISALIGNMENT_NOT_SUPPORTED -#endif -/******************************************************************************* * Index:
b/executer/exoparg2.c
===================================================================executer/exoparg2.c +2
-0@@ -248,6 +248,8 @@ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0 ];ACPI_OPERAND_OBJECT *ReturnDesc1 =NULL ;ACPI_OPERAND_OBJECT *ReturnDesc2 =NULL ; +UINT64 ReturnValue1 =0 ; +UINT64 ReturnValue2 =0 ;ACPI_STATUS Status;
executer/exoparg2.c line 286
Quoted 6 lines
executer/exoparg2.c +1
-2@@ -281,8 +283,10 @@ Status =AcpiUtDivide (Operand[0 ]->Integer.Value, Operand[1 ]->Integer.Value, - &ReturnDesc1->Integer.Value, - &ReturnDesc2->Integer.Value); + &ReturnValue1, &ReturnValue2);
Why need to replace &ReturnDesc1->Integer.Value with &ReturnValue1?
Quoted 15 lines
executer/exoparg2.c +4
-0+ ReturnDesc1->Integer.Value = ReturnValue1; + ReturnDesc2->Integer.Value = ReturnValue2; +if (ACPI_FAILURE (Status)) { goto Cleanup;@@ -357,6 +361,7 @@ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0 ];ACPI_OPERAND_OBJECT *ReturnDesc =NULL ;UINT64 Index; +UINT64 ReturnValue =0 ;ACPI_STATUS Status =AE_OK ;ACPI_SIZE Length;
executer/exoparg2.c line 410
Quoted 7 lines
executer/exoparg2.c +2
-1@@ -400,7 +405,8 @@ Status =AcpiUtDivide (Operand[0 ]->Integer.Value, Operand[1 ]->Integer.Value,NULL , - &ReturnDesc->Integer.Value); + &ReturnValue); + ReturnDesc->Integer.Value = ReturnValue;break ;
Ditto.
malattia at linux.it
Re: [Devel] [patch 4/5] Fix aligment issues
Quoted 3 lines · Lin Ming
Quoted 2 lines · malattia(a)linux.it
Add more platforms to the list of the ones requiring aligned memory access. Also fix callsites where wrong assumptions where made in terms of aligment.
...
Quoted 15 lines
Quoted 15 lines
Index:
b/executer/exoparg2.c
===================================================================executer/exoparg2.c +2
-0@@ -248,6 +248,8 @@ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0 ];ACPI_OPERAND_OBJECT *ReturnDesc1 =NULL ;ACPI_OPERAND_OBJECT *ReturnDesc2 =NULL ; +UINT64 ReturnValue1 =0 ; +UINT64 ReturnValue2 =0 ;ACPI_STATUS Status;@@ -281,8 +283,10 @@
Quoted 7 lines
executer/exoparg2.c line 286
Quoted 5 lines
executer/exoparg2.c +1
-2Status =AcpiUtDivide (Operand[0 ]->Integer.Value, Operand[1 ]->Integer.Value, - &ReturnDesc1->Integer.Value, - &ReturnDesc2->Integer.Value); + &ReturnValue1, &ReturnValue2);Why need to replace
&ReturnDesc1->Integer.Valuewith &ReturnValue1?
I get this on sparc systems without these 2 hunks:
malattia(a)smetana:~/acpica-unix> ./compiler/iasl -tc -ps.hex tests/misc/grammar.asl
Intel ACPI Component Architecture
ASL Optimizing Compiler version 20100528 [Jul 6 2010] Copyright (c) 2000 - 2010 Intel Corporation Supports ACPI Specification Revision 4.0a
[1] 28389 bus error ./compiler/iasl -tc -ps.hex tests/misc/grammar.asl
it is caused by the pointer to the 64bit integer being aligned to 4 bytes instead of 8 bytes as required by the 64bit assigment inside AcpiUtDivide when computing the result of the division:
*OutQuotient = InDividend / InDivisor;
or at least that is my understanding of the problem.
Anyway, just using a temporary variable correctly aligned on the stack and then assigning the result to Integer.Value afterwards works around the problem.
Hope the explanation is understandable... otherwise I'll try harder :)
Signature · 2 lines
mattia :wq!
Lin Ming
Re: [Devel] [patch 4/5] Fix aligment issues
Quoted 45 lines · malattia(a)linux.it
Quoted 3 lines · Lin Ming
Quoted 2 lines · malattia(a)linux.it
Add more platforms to the list of the ones requiring aligned memory access. Also fix callsites where wrong assumptions where made in terms of aligment.
...
Quoted 15 lines
Quoted 15 lines
Index:
b/executer/exoparg2.c
===================================================================executer/exoparg2.c +2
-0@@ -248,6 +248,8 @@ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0 ];ACPI_OPERAND_OBJECT *ReturnDesc1 =NULL ;ACPI_OPERAND_OBJECT *ReturnDesc2 =NULL ; +UINT64 ReturnValue1 =0 ; +UINT64 ReturnValue2 =0 ;ACPI_STATUS Status;@@ -281,8 +283,10 @@Quoted 7 lines
executer/exoparg2.c line 286
Quoted 5 lines
executer/exoparg2.c +1
-2Status =AcpiUtDivide (Operand[0 ]->Integer.Value, Operand[1 ]->Integer.Value, - &ReturnDesc1->Integer.Value, - &ReturnDesc2->Integer.Value); + &ReturnValue1, &ReturnValue2);Why need to replace
&ReturnDesc1->Integer.Valuewith &ReturnValue1?I get this on sparc systems without these 2 hunks:
malattia(a)smetana:~/acpica-unix> ./compiler/iasl -tc -ps.hex tests/misc/grammar.asl
Intel ACPI Component Architecture
ASL Optimizing Compiler version 20100528 [Jul 6 2010] Copyright (c) 2000 - 2010 Intel Corporation Supports ACPI Specification Revision 4.0a[1] 28389 bus error ./compiler/iasl -tc -ps.hex tests/misc/grammar.asl
it is caused by the pointer to the 64bit integer being aligned to 4 bytes instead of 8 bytes as required by the 64bit assigment inside AcpiUtDivide when computing the result of the division:
*OutQuotient = InDividend / InDivisor;
Quoted 7 lines
or at least that is my understanding of the problem.
Anyway, just using a temporary variable correctly aligned on the stack and then assigning the result to Integer.Value afterwards works around the problem.
Hope the explanation is understandable... otherwise I'll try harder :)
Thanks for the clear explanation.
Lin Ming