diff options
author | Matt Fleming <matt.fleming@intel.com> | 2013-03-20 17:14:21 +0000 |
---|---|---|
committer | Matt Fleming <matt.fleming@intel.com> | 2013-03-22 13:57:44 +0000 |
commit | 37d43cf9dd5dd2d2cef1e86aa651097473fd0b48 (patch) | |
tree | 07a7df546f178c4e1576f4cbcc0bb4db3a8e18b4 /com32/include/sys | |
parent | bf20364b582c383b4927f898de213b1cc0981a80 (diff) | |
parent | a107cb3b6fa219cf5f65bef366c9b00b108e9a3a (diff) | |
download | syslinux-37d43cf9dd5dd2d2cef1e86aa651097473fd0b48.tar.gz |
Merge tag 'syslinux-5.10-pre2' into for-hpa/elflink/firmware
syslinux-5.10-pre2
Conflicts:
NEWS
com32/include/netinet/in.h
com32/include/sys/cpu.h
com32/lib/Makefile
core/Makefile
core/fs/diskio.c
core/fs/pxe/pxe.h
core/init.c
core/mem/free.c
core/mem/malloc.c
mk/devel.mk
version
Diffstat (limited to 'com32/include/sys')
-rw-r--r-- | com32/include/sys/cpu.h | 41 | ||||
-rw-r--r-- | com32/include/sys/i386/cpu.h | 29 | ||||
-rw-r--r-- | com32/include/sys/x86_64/cpu.h | 28 |
3 files changed, 49 insertions, 49 deletions
diff --git a/com32/include/sys/cpu.h b/com32/include/sys/cpu.h index 05c98843..76c45da0 100644 --- a/com32/include/sys/cpu.h +++ b/com32/include/sys/cpu.h @@ -13,4 +13,45 @@ #error "unsupported architecture" #endif +typedef unsigned long irq_state_t; + +static inline irq_state_t irq_state(void) +{ + irq_state_t __st; + + asm volatile("pushf ; pop %0" : "=rm" (__st) : : "memory"); + return __st; +} + +static inline irq_state_t irq_save(void) +{ + irq_state_t __st = irq_state(); + cli(); + return __st; +} + +static inline void irq_restore(irq_state_t __st) +{ + asm volatile("push %0 ; popf" : : "rm" (__st) : "memory"); +} + +/* Standard macro to see if a specific flag is changeable */ +static inline __constfunc bool cpu_has_eflag(unsigned long flag) +{ + unsigned long f0, f1; + asm("pushf ; " + "pushf ; " + "pop %0 ; " + "mov %0,%1 ; " + "xor %2,%1 ; " + "push %1 ; " + "popf ; " + "pushf ; " + "pop %1 ; " + "popf" + : "=&r" (f0), "=&r" (f1) + : "ri" (flag)); + return !!((f0^f1) & flag); +} + #endif diff --git a/com32/include/sys/i386/cpu.h b/com32/include/sys/i386/cpu.h index 63d0f5ed..a0cedf20 100644 --- a/com32/include/sys/i386/cpu.h +++ b/com32/include/sys/i386/cpu.h @@ -80,27 +80,6 @@ static inline __constfunc uint32_t cpuid_edx(uint32_t level) return v; } -/* Standard macro to see if a specific flag is changeable */ -static inline __constfunc bool cpu_has_eflag(uint32_t flag) -{ - uint32_t f0, f1; - - asm("pushfl ; " - "pushfl ; " - "popl %0 ; " - "movl %0,%1 ; " - "xorl %2,%1 ; " - "pushl %1 ; " - "popfl ; " - "pushfl ; " - "popl %1 ; " - "popfl" - : "=&r" (f0), "=&r" (f1) - : "ri" (flag)); - - return !!((f0^f1) & flag); -} - static inline uint64_t rdmsr(uint32_t msr) { uint64_t v; @@ -116,20 +95,20 @@ static inline void wrmsr(uint64_t v, uint32_t msr) static inline void cpu_relax(void) { - asm volatile("rep ; nop"); + asm volatile("rep ; nop" : : : "memory"); } static inline void hlt(void) { - asm volatile("hlt"); + asm volatile("hlt" : : : "memory"); } static inline void cli(void) { - asm volatile("cli"); + asm volatile("cli" : : : "memory"); } static inline void sti(void) { - asm volatile("sti"); + asm volatile("sti" : : : "memory"); } diff --git a/com32/include/sys/x86_64/cpu.h b/com32/include/sys/x86_64/cpu.h index 89d79154..cbe968f5 100644 --- a/com32/include/sys/x86_64/cpu.h +++ b/com32/include/sys/x86_64/cpu.h @@ -93,26 +93,6 @@ static inline void cpuid_count(uint32_t op, uint32_t cnt, : "a"(op), "c"(cnt)); } -/* Standard macro to see if a specific flag is changeable */ -static inline __constfunc bool cpu_has_eflag(uint32_t flag) -{ - /* x86_64 */ - uint64_t f0, f1; - asm("pushf ; " - "pushf ; " - "pop %0 ; " - "mov %0,%1 ; " - "xor %2,%1 ; " - "push %1 ; " - "popf ; " - "pushf ; " - "pop %1 ; " - "popf" - : "=&r" (f0), "=&r" (f1) - : "ri" (flag)); - return !!((f0^f1) & flag); -} - static inline uint64_t rdmsr(uint32_t msr) { uint64_t v; @@ -128,21 +108,21 @@ static inline void wrmsr(uint64_t v, uint32_t msr) static inline void cpu_relax(void) { - asm volatile("rep ; nop"); + asm volatile("rep ; nop" : : : "memory"); } static inline void hlt(void) { - asm volatile("hlt"); + asm volatile("hlt" : : : "memory"); } static inline void cli(void) { - asm volatile("cli"); + asm volatile("cli" : : : "memory"); } static inline void sti(void) { - asm volatile("sti"); + asm volatile("sti" : : : "memory"); } #endif |