haiku/headers/private/kernel/arch/x86/arch_int.h
Ingo Weinhold 7515c32c1f Not sure, if this was only a gcc 4.3.3 bug or if I misunderstand something, but
gcc could apparently assume that the register assigned to the one in the
clobber list would keep its value (as can be observed when disassembling
add_debugger_command_etc()).
Using a dummy output register works around the problem and also avoids the
unnecessary initialization of the register.

Comments explaining the mystery welcome.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30909 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-05-29 01:17:53 +00:00

68 lines
1.4 KiB
C

/*
* Copyright 2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _KERNEL_ARCH_x86_INT_H
#define _KERNEL_ARCH_x86_INT_H
#define ARCH_INTERRUPT_BASE 0x20
#define NUM_IO_VECTORS (256 - ARCH_INTERRUPT_BASE)
static inline void
arch_int_enable_interrupts_inline(void)
{
asm volatile("sti");
}
static inline int
arch_int_disable_interrupts_inline(void)
{
int flags;
asm volatile("pushfl;\n"
"popl %0;\n"
"cli" : "=g" (flags));
return flags & 0x200 ? 1 : 0;
}
static inline void
arch_int_restore_interrupts_inline(int oldstate)
{
int flags = oldstate ? 0x200 : 0;
asm volatile("pushfl;\n"
"popl %0;\n"
"andl $0xfffffdff,%0;\n"
"orl %1,%0;\n"
"pushl %0;\n"
"popfl\n"
: "=&r"(flags) : "r"(flags));
}
static inline bool
arch_int_are_interrupts_enabled_inline(void)
{
int flags;
asm volatile("pushfl;\n"
"popl %0;\n" : "=g" (flags));
return flags & 0x200 ? 1 : 0;
}
// map the functions to the inline versions
#define arch_int_enable_interrupts() arch_int_enable_interrupts_inline()
#define arch_int_disable_interrupts() arch_int_disable_interrupts_inline()
#define arch_int_restore_interrupts(status) \
arch_int_restore_interrupts_inline(status)
#define arch_int_are_interrupts_enabled() \
arch_int_are_interrupts_enabled_inline()
#endif /* _KERNEL_ARCH_x86_INT_H */