kernel: Add kswap.h header to unbreak cycles
The xtensa-asm2 work included a patch that added nano_internal.h includes in lots of places that needed to have _Swap defined, because it had to break a cycle and this no longer got pulled in from the arch headers. Unfortunately those new includes created new and more amusing cycles elsewhere which led to breakage on other platforms. Break out the _Swap definition (only) into a separate header and use that instead. Cleaner. Seems not to have any more hidden gotchas. Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
This commit is contained in:
parent
73678c4388
commit
9c62cc677d
25 changed files with 94 additions and 75 deletions
|
@ -21,6 +21,7 @@
|
||||||
#include <toolchain.h>
|
#include <toolchain.h>
|
||||||
#include <linker/sections.h>
|
#include <linker/sections.h>
|
||||||
#include <ksched.h>
|
#include <ksched.h>
|
||||||
|
#include <kswap.h>
|
||||||
#include <wait_q.h>
|
#include <wait_q.h>
|
||||||
#include <misc/__assert.h>
|
#include <misc/__assert.h>
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,7 @@
|
||||||
#include "kernel_internal.h"
|
#include "kernel_internal.h"
|
||||||
#include "kernel_structs.h"
|
#include "kernel_structs.h"
|
||||||
#include "ksched.h"
|
#include "ksched.h"
|
||||||
|
#include "kswap.h"
|
||||||
|
|
||||||
#define PREFIX "POSIX arch core: "
|
#define PREFIX "POSIX arch core: "
|
||||||
#define ERPREFIX PREFIX"error on "
|
#define ERPREFIX PREFIX"error on "
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include <misc/printk.h>
|
#include <misc/printk.h>
|
||||||
#include <irq.h>
|
#include <irq.h>
|
||||||
#include <logging/kernel_event_logger.h>
|
#include <logging/kernel_event_logger.h>
|
||||||
|
#include <kswap.h>
|
||||||
|
|
||||||
extern void _SpuriousIntHandler(void *);
|
extern void _SpuriousIntHandler(void *);
|
||||||
extern void _SpuriousIntNoErrCodeHandler(void *);
|
extern void _SpuriousIntNoErrCodeHandler(void *);
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include <ksched.h>
|
#include <ksched.h>
|
||||||
#include <kernel_structs.h>
|
#include <kernel_structs.h>
|
||||||
#include <nano_internal.h>
|
#include <nano_internal.h>
|
||||||
|
#include <kswap.h>
|
||||||
#include <_soc_inthandlers.h>
|
#include <_soc_inthandlers.h>
|
||||||
|
|
||||||
void *xtensa_init_stack(int *stack_top,
|
void *xtensa_init_stack(int *stack_top,
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include "irq_offload.h"
|
#include "irq_offload.h"
|
||||||
#include "kernel_structs.h"
|
#include "kernel_structs.h"
|
||||||
#include "kernel_internal.h"
|
#include "kernel_internal.h"
|
||||||
|
#include "kswap.h"
|
||||||
#include "irq_ctrl.h"
|
#include "irq_ctrl.h"
|
||||||
#include "posix_core.h"
|
#include "posix_core.h"
|
||||||
#include "board_soc.h"
|
#include "board_soc.h"
|
||||||
|
|
|
@ -15,8 +15,6 @@
|
||||||
#define _NANO_INTERNAL__H_
|
#define _NANO_INTERNAL__H_
|
||||||
|
|
||||||
#include <kernel.h>
|
#include <kernel.h>
|
||||||
#include <kernel_structs.h>
|
|
||||||
#include <ksched.h>
|
|
||||||
|
|
||||||
#ifndef _ASMLANGUAGE
|
#ifndef _ASMLANGUAGE
|
||||||
|
|
||||||
|
@ -52,65 +50,6 @@ extern void _setup_new_thread(struct k_thread *new_thread,
|
||||||
void *p1, void *p2, void *p3,
|
void *p1, void *p2, void *p3,
|
||||||
int prio, u32_t options);
|
int prio, u32_t options);
|
||||||
|
|
||||||
#ifdef CONFIG_TIMESLICING
|
|
||||||
extern void _update_time_slice_before_swap(void);
|
|
||||||
#else
|
|
||||||
#define _update_time_slice_before_swap() /**/
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_STACK_SENTINEL
|
|
||||||
extern void _check_stack_sentinel(void);
|
|
||||||
#else
|
|
||||||
#define _check_stack_sentinel() /**/
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* context switching and scheduling-related routines */
|
|
||||||
#ifdef CONFIG_USE_SWITCH
|
|
||||||
|
|
||||||
/* New style context switching. _arch_switch() is a lower level
|
|
||||||
* primitive that doesn't know about the scheduler or return value.
|
|
||||||
* Needed for SMP, where the scheduler requires spinlocking that we
|
|
||||||
* don't want to have to do in per-architecture assembly.
|
|
||||||
*/
|
|
||||||
static inline unsigned int _Swap(unsigned int key)
|
|
||||||
{
|
|
||||||
struct k_thread *new_thread, *old_thread;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
old_thread = _kernel.current;
|
|
||||||
|
|
||||||
_check_stack_sentinel();
|
|
||||||
_update_time_slice_before_swap();
|
|
||||||
|
|
||||||
new_thread = _get_next_ready_thread();
|
|
||||||
|
|
||||||
old_thread->swap_retval = -EAGAIN;
|
|
||||||
|
|
||||||
_kernel.current = new_thread;
|
|
||||||
_arch_switch(new_thread->switch_handle,
|
|
||||||
&old_thread->switch_handle);
|
|
||||||
|
|
||||||
ret = _kernel.current->swap_retval;
|
|
||||||
|
|
||||||
irq_unlock(key);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else /* !CONFIG_USE_SWITCH */
|
|
||||||
|
|
||||||
extern unsigned int __swap(unsigned int key);
|
|
||||||
|
|
||||||
static inline unsigned int _Swap(unsigned int key)
|
|
||||||
{
|
|
||||||
_check_stack_sentinel();
|
|
||||||
_update_time_slice_before_swap();
|
|
||||||
|
|
||||||
return __swap(key);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef CONFIG_USERSPACE
|
#ifdef CONFIG_USERSPACE
|
||||||
/**
|
/**
|
||||||
* @brief Get the maximum number of partitions for a memory domain
|
* @brief Get the maximum number of partitions for a memory domain
|
||||||
|
|
70
kernel/include/kswap.h
Normal file
70
kernel/include/kswap.h
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2018 Intel Corporation
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
#ifndef _KSWAP_H
|
||||||
|
#define _KSWAP_H
|
||||||
|
|
||||||
|
#include <ksched.h>
|
||||||
|
#include <kernel_arch_func.h>
|
||||||
|
|
||||||
|
#ifdef CONFIG_TIMESLICING
|
||||||
|
extern void _update_time_slice_before_swap(void);
|
||||||
|
#else
|
||||||
|
#define _update_time_slice_before_swap() /**/
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_STACK_SENTINEL
|
||||||
|
extern void _check_stack_sentinel(void);
|
||||||
|
#else
|
||||||
|
#define _check_stack_sentinel() /**/
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* context switching and scheduling-related routines */
|
||||||
|
#ifdef CONFIG_USE_SWITCH
|
||||||
|
|
||||||
|
/* New style context switching. _arch_switch() is a lower level
|
||||||
|
* primitive that doesn't know about the scheduler or return value.
|
||||||
|
* Needed for SMP, where the scheduler requires spinlocking that we
|
||||||
|
* don't want to have to do in per-architecture assembly.
|
||||||
|
*/
|
||||||
|
static inline unsigned int _Swap(unsigned int key)
|
||||||
|
{
|
||||||
|
struct k_thread *new_thread, *old_thread;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
old_thread = _kernel.current;
|
||||||
|
|
||||||
|
_check_stack_sentinel();
|
||||||
|
_update_time_slice_before_swap();
|
||||||
|
|
||||||
|
new_thread = _get_next_ready_thread();
|
||||||
|
|
||||||
|
old_thread->swap_retval = -EAGAIN;
|
||||||
|
|
||||||
|
_kernel.current = new_thread;
|
||||||
|
_arch_switch(new_thread->switch_handle,
|
||||||
|
&old_thread->switch_handle);
|
||||||
|
|
||||||
|
ret =_kernel.current->swap_retval;
|
||||||
|
|
||||||
|
irq_unlock(key);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else /* !CONFIG_USE_SWITCH */
|
||||||
|
|
||||||
|
extern unsigned int __swap(unsigned int key);
|
||||||
|
|
||||||
|
static inline unsigned int _Swap(unsigned int key)
|
||||||
|
{
|
||||||
|
_check_stack_sentinel();
|
||||||
|
_update_time_slice_before_swap();
|
||||||
|
|
||||||
|
return __swap(key);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _KSWAP_H */
|
|
@ -28,6 +28,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <misc/dlist.h>
|
#include <misc/dlist.h>
|
||||||
#include <nano_internal.h>
|
#include <nano_internal.h>
|
||||||
|
#include <kswap.h>
|
||||||
|
|
||||||
/* kernel build timestamp items */
|
/* kernel build timestamp items */
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
#include <wait_q.h>
|
#include <wait_q.h>
|
||||||
#include <misc/dlist.h>
|
#include <misc/dlist.h>
|
||||||
#include <init.h>
|
#include <init.h>
|
||||||
#include <nano_internal.h>
|
#include <kswap.h>
|
||||||
|
|
||||||
#if (CONFIG_NUM_MBOX_ASYNC_MSGS > 0)
|
#if (CONFIG_NUM_MBOX_ASYNC_MSGS > 0)
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
#include <misc/dlist.h>
|
#include <misc/dlist.h>
|
||||||
#include <ksched.h>
|
#include <ksched.h>
|
||||||
#include <init.h>
|
#include <init.h>
|
||||||
#include <nano_internal.h>
|
#include <kswap.h>
|
||||||
|
|
||||||
extern struct k_mem_slab _k_mem_slab_list_start[];
|
extern struct k_mem_slab _k_mem_slab_list_start[];
|
||||||
extern struct k_mem_slab _k_mem_slab_list_end[];
|
extern struct k_mem_slab _k_mem_slab_list_end[];
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
#include <init.h>
|
#include <init.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <misc/__assert.h>
|
#include <misc/__assert.h>
|
||||||
#include <nano_internal.h>
|
#include <kswap.h>
|
||||||
|
|
||||||
/* Linker-defined symbols bound the static pool structs */
|
/* Linker-defined symbols bound the static pool structs */
|
||||||
extern struct k_mem_pool _k_mem_pool_list_start[];
|
extern struct k_mem_pool _k_mem_pool_list_start[];
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#include <misc/dlist.h>
|
#include <misc/dlist.h>
|
||||||
#include <init.h>
|
#include <init.h>
|
||||||
#include <syscall_handler.h>
|
#include <syscall_handler.h>
|
||||||
#include <nano_internal.h>
|
#include <kswap.h>
|
||||||
|
|
||||||
extern struct k_msgq _k_msgq_list_start[];
|
extern struct k_msgq _k_msgq_list_start[];
|
||||||
extern struct k_msgq _k_msgq_list_end[];
|
extern struct k_msgq _k_msgq_list_end[];
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <init.h>
|
#include <init.h>
|
||||||
#include <syscall_handler.h>
|
#include <syscall_handler.h>
|
||||||
#include <nano_internal.h>
|
#include <kswap.h>
|
||||||
|
|
||||||
#define RECORD_STATE_CHANGE(mutex) do { } while ((0))
|
#define RECORD_STATE_CHANGE(mutex) do { } while ((0))
|
||||||
#define RECORD_CONFLICT(mutex) do { } while ((0))
|
#define RECORD_CONFLICT(mutex) do { } while ((0))
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
#include <misc/dlist.h>
|
#include <misc/dlist.h>
|
||||||
#include <init.h>
|
#include <init.h>
|
||||||
#include <syscall_handler.h>
|
#include <syscall_handler.h>
|
||||||
#include <nano_internal.h>
|
#include <kswap.h>
|
||||||
|
|
||||||
struct k_pipe_desc {
|
struct k_pipe_desc {
|
||||||
unsigned char *buffer; /* Position in src/dest buffer */
|
unsigned char *buffer; /* Position in src/dest buffer */
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include <nano_internal.h>
|
#include <nano_internal.h>
|
||||||
#include <wait_q.h>
|
#include <wait_q.h>
|
||||||
#include <ksched.h>
|
#include <ksched.h>
|
||||||
|
#include <kswap.h>
|
||||||
#include <misc/slist.h>
|
#include <misc/slist.h>
|
||||||
#include <misc/dlist.h>
|
#include <misc/dlist.h>
|
||||||
#include <misc/__assert.h>
|
#include <misc/__assert.h>
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include "ksched.h"
|
#include "ksched.h"
|
||||||
#include "wait_q.h"
|
#include "wait_q.h"
|
||||||
#include <nano_internal.h>
|
#include <kswap.h>
|
||||||
|
|
||||||
void ready_one_thread(_wait_q_t *wq);
|
void ready_one_thread(_wait_q_t *wq);
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include "ksched.h"
|
#include "ksched.h"
|
||||||
#include "wait_q.h"
|
#include "wait_q.h"
|
||||||
#include <nano_internal.h>
|
#include <kswap.h>
|
||||||
|
|
||||||
void ready_one_thread(_wait_q_t *wq);
|
void ready_one_thread(_wait_q_t *wq);
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#include <ksched.h>
|
#include <ksched.h>
|
||||||
#include <misc/slist.h>
|
#include <misc/slist.h>
|
||||||
#include <init.h>
|
#include <init.h>
|
||||||
#include <nano_internal.h>
|
#include <kswap.h>
|
||||||
|
|
||||||
extern struct k_queue _k_queue_list_start[];
|
extern struct k_queue _k_queue_list_start[];
|
||||||
extern struct k_queue _k_queue_list_end[];
|
extern struct k_queue _k_queue_list_end[];
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
#include <wait_q.h>
|
#include <wait_q.h>
|
||||||
#include <misc/util.h>
|
#include <misc/util.h>
|
||||||
#include <syscall_handler.h>
|
#include <syscall_handler.h>
|
||||||
#include <nano_internal.h>
|
#include <kswap.h>
|
||||||
|
|
||||||
/* the only struct _kernel instance */
|
/* the only struct _kernel instance */
|
||||||
struct _kernel _kernel = {0};
|
struct _kernel _kernel = {0};
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
#include <ksched.h>
|
#include <ksched.h>
|
||||||
#include <init.h>
|
#include <init.h>
|
||||||
#include <syscall_handler.h>
|
#include <syscall_handler.h>
|
||||||
#include <nano_internal.h>
|
#include <kswap.h>
|
||||||
|
|
||||||
extern struct k_sem _k_sem_list_start[];
|
extern struct k_sem _k_sem_list_start[];
|
||||||
extern struct k_sem _k_sem_list_end[];
|
extern struct k_sem _k_sem_list_end[];
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
#include <misc/__assert.h>
|
#include <misc/__assert.h>
|
||||||
#include <init.h>
|
#include <init.h>
|
||||||
#include <syscall_handler.h>
|
#include <syscall_handler.h>
|
||||||
#include <nano_internal.h>
|
#include <kswap.h>
|
||||||
|
|
||||||
extern struct k_stack _k_stack_list_start[];
|
extern struct k_stack _k_stack_list_start[];
|
||||||
extern struct k_stack _k_stack_list_end[];
|
extern struct k_stack _k_stack_list_end[];
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include <atomic.h>
|
#include <atomic.h>
|
||||||
#include <syscall_handler.h>
|
#include <syscall_handler.h>
|
||||||
#include <nano_internal.h>
|
#include <nano_internal.h>
|
||||||
|
#include <kswap.h>
|
||||||
|
|
||||||
extern struct _static_thread_data _static_thread_data_list_start[];
|
extern struct _static_thread_data _static_thread_data_list_start[];
|
||||||
extern struct _static_thread_data _static_thread_data_list_end[];
|
extern struct _static_thread_data _static_thread_data_list_end[];
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
#include <kernel.h>
|
#include <kernel.h>
|
||||||
#include <kernel_structs.h>
|
#include <kernel_structs.h>
|
||||||
#include <kernel_internal.h>
|
#include <kernel_internal.h>
|
||||||
|
#include <nano_internal.h>
|
||||||
|
#include <kswap.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <toolchain.h>
|
#include <toolchain.h>
|
||||||
#include <linker/sections.h>
|
#include <linker/sections.h>
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
#include <init.h>
|
#include <init.h>
|
||||||
#include <wait_q.h>
|
#include <wait_q.h>
|
||||||
#include <syscall_handler.h>
|
#include <syscall_handler.h>
|
||||||
#include <nano_internal.h>
|
#include <kswap.h>
|
||||||
|
|
||||||
extern struct k_timer _k_timer_list_start[];
|
extern struct k_timer _k_timer_list_start[];
|
||||||
extern struct k_timer _k_timer_list_end[];
|
extern struct k_timer _k_timer_list_end[];
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
#include <tc_util.h>
|
#include <tc_util.h>
|
||||||
#include <kernel_structs.h>
|
#include <kernel_structs.h>
|
||||||
#include <irq_offload.h>
|
#include <irq_offload.h>
|
||||||
#include <nano_internal.h>
|
#include <kswap.h>
|
||||||
|
|
||||||
#if defined(CONFIG_X86) && defined(CONFIG_X86_MMU)
|
#if defined(CONFIG_X86) && defined(CONFIG_X86_MMU)
|
||||||
#define STACKSIZE (8192)
|
#define STACKSIZE (8192)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue