From 88b3e30fe56cd837f5f3f78e948a6dec5f40ae0f Mon Sep 17 00:00:00 2001 From: Thomas Faber Date: Tue, 10 Nov 2015 12:43:58 +0000 Subject: [PATCH] [ACPICA] - Fix GCC versions of ACPI_ACQUIRE_GLOBAL_LOCK/ACPI_RELEASE_GLOBAL_LOCK. It now generates the same code as the original CORE-10509 svn path=/trunk/; revision=69863 --- .../bus/acpi/acpica/include/platform/acgcc.h | 41 +++++++++++-------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/reactos/drivers/bus/acpi/acpica/include/platform/acgcc.h b/reactos/drivers/bus/acpi/acpica/include/platform/acgcc.h index 95f8f24d716..fda74d4449f 100644 --- a/reactos/drivers/bus/acpi/acpica/include/platform/acgcc.h +++ b/reactos/drivers/bus/acpi/acpica/include/platform/acgcc.h @@ -159,35 +159,42 @@ /* * Global Lock acquire/release code * - * Note: Taken from our old adaptation. - * TODO: Check whether it is equivalent to the MSVC code - * (which was also the same in the older version). + * Note: Handles case where the FACS pointer is null */ -#define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acq) \ +#define ACPI_ACQUIRE_GLOBAL_LOCK(FacsPtr, Acq) \ do { \ - int dummy; \ - asm("1: movl (%1),%%eax;" \ + asm("orl %2,%2;" \ + "jz 2f;" \ + "leal 16(%2),%2;" \ + "1:" \ + "movl (%2),%%eax;" \ "movl %%eax,%%edx;" \ - "andl %2,%%edx;" \ + "andl %3,%%edx;" \ "btsl $0x1,%%edx;" \ "adcl $0x0,%%edx;" \ - "lock; cmpxchgl %%edx,(%1);" \ + "lock; cmpxchgl %%edx,(%2);" \ "jnz 1b;" \ "cmpb $0x3,%%dl;" \ - "sbbl %%eax,%%eax" \ - :"=a"(Acq),"=c"(dummy):"c"(GLptr),"i"(~1L):"dx"); \ + "sbbl %%eax,%%eax;" \ + "2:" \ + :"=a"(Acq):"a"(0xFF),"c"(FacsPtr),"i"(~1L):"edx");\ } while(0) -#define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Acq) \ +#define ACPI_RELEASE_GLOBAL_LOCK(FacsPtr, Acq) \ do { \ - int dummy; \ - asm("1: movl (%1),%%eax;" \ + asm("orl %2,%2;" \ + "jz 2f;" \ + "leal 16(%2),%2;" \ + "1:" \ + "movl (%2),%%eax;" \ "movl %%eax,%%edx;" \ - "andl %2,%%edx;" \ - "lock; cmpxchgl %%edx,(%1);" \ + "andl %3,%%edx;" \ + "lock; cmpxchgl %%edx,(%2);" \ "jnz 1b;" \ - "andl $0x1,%%eax" \ - :"=a"(Acq),"=c"(dummy):"c"(GLptr),"i"(~3L):"dx"); \ + "cmpb $0x3,%%dl;" /* FIXME: this is pointless */ \ + "andl $0x1,%%eax;" \ + "2:" \ + :"=a"(Acq):"a"(0),"c"(FacsPtr),"i"(~3L):"edx");\ } while(0) -- 2.17.1