Fully inline {disable,restore}_interrupts() and friends when including
<int.h>. Performance-wise not really significant, but gives nicer profiling results. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27827 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
fd9d807978
commit
567f78895b
@ -8,7 +8,6 @@
|
||||
#ifndef KERNEL_ARCH_INT_H
|
||||
#define KERNEL_ARCH_INT_H
|
||||
|
||||
#include <arch_int.h>
|
||||
|
||||
// config flags for arch_int_configure_io_interrupt()
|
||||
#define B_EDGE_TRIGGERED 1
|
||||
@ -38,4 +37,8 @@ bool arch_int_are_interrupts_enabled(void);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#include <arch_int.h>
|
||||
|
||||
|
||||
#endif /* KERNEL_ARCH_INT_H */
|
||||
|
@ -10,4 +10,58 @@
|
||||
#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 %1;\n"
|
||||
"andl $0xfffffdff,%1;\n"
|
||||
"orl %0,%1;\n"
|
||||
"pushl %1;\n"
|
||||
"popfl\n"
|
||||
: : "r" (flags), "r" (0));
|
||||
}
|
||||
|
||||
|
||||
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 */
|
||||
|
@ -42,4 +42,10 @@ are_interrupts_enabled(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// map those directly to the arch versions, so they can be inlined
|
||||
#define disable_interrupts() arch_int_disable_interrupts()
|
||||
#define restore_interrupts(status) arch_int_restore_interrupts(status)
|
||||
|
||||
|
||||
#endif /* _KERNEL_INT_H */
|
||||
|
@ -645,48 +645,37 @@ arch_int_configure_io_interrupt(int irq, uint32 config)
|
||||
}
|
||||
|
||||
|
||||
#undef arch_int_enable_interrupts
|
||||
#undef arch_int_disable_interrupts
|
||||
#undef arch_int_restore_interrupts
|
||||
#undef arch_int_are_interrupts_enabled
|
||||
|
||||
|
||||
void
|
||||
arch_int_enable_interrupts(void)
|
||||
{
|
||||
asm("sti");
|
||||
arch_int_enable_interrupts_inline();
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
arch_int_disable_interrupts(void)
|
||||
{
|
||||
int flags;
|
||||
|
||||
asm("pushfl;\n"
|
||||
"popl %0;\n"
|
||||
"cli" : "=g" (flags));
|
||||
return flags & 0x200 ? 1 : 0;
|
||||
return arch_int_disable_interrupts_inline();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
arch_int_restore_interrupts(int oldstate)
|
||||
{
|
||||
int flags = oldstate ? 0x200 : 0;
|
||||
|
||||
asm("pushfl;\n"
|
||||
"popl %1;\n"
|
||||
"andl $0xfffffdff,%1;\n"
|
||||
"orl %0,%1;\n"
|
||||
"pushl %1;\n"
|
||||
"popfl\n"
|
||||
: : "r" (flags), "r" (0));
|
||||
arch_int_restore_interrupts_inline(oldstate);
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
arch_int_are_interrupts_enabled(void)
|
||||
{
|
||||
int flags;
|
||||
|
||||
asm("pushfl;\n"
|
||||
"popl %0;\n" : "=g" (flags));
|
||||
return flags & 0x200 ? 1 : 0;
|
||||
return arch_int_are_interrupts_enabled_inline();
|
||||
}
|
||||
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <vm_address_space.h>
|
||||
#include <vm_page.h>
|
||||
#include <vm_priv.h>
|
||||
#include <int.h>
|
||||
#include <smp.h>
|
||||
#include <util/queue.h>
|
||||
#include <heap.h>
|
||||
|
@ -248,6 +248,10 @@ int_io_interrupt_handler(int vector, bool levelTriggered)
|
||||
// #pragma mark - public API
|
||||
|
||||
|
||||
#undef disable_interrupts
|
||||
#undef restore_interrupts
|
||||
|
||||
|
||||
cpu_status
|
||||
disable_interrupts(void)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user