kernel: activate arch interface headers

Duplicate definitions elsewhere have been removed.

A couple functions which are defined by the arch interface
to be non-inline, but were implemented inline by native_posix
and intel64, have been moved to non-inline.

Some missing conditional compilation for z_arch_irq_offload()
has been fixed, as this is an optional feature.

Some massaging of native_posix headers to get everything
in the right scope.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
Andrew Boie 2019-10-03 15:20:41 -07:00 committed by Andrew Boie
commit 979b17f243
16 changed files with 54 additions and 165 deletions

View file

@ -49,8 +49,6 @@ z_arch_thread_return_value_set(struct k_thread *thread, unsigned int value)
thread->arch.swap_return_value = value; thread->arch.swap_return_value = value;
} }
extern void z_arch_cpu_atomic_idle(unsigned int key);
extern FUNC_NORETURN void z_arm_userspace_enter(k_thread_entry_t user_entry, extern FUNC_NORETURN void z_arm_userspace_enter(k_thread_entry_t user_entry,
void *p1, void *p2, void *p3, void *p1, void *p2, void *p3,
u32_t stack_end, u32_t stack_end,
@ -58,11 +56,6 @@ extern FUNC_NORETURN void z_arm_userspace_enter(k_thread_entry_t user_entry,
extern void z_arm_fatal_error(unsigned int reason, const z_arch_esf_t *esf); extern void z_arm_fatal_error(unsigned int reason, const z_arch_esf_t *esf);
extern void z_arch_switch_to_main_thread(struct k_thread *main_thread,
k_thread_stack_t *main_stack,
size_t main_stack_size,
k_thread_entry_t _main);
#endif /* _ASMLANGUAGE */ #endif /* _ASMLANGUAGE */
#ifdef __cplusplus #ifdef __cplusplus

View file

@ -7,10 +7,27 @@
#include "posix_soc_if.h" #include "posix_soc_if.h"
#include "board_irq.h" #include "board_irq.h"
#ifdef CONFIG_IRQ_OFFLOAD
void z_arch_irq_offload(irq_offload_routine_t routine, void *parameter) void z_arch_irq_offload(irq_offload_routine_t routine, void *parameter)
{ {
posix_irq_offload(routine, parameter); posix_irq_offload(routine, parameter);
} }
#endif
void z_arch_irq_enable(unsigned int irq)
{
posix_irq_enable(irq);
}
void z_arch_irq_disable(unsigned int irq)
{
posix_irq_disable(irq);
}
int z_arch_irq_is_enabled(unsigned int irq)
{
return posix_irq_is_enabled(irq);
}
#ifdef CONFIG_DYNAMIC_INTERRUPTS #ifdef CONFIG_DYNAMIC_INTERRUPTS
/** /**

View file

@ -32,7 +32,20 @@ unsigned int posix_irq_lock(void);
void posix_irq_unlock(unsigned int key); void posix_irq_unlock(unsigned int key);
void posix_irq_full_unlock(void); void posix_irq_full_unlock(void);
int posix_get_current_irq(void); int posix_get_current_irq(void);
#ifdef CONFIG_IRQ_OFFLOAD
void posix_irq_offload(irq_offload_routine_t routine, void *parameter); void posix_irq_offload(irq_offload_routine_t routine, void *parameter);
#endif
static ALWAYS_INLINE unsigned int z_arch_irq_lock(void)
{
return posix_irq_lock();
}
static ALWAYS_INLINE void z_arch_irq_unlock(unsigned int key)
{
posix_irq_unlock(key);
}
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -8,6 +8,7 @@
#include <arch/cpu.h> #include <arch/cpu.h>
#include <kernel_arch_data.h> #include <kernel_arch_data.h>
#include <drivers/interrupt_controller/sysapic.h> #include <drivers/interrupt_controller/sysapic.h>
#include <drivers/interrupt_controller/loapic.h>
#include <irq.h> #include <irq.h>
unsigned char _irq_to_interrupt_vector[CONFIG_MAX_IRQ_LINES]; unsigned char _irq_to_interrupt_vector[CONFIG_MAX_IRQ_LINES];
@ -114,4 +115,12 @@ void z_x86_ipi_setup(void)
(void *) z_sched_ipi; (void *) z_sched_ipi;
} }
/*
* it is not clear exactly how/where/why to abstract this, as it
* assumes the use of a local APIC (but there's no other mechanism).
*/
void z_arch_sched_ipi(void)
{
z_loapic_ipi(0, LOAPIC_ICR_IPI_OTHERS, CONFIG_SCHED_IPI_VECTOR);
}
#endif #endif

View file

@ -40,24 +40,6 @@ static inline struct _cpu *z_arch_curr_cpu(void)
return cpu; return cpu;
} }
#if defined(CONFIG_SMP)
#include <drivers/interrupt_controller/loapic.h>
/*
* it is not clear exactly how/where/why to abstract this, as it
* assumes the use of a local APIC (but there's no other mechanism).
*/
static inline void z_arch_sched_ipi(void)
{
z_loapic_ipi(0, LOAPIC_ICR_IPI_OTHERS, CONFIG_SCHED_IPI_VECTOR);
}
#endif
#endif /* _ASMLANGUAGE */ #endif /* _ASMLANGUAGE */
#endif /* ZEPHYR_ARCH_X86_INCLUDE_INTEL64_KERNEL_ARCH_FUNC_H_ */ #endif /* ZEPHYR_ARCH_X86_INCLUDE_INTEL64_KERNEL_ARCH_FUNC_H_ */

View file

@ -274,6 +274,7 @@ void posix_sw_clear_pending_IRQ(unsigned int IRQn)
hw_irq_ctrl_clear_irq(IRQn); hw_irq_ctrl_clear_irq(IRQn);
} }
#ifdef CONFIG_IRQ_OFFLOAD
/** /**
* Storage for functions offloaded to IRQ * Storage for functions offloaded to IRQ
*/ */
@ -303,3 +304,4 @@ void posix_irq_offload(irq_offload_routine_t routine, void *parameter)
posix_sw_set_pending_IRQ(OFFLOAD_SW_IRQ); posix_sw_set_pending_IRQ(OFFLOAD_SW_IRQ);
posix_irq_disable(OFFLOAD_SW_IRQ); posix_irq_disable(OFFLOAD_SW_IRQ);
} }
#endif /* CONFIG_IRQ_OFFLOAD */

View file

@ -333,6 +333,7 @@ void posix_sw_clear_pending_IRQ(unsigned int IRQn)
hw_irq_ctrl_clear_irq(IRQn); hw_irq_ctrl_clear_irq(IRQn);
} }
#ifdef CONFIG_IRQ_OFFLOAD
/** /**
* Storage for functions offloaded to IRQ * Storage for functions offloaded to IRQ
*/ */
@ -362,6 +363,7 @@ void posix_irq_offload(irq_offload_routine_t routine, void *parameter)
posix_sw_set_pending_IRQ(OFFLOAD_SW_IRQ); posix_sw_set_pending_IRQ(OFFLOAD_SW_IRQ);
posix_irq_disable(OFFLOAD_SW_IRQ); posix_irq_disable(OFFLOAD_SW_IRQ);
} }
#endif
/** /**
* Replacement for ARMs NVIC_SetPendingIRQ() * Replacement for ARMs NVIC_SetPendingIRQ()

View file

@ -9,6 +9,8 @@
#ifndef ZEPHYR_INCLUDE_ARCH_CPU_H_ #ifndef ZEPHYR_INCLUDE_ARCH_CPU_H_
#define ZEPHYR_INCLUDE_ARCH_CPU_H_ #define ZEPHYR_INCLUDE_ARCH_CPU_H_
#include <sys/arch_inlines.h>
#if defined(CONFIG_X86) #if defined(CONFIG_X86)
#include <arch/x86/arch.h> #include <arch/x86/arch.h>
#elif defined(CONFIG_X86_64) #elif defined(CONFIG_X86_64)

View file

@ -56,35 +56,6 @@ static ALWAYS_INLINE void z_arch_nop(void)
__asm__ volatile("nop"); __asm__ volatile("nop");
} }
static ALWAYS_INLINE unsigned int z_arch_irq_lock(void)
{
return posix_irq_lock();
}
static ALWAYS_INLINE void z_arch_irq_unlock(unsigned int key)
{
posix_irq_unlock(key);
}
static ALWAYS_INLINE void z_arch_irq_enable(unsigned int irq)
{
posix_irq_enable(irq);
}
static ALWAYS_INLINE void z_arch_irq_disable(unsigned int irq)
{
posix_irq_disable(irq);
}
static ALWAYS_INLINE int z_arch_irq_is_enabled(unsigned int irq)
{
return posix_irq_is_enabled(irq);
}
/**
* Returns true if interrupts were unlocked prior to the
* z_arch_irq_lock() call that produced the key argument.
*/
static ALWAYS_INLINE bool z_arch_irq_unlocked(unsigned int key) static ALWAYS_INLINE bool z_arch_irq_unlocked(unsigned int key)
{ {
return key == false; return key == false;

View file

@ -21,6 +21,7 @@
#include <stdbool.h> #include <stdbool.h>
#include <arch/common/ffs.h> #include <arch/common/ffs.h>
#include <misc/util.h> #include <misc/util.h>
#include <arch/x86/ia32/syscall.h>
#ifndef _ASMLANGUAGE #ifndef _ASMLANGUAGE
#include <stddef.h> /* for size_t */ #include <stddef.h> /* for size_t */

View file

@ -50,10 +50,6 @@ extern "C" {
#define IRQ_CONNECT(irq_p, priority_p, isr_p, isr_param_p, flags_p) \ #define IRQ_CONNECT(irq_p, priority_p, isr_p, isr_param_p, flags_p) \
Z_ARCH_IRQ_CONNECT(irq_p, priority_p, isr_p, isr_param_p, flags_p) Z_ARCH_IRQ_CONNECT(irq_p, priority_p, isr_p, isr_param_p, flags_p)
extern int z_arch_irq_connect_dynamic(unsigned int irq, unsigned int priority,
void (*routine)(void *parameter), void *parameter,
u32_t flags);
/** /**
* Configure a dynamic interrupt. * Configure a dynamic interrupt.
* *

View file

@ -15,10 +15,9 @@
extern "C" { extern "C" {
#endif #endif
typedef void (*irq_offload_routine_t)(void *parameter); #include <arch/cpu.h>
void z_arch_irq_offload(irq_offload_routine_t routine, void *parameter);
#ifdef CONFIG_IRQ_OFFLOAD
/** /**
* @brief Run a function in interrupt context * @brief Run a function in interrupt context
* *
@ -35,6 +34,7 @@ static inline void irq_offload(irq_offload_routine_t routine, void *parameter)
{ {
z_arch_irq_offload(routine, parameter); z_arch_irq_offload(routine, parameter);
} }
#endif
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -1814,7 +1814,10 @@ static inline u32_t k_uptime_delta_32(s64_t *reftime)
* *
* @return Current hardware clock up-counter (in cycles). * @return Current hardware clock up-counter (in cycles).
*/ */
#define k_cycle_get_32() z_arch_k_cycle_get_32() static inline u32_t k_cycle_get_32(void)
{
return z_arch_k_cycle_get_32();
}
/** /**
* @} * @}
@ -4747,10 +4750,6 @@ extern void z_handle_obj_poll_events(sys_dlist_t *events, u32_t state);
* @ingroup kernel_apis * @ingroup kernel_apis
* @{ * @{
*/ */
extern void z_arch_cpu_idle(void);
extern void z_arch_cpu_atomic_idle(unsigned int key);
/** /**
* @brief Make the CPU idle. * @brief Make the CPU idle.
* *
@ -5162,10 +5161,6 @@ extern void k_mem_domain_remove_thread(k_tid_t thread);
*/ */
__syscall void k_str_out(char *c, size_t n); __syscall void k_str_out(char *c, size_t n);
extern void z_arch_start_cpu(int cpu_num, k_thread_stack_t *stack, int sz,
void (*fn)(int key, void *data), void *arg);
/** /**
* @brief Disable preservation of floating point context information. * @brief Disable preservation of floating point context information.
* *

View file

@ -86,45 +86,6 @@ extern "C" {
typedef u32_t (*_k_syscall_handler_t)(u32_t arg1, u32_t arg2, u32_t arg3, typedef u32_t (*_k_syscall_handler_t)(u32_t arg1, u32_t arg2, u32_t arg3,
u32_t arg4, u32_t arg5, u32_t arg6, u32_t arg4, u32_t arg5, u32_t arg6,
void *ssf); void *ssf);
#ifdef CONFIG_USERSPACE
/*
* Interfaces for invoking system calls
*/
static inline u32_t z_arch_syscall_invoke0(u32_t call_id);
static inline u32_t z_arch_syscall_invoke1(u32_t arg1, u32_t call_id);
static inline u32_t z_arch_syscall_invoke2(u32_t arg1, u32_t arg2,
u32_t call_id);
static inline u32_t z_arch_syscall_invoke3(u32_t arg1, u32_t arg2, u32_t arg3,
u32_t call_id);
static inline u32_t z_arch_syscall_invoke4(u32_t arg1, u32_t arg2, u32_t arg3,
u32_t arg4, u32_t call_id);
static inline u32_t z_arch_syscall_invoke5(u32_t arg1, u32_t arg2, u32_t arg3,
u32_t arg4, u32_t arg5,
u32_t call_id);
static inline u32_t z_arch_syscall_invoke6(u32_t arg1, u32_t arg2, u32_t arg3,
u32_t arg4, u32_t arg5, u32_t arg6,
u32_t call_id);
#endif /* CONFIG_USERSPACE */
/**
* Indicate whether we are currently running in user mode
*
* @return true if the CPU is currently running with user permissions
*/
#ifdef CONFIG_USERSPACE
static inline bool z_arch_is_user_context(void);
#else
#define z_arch_is_user_context() (true)
#endif
/* True if a syscall function must trap to the kernel, usually a /* True if a syscall function must trap to the kernel, usually a
* compile-time decision. * compile-time decision.

View file

@ -39,48 +39,13 @@ FUNC_NORETURN void z_cstart(void);
extern FUNC_NORETURN void z_thread_entry(k_thread_entry_t entry, extern FUNC_NORETURN void z_thread_entry(k_thread_entry_t entry,
void *p1, void *p2, void *p3); void *p1, void *p2, void *p3);
/* Implemented by architectures. Only called from z_setup_new_thread. */
extern void z_arch_new_thread(struct k_thread *thread, k_thread_stack_t *pStack,
size_t stackSize, k_thread_entry_t entry,
void *p1, void *p2, void *p3,
int prio, unsigned int options);
extern void z_setup_new_thread(struct k_thread *new_thread, extern void z_setup_new_thread(struct k_thread *new_thread,
k_thread_stack_t *stack, size_t stack_size, k_thread_stack_t *stack, size_t stack_size,
k_thread_entry_t entry, k_thread_entry_t entry,
void *p1, void *p2, void *p3, void *p1, void *p2, void *p3,
int prio, u32_t options, const char *name); int prio, u32_t options, const char *name);
#if defined(CONFIG_FLOAT) && defined(CONFIG_FP_SHARING)
extern int z_arch_float_disable(struct k_thread *thread);
#endif /* CONFIG_FLOAT && CONFIG_FP_SHARING */
#ifdef CONFIG_USERSPACE #ifdef CONFIG_USERSPACE
extern int z_arch_mem_domain_max_partitions_get(void);
extern void z_arch_mem_domain_thread_add(struct k_thread *thread);
extern void z_arch_mem_domain_thread_remove(struct k_thread *thread);
extern void z_arch_mem_domain_partition_remove(struct k_mem_domain *domain,
u32_t partition_id);
extern void z_arch_mem_domain_partition_add(struct k_mem_domain *domain,
u32_t partition_id);
extern void z_arch_mem_domain_destroy(struct k_mem_domain *domain);
extern int z_arch_buffer_validate(void *addr, size_t size, int write);
extern FUNC_NORETURN
void z_arch_user_mode_enter(k_thread_entry_t user_entry, void *p1, void *p2,
void *p3);
extern FUNC_NORETURN void z_arch_syscall_oops(void *ssf);
extern size_t z_arch_user_string_nlen(const char *s, size_t maxsize, int *err);
/** /**
* @brief Zero out BSS sections for application shared memory * @brief Zero out BSS sections for application shared memory
* *
@ -128,27 +93,6 @@ extern u32_t z_early_boot_rand32_get(void);
extern int z_stack_adjust_initialized; extern int z_stack_adjust_initialized;
#endif #endif
#if defined(CONFIG_ARCH_HAS_CUSTOM_BUSY_WAIT)
extern void z_arch_busy_wait(u32_t usec_to_wait);
#endif
int z_arch_swap(unsigned int key);
extern FUNC_NORETURN void z_arch_system_halt(unsigned int reason);
#ifdef CONFIG_EXECUTION_BENCHMARKING
extern u64_t z_arch_timing_swap_start;
extern u64_t z_arch_timing_swap_end;
extern u64_t z_arch_timing_irq_start;
extern u64_t z_arch_timing_irq_end;
extern u64_t z_arch_timing_tick_start;
extern u64_t z_arch_timing_tick_end;
extern u64_t z_arch_timing_user_mode_end;
extern u32_t z_arch_timing_value_swap_end;
extern u64_t z_arch_timing_value_swap_common;
extern u64_t z_arch_timing_value_swap_temp;
#endif /* CONFIG_EXECUTION_BENCHMARKING */
#ifdef CONFIG_BOOT_TIME_MEASUREMENT #ifdef CONFIG_BOOT_TIME_MEASUREMENT
extern u32_t z_timestamp_main; /* timestamp when main task starts */ extern u32_t z_timestamp_main; /* timestamp when main task starts */
extern u32_t z_timestamp_idle; /* timestamp when CPU goes idle */ extern u32_t z_timestamp_idle; /* timestamp when CPU goes idle */

View file

@ -15,6 +15,7 @@
#include <sys/rb.h> #include <sys/rb.h>
#include <sys/util.h> #include <sys/util.h>
#include <string.h> #include <string.h>
#include <sys/arch_interface.h>
#endif #endif
#define K_NUM_PRIORITIES \ #define K_NUM_PRIORITIES \