2005-04-27 01:08:35 +00:00
|
|
|
/*
|
2009-11-08 17:31:39 +00:00
|
|
|
* Copyright 2005-2009, Axel Dörfler, axeld@pinc-software.de.
|
2005-04-27 01:08:35 +00:00
|
|
|
* 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)
|
|
|
|
|
|
|
|
|
2008-10-01 14:33:10 +00:00
|
|
|
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));
|
2009-11-08 17:31:39 +00:00
|
|
|
return (flags & 0x200) != 0;
|
2008-10-01 14:33:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static inline void
|
2009-11-08 17:31:39 +00:00
|
|
|
arch_int_restore_interrupts_inline(int oldState)
|
2008-10-01 14:33:10 +00:00
|
|
|
{
|
2009-11-08 17:31:39 +00:00
|
|
|
int flags = oldState ? 0x200 : 0;
|
2008-10-01 14:33:10 +00:00
|
|
|
|
|
|
|
asm volatile("pushfl;\n"
|
2009-05-29 01:17:53 +00:00
|
|
|
"popl %0;\n"
|
|
|
|
"andl $0xfffffdff,%0;\n"
|
|
|
|
"orl %1,%0;\n"
|
|
|
|
"pushl %0;\n"
|
2008-10-01 14:33:10 +00:00
|
|
|
"popfl\n"
|
2009-05-29 01:17:53 +00:00
|
|
|
: "=&r"(flags) : "r"(flags));
|
2008-10-01 14:33:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static inline bool
|
|
|
|
arch_int_are_interrupts_enabled_inline(void)
|
|
|
|
{
|
|
|
|
int flags;
|
|
|
|
|
|
|
|
asm volatile("pushfl;\n"
|
|
|
|
"popl %0;\n" : "=g" (flags));
|
2009-11-08 17:31:39 +00:00
|
|
|
return (flags & 0x200) != 0;
|
2008-10-01 14:33:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 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()
|
|
|
|
|
|
|
|
|
2005-04-27 01:08:35 +00:00
|
|
|
#endif /* _KERNEL_ARCH_x86_INT_H */
|