arch/x86: rework z_arch_irq_lock() and z_arch_irq_unlock()
Simplified these two inline functions somewhat, and refactored them: unlocking can be shared between subarches, but locking cannot. Signed-off-by: Charles E. Youse <charles.youse@intel.com>
This commit is contained in:
parent
58bbbddbef
commit
9b00f7821a
3 changed files with 45 additions and 81 deletions
|
@ -16,6 +16,16 @@
|
|||
#include <zephyr/types.h>
|
||||
#include <stddef.h>
|
||||
|
||||
static ALWAYS_INLINE void z_arch_irq_unlock(unsigned int key)
|
||||
{
|
||||
if ((key & 0x00000200U) != 0U) { /* 'IF' bit */
|
||||
__asm__ volatile (
|
||||
"sti;\n\t"
|
||||
: : : "memory"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
static ALWAYS_INLINE void sys_out8(u8_t data, io_port_t port)
|
||||
{
|
||||
__asm__ volatile("outb %b0, %w1;\n\t"
|
||||
|
|
|
@ -316,57 +316,6 @@ struct _x86_syscall_stack_frame {
|
|||
u32_t ss;
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @brief Disable all interrupts on the CPU
|
||||
*
|
||||
* GCC assembly internals of irq_lock(). See irq_lock() for a complete
|
||||
* description.
|
||||
*
|
||||
* @return An architecture-dependent lock-out key representing the
|
||||
* "interrupt disable state" prior to the call.
|
||||
*/
|
||||
|
||||
static ALWAYS_INLINE unsigned int _do_irq_lock(void)
|
||||
{
|
||||
unsigned int key;
|
||||
|
||||
__asm__ volatile (
|
||||
"pushfl;\n\t"
|
||||
"cli;\n\t"
|
||||
"popl %0;\n\t"
|
||||
: "=g" (key)
|
||||
:
|
||||
: "memory"
|
||||
);
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @brief Enable all interrupts on the CPU (inline)
|
||||
*
|
||||
* GCC assembly internals of irq_lock_unlock(). See irq_lock_unlock() for a
|
||||
* complete description.
|
||||
*
|
||||
* @return N/A
|
||||
*/
|
||||
|
||||
static ALWAYS_INLINE void z_do_irq_unlock(void)
|
||||
{
|
||||
__asm__ volatile (
|
||||
"sti;\n\t"
|
||||
: : : "memory"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Get a 32 bit CPU timestamp counter
|
||||
|
@ -418,35 +367,21 @@ static ALWAYS_INLINE
|
|||
|
||||
static ALWAYS_INLINE unsigned int z_arch_irq_lock(void)
|
||||
{
|
||||
unsigned int key = _do_irq_lock();
|
||||
unsigned int key;
|
||||
|
||||
__asm__ volatile (
|
||||
"pushfl;\n\t"
|
||||
"cli;\n\t"
|
||||
"popl %0;\n\t"
|
||||
: "=g" (key)
|
||||
:
|
||||
: "memory"
|
||||
);
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Enable all interrupts on the CPU (inline)
|
||||
*
|
||||
* This routine re-enables interrupts on the CPU. The @a key parameter
|
||||
* is an architecture-dependent lock-out key that is returned by a previous
|
||||
* invocation of irq_lock().
|
||||
*
|
||||
* This routine can be called from either interrupt or thread level.
|
||||
*
|
||||
* @return N/A
|
||||
*
|
||||
*/
|
||||
|
||||
static ALWAYS_INLINE void z_arch_irq_unlock(unsigned int key)
|
||||
{
|
||||
if ((key & 0x200U) == 0U) {
|
||||
return;
|
||||
}
|
||||
|
||||
z_do_irq_unlock();
|
||||
}
|
||||
|
||||
/**
|
||||
* The NANO_SOFT_IRQ macro must be used as the value for the @a irq parameter
|
||||
* to NANO_CPU_INT_REGISTER when connecting to an interrupt that does not
|
||||
|
|
|
@ -3,13 +3,35 @@
|
|||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef ZEPHYR_INCLUDE_ARCH_X86_INTEL64_ARCH_H_
|
||||
#define ZEPHYR_INCLUDE_ARCH_X86_INTEL64_ARCH_H_
|
||||
|
||||
#include <kernel_arch_thread.h>
|
||||
|
||||
#ifndef _ASMLANGUAGE
|
||||
|
||||
static ALWAYS_INLINE unsigned int z_arch_irq_lock(void)
|
||||
{
|
||||
unsigned long key;
|
||||
|
||||
__asm__ volatile (
|
||||
"pushfq\n\t"
|
||||
"cli\n\t"
|
||||
"popq %0\n\t"
|
||||
: "=g" (key)
|
||||
:
|
||||
: "memory"
|
||||
);
|
||||
|
||||
return (unsigned int) key;
|
||||
}
|
||||
|
||||
#endif /* _ASMLANGUAGE */
|
||||
|
||||
/*
|
||||
* dummies for now
|
||||
*/
|
||||
|
||||
#ifndef ZEPHYR_INCLUDE_ARCH_X86_INTEL64_ARCH_H_
|
||||
#define ZEPHYR_INCLUDE_ARCH_X86_INTEL64_ARCH_H_
|
||||
|
||||
#define Z_ARCH_THREAD_STACK_DEFINE(sym, size) \
|
||||
struct _k_thread_stack_element sym[size]
|
||||
|
||||
|
@ -19,9 +41,6 @@
|
|||
#define Z_IRQ_TO_INTERRUPT_VECTOR(irq) (0)
|
||||
#define Z_ARCH_IRQ_CONNECT(irq_p, priority_p, isr_p, isr_param_p, flags_p)
|
||||
|
||||
#define z_arch_irq_lock() (0)
|
||||
#define z_arch_irq_unlock(k)
|
||||
|
||||
#define z_x86_msr_read(a) (0)
|
||||
|
||||
#endif /* ZEPHYR_INCLUDE_ARCH_X86_INTEL64_ARCH_H_ */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue