[ACPICA]
authorThomas Faber <thomas.faber@reactos.org>
Tue, 10 Nov 2015 12:43:58 +0000 (12:43 +0000)
committerThomas Faber <thomas.faber@reactos.org>
Tue, 10 Nov 2015 12:43:58 +0000 (12:43 +0000)
- 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

reactos/drivers/bus/acpi/acpica/include/platform/acgcc.h

index 95f8f24..fda74d4 100644 (file)
 /*
  * 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)