headers: Refactor kernel and arch headers.

This commit refactors kernel and arch headers to establish a boundary
between private and public interface headers.

The refactoring strategy used in this commit is detailed in the issue

This commit introduces the following major changes:

1. Establish a clear boundary between private and public headers by
  removing "kernel/include" and "arch/*/include" from the global
  include paths. Ideally, only kernel/ and arch/*/ source files should
  reference the headers in these directories. If these headers must be
  used by a component, these include paths shall be manually added to
  the CMakeLists.txt file of the component. This is intended to
  discourage applications from including private kernel and arch
  headers either knowingly and unknowingly.

  - kernel/include/ (PRIVATE)
    This directory contains the private headers that provide private
   kernel definitions which should not be visible outside the kernel
   and arch source code. All public kernel definitions must be added
   to an appropriate header located under include/.

  - arch/*/include/ (PRIVATE)
    This directory contains the private headers that provide private
   architecture-specific definitions which should not be visible
   outside the arch and kernel source code. All public architecture-
   specific definitions must be added to an appropriate header located
   under include/arch/*/.

  - include/ AND include/sys/ (PUBLIC)
    This directory contains the public headers that provide public
   kernel definitions which can be referenced by both kernel and
   application code.

  - include/arch/*/ (PUBLIC)
    This directory contains the public headers that provide public
   architecture-specific definitions which can be referenced by both
   kernel and application code.

2. Split arch_interface.h into "kernel-to-arch interface" and "public
  arch interface" divisions.

  - kernel/include/kernel_arch_interface.h
    * provides private "kernel-to-arch interface" definition.
    * includes arch/*/include/kernel_arch_func.h to ensure that the
     interface function implementations are always available.
    * includes sys/arch_interface.h so that public arch interface
     definitions are automatically included when including this file.

  - arch/*/include/kernel_arch_func.h
    * provides architecture-specific "kernel-to-arch interface"
     implementation.
    * only the functions that will be used in kernel and arch source
     files are defined here.

  - include/sys/arch_interface.h
    * provides "public arch interface" definition.
    * includes include/arch/arch_inlines.h to ensure that the
     architecture-specific public inline interface function
     implementations are always available.

  - include/arch/arch_inlines.h
    * includes architecture-specific arch_inlines.h in
     include/arch/*/arch_inline.h.

  - include/arch/*/arch_inline.h
    * provides architecture-specific "public arch interface" inline
     function implementation.
    * supersedes include/sys/arch_inline.h.

3. Refactor kernel and the existing architecture implementations.

  - Remove circular dependency of kernel and arch headers. The
   following general rules should be observed:

    * Never include any private headers from public headers
    * Never include kernel_internal.h in kernel_arch_data.h
    * Always include kernel_arch_data.h from kernel_arch_func.h
    * Never include kernel.h from kernel_struct.h either directly or
     indirectly. Only add the kernel structures that must be referenced
     from public arch headers in this file.

  - Relocate syscall_handler.h to include/ so it can be used in the
   public code. This is necessary because many user-mode public codes
   reference the functions defined in this header.

  - Relocate kernel_arch_thread.h to include/arch/*/thread.h. This is
   necessary to provide architecture-specific thread definition for
   'struct k_thread' in kernel.h.

  - Remove any private header dependencies from public headers using
   the following methods:

    * If dependency is not required, simply omit
    * If dependency is required,
      - Relocate a portion of the required dependencies from the
       private header to an appropriate public header OR
      - Relocate the required private header to make it public.

This commit supersedes #20047, addresses #19666, and fixes #3056.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
This commit is contained in:
Stephanos Ioannidis 2019-10-25 00:08:21 +09:00 committed by Andrew Boie
parent 8bb99dc9ce
commit 2d7460482d
244 changed files with 1542 additions and 1297 deletions

View file

@ -73,8 +73,6 @@ add_library(zephyr_interface INTERFACE)
zephyr_library_named(zephyr)
zephyr_include_directories(
kernel/include
${ARCH_DIR}/${ARCH}/include
include
include/drivers
${PROJECT_BINARY_DIR}/include/generated
@ -632,6 +630,10 @@ set(OFFSETS_C_PATH ${ARCH_DIR}/${ARCH}/core/offsets/offsets.c)
set(OFFSETS_H_PATH ${PROJECT_BINARY_DIR}/include/generated/offsets.h)
add_library( ${OFFSETS_LIB} OBJECT ${OFFSETS_C_PATH})
target_include_directories(${OFFSETS_LIB} PRIVATE
kernel/include
${ARCH_DIR}/${ARCH}/include
)
target_link_libraries(${OFFSETS_LIB} zephyr_interface)
add_dependencies( ${OFFSETS_LIB}
${SYSCALL_LIST_H_TARGET}

View file

@ -3,28 +3,35 @@
zephyr_library()
zephyr_library_sources(
thread.c
thread_entry_wrapper.S
cpu_idle.S
fatal.c
fault.c
fault_s.S
irq_manage.c
timestamp.c
isr_wrapper.S
regular_irq.S
switch.S
prep_c.c
reset.S
vector_table.c
)
thread.c
thread_entry_wrapper.S
cpu_idle.S
fatal.c
fault.c
fault_s.S
irq_manage.c
timestamp.c
isr_wrapper.S
regular_irq.S
switch.S
prep_c.c
reset.S
vector_table.c
)
zephyr_library_sources_ifdef(CONFIG_CACHE_FLUSHING cache.c)
zephyr_library_sources_ifdef(CONFIG_ARC_FIRQ fast_irq.S)
zephyr_library_sources_if_kconfig(irq_offload.c)
add_subdirectory_ifdef(CONFIG_ARC_CORE_MPU mpu)
add_subdirectory_ifdef(CONFIG_ARC_SECURE_FIRMWARE secureshield)
zephyr_library_sources_ifdef(CONFIG_USERSPACE userspace.S)
zephyr_library_sources_ifdef(CONFIG_ARC_CONNECT arc_connect.c)
zephyr_library_sources_ifdef(CONFIG_SMP arc_smp.c)
zephyr_library_include_directories(
${ZEPHYR_BASE}/kernel/include
${ZEPHYR_BASE}/arch/arc/include
)
add_subdirectory_ifdef(CONFIG_ARC_CORE_MPU mpu)
add_subdirectory_ifdef(CONFIG_ARC_SECURE_FIRMWARE secureshield)

View file

@ -16,6 +16,7 @@
#include <kernel_structs.h>
#include <offsets_short.h>
#include <toolchain.h>
#include <linker/sections.h>
#include <arch/cpu.h>
#include <swap_macros.h>

View file

@ -12,9 +12,8 @@
* ARCv2 CPUs.
*/
#include <kernel_structs.h>
#include <kernel.h>
#include <offsets_short.h>
#include <toolchain.h>
#include <arch/cpu.h>
#include <logging/log.h>
LOG_MODULE_DECLARE(os);

View file

@ -16,6 +16,7 @@
#include <inttypes.h>
#include <kernel.h>
#include <kernel_internal.h>
#include <kernel_structs.h>
#include <exc_handle.h>
#include <logging/log.h>

View file

@ -4,3 +4,8 @@ zephyr_library()
zephyr_library_sources_if_kconfig(arc_core_mpu.c)
zephyr_library_sources_if_kconfig(arc_mpu.c)
zephyr_library_include_directories(
${ZEPHYR_BASE}/kernel/include
${ZEPHYR_BASE}/arch/arc/include
)

View file

@ -22,8 +22,9 @@
* completeness.
*/
#include <kernel.h>
#include <kernel_arch_data.h>
#include <gen_offset.h>
#include <kernel_structs.h>
#include <kernel_offsets.h>
GEN_OFFSET_SYM(_thread_arch_t, relinquish_cause);

View file

@ -17,6 +17,7 @@
#include <kernel_structs.h>
#include <offsets_short.h>
#include <toolchain.h>
#include <linker/sections.h>
#include <arch/cpu.h>
#include <swap_macros.h>

View file

@ -6,7 +6,12 @@
zephyr_library()
zephyr_library_sources(
arc_sjli.c
arc_secure.S
secure_sys_services.c
)
arc_sjli.c
arc_secure.S
secure_sys_services.c
)
zephyr_library_include_directories(
${ZEPHYR_BASE}/kernel/include
${ZEPHYR_BASE}/arch/arc/include
)

View file

@ -17,6 +17,7 @@
#include <kernel_structs.h>
#include <offsets_short.h>
#include <toolchain.h>
#include <linker/sections.h>
#include <arch/cpu.h>
#include <v2/irq.h>
#include <swap_macros.h>

View file

@ -12,8 +12,7 @@
*/
#include <kernel.h>
#include <toolchain.h>
#include <kernel_structs.h>
#include <ksched.h>
#include <offsets_short.h>
#include <wait_q.h>

View file

@ -24,11 +24,9 @@
#include <linker/sections.h>
#include <arch/cpu.h>
#include <vector_table.h>
#include <kernel_arch_thread.h>
#ifndef _ASMLANGUAGE
#include <kernel.h>
#include <kernel_internal.h>
#include <zephyr/types.h>
#include <sys/util.h>
#include <sys/dlist.h>

View file

@ -22,6 +22,8 @@
#if !defined(_ASMLANGUAGE)
#include <kernel_arch_data.h>
#ifdef CONFIG_CPU_ARCV2
#include <v2/cache.h>
#include <v2/irq.h>
@ -31,19 +33,6 @@
extern "C" {
#endif
static ALWAYS_INLINE _cpu_t *z_arch_curr_cpu(void)
{
#ifdef CONFIG_SMP
u32_t core;
core = z_arc_v2_core_id();
return &_kernel.cpus[core];
#else
return &_kernel.cpus[0];
#endif
}
static ALWAYS_INLINE void z_arch_kernel_init(void)
{
z_irq_setup();

View file

@ -20,6 +20,11 @@ zephyr_library_sources(
prep_c.c
)
zephyr_library_include_directories(
${ZEPHYR_BASE}/kernel/include
${ZEPHYR_BASE}/arch/arm/include
)
zephyr_library_sources_ifdef(CONFIG_GEN_SW_ISR_TABLE isr_wrapper.S)
zephyr_library_sources_ifdef(CONFIG_CPLUSPLUS __aeabi_atexit.c)
zephyr_library_sources_ifdef(CONFIG_IRQ_OFFLOAD irq_offload.c)

View file

@ -15,3 +15,8 @@ zephyr_linker_sources_ifdef(CONFIG_SW_VECTOR_RELAY
RAM_SECTIONS
vt_pointer_section.ld
)
zephyr_library_include_directories(
${ZEPHYR_BASE}/kernel/include
${ZEPHYR_BASE}/arch/arm/include
)

View file

@ -11,11 +11,8 @@
* Common fault handler for ARM Cortex-M processors.
*/
#include <toolchain.h>
#include <linker/sections.h>
#include <kernel.h>
#include <kernel_structs.h>
#include <kernel_internal.h>
#include <inttypes.h>
#include <exc_handle.h>
#include <logging/log.h>

View file

@ -17,7 +17,6 @@
*/
#include <kernel.h>
#include <kernel_structs.h>
#include <toolchain.h>
#include <linker/sections.h>
#include <ksched.h>

View file

@ -9,3 +9,8 @@ zephyr_library_sources(
reboot.c
stacks.c
)
zephyr_library_include_directories(
${ZEPHYR_BASE}/kernel/include
${ZEPHYR_BASE}/arch/arm/include
)

View file

@ -5,6 +5,7 @@
*/
#include <kernel.h>
#include <kernel_internal.h>
#include <kernel_structs.h>
/**

View file

@ -12,12 +12,7 @@
* and Cortex-R CPUs.
*/
#include <toolchain.h>
#include <linker/sections.h>
#include <inttypes.h>
#include <kernel.h>
#include <kernel_structs.h>
#include <logging/log.h>
LOG_MODULE_DECLARE(os);

View file

@ -27,7 +27,6 @@
#include <linker/sections.h>
#include <sw_isr_table.h>
#include <irq.h>
#include <kernel_structs.h>
#include <debug/tracing.h>
extern void z_arm_reserved(void);

View file

@ -22,8 +22,9 @@
* completeness.
*/
#include <kernel.h>
#include <kernel_arch_data.h>
#include <gen_offset.h>
#include <kernel_structs.h>
#include <kernel_offsets.h>
GEN_OFFSET_SYM(_thread_arch_t, basepri);

View file

@ -17,14 +17,10 @@
*/
#include <kernel.h>
#include <zephyr/types.h>
#include <toolchain.h>
#include <linker/linker-defs.h>
#include <kernel_internal.h>
#include <arch/cpu.h>
#if defined(CONFIG_CPU_CORTEX_M)
#include <arch/arm/cortex_m/cmsis.h>
#elif defined(CONFIG_ARMV7_R)
#include <linker/linker-defs.h>
#if defined(CONFIG_ARMV7_R)
#include <cortex_r/stack.h>
#endif

View file

@ -5,8 +5,7 @@
*/
#include <kernel.h>
#include <toolchain.h>
#include <kernel_structs.h>
#include <kernel_internal.h>
#ifdef CONFIG_EXECUTION_BENCHMARKING
extern void read_timer_start_of_swap(void);

View file

@ -13,8 +13,7 @@
*/
#include <kernel.h>
#include <toolchain.h>
#include <kernel_structs.h>
#include <ksched.h>
#include <wait_q.h>
#ifdef CONFIG_USERSPACE

View file

@ -23,7 +23,6 @@
#include <toolchain.h>
#include <linker/sections.h>
#include <arch/cpu.h>
#include <kernel_arch_thread.h>
/* stacks */
@ -40,7 +39,6 @@
#ifndef _ASMLANGUAGE
#include <kernel.h>
#include <kernel_internal.h>
#include <zephyr/types.h>
#include <sys/dlist.h>
#include <sys/atomic.h>

View file

@ -17,11 +17,11 @@
* in the offsets.o module.
*/
/* this file is only meant to be included by kernel_structs.h */
#ifndef ZEPHYR_ARCH_ARM_INCLUDE_KERNEL_ARCH_FUNC_H_
#define ZEPHYR_ARCH_ARM_INCLUDE_KERNEL_ARCH_FUNC_H_
#include <kernel_arch_data.h>
#ifdef __cplusplus
extern "C" {
#endif

View file

@ -29,3 +29,8 @@ zephyr_linker_sources_ifdef(CONFIG_NOCACHE_MEMORY
RAM_SECTIONS
nocache.ld
)
zephyr_library_include_directories(
${ZEPHYR_BASE}/kernel/include
${ZEPHYR_BASE}/arch/${ARCH}/include
)

View file

@ -1,16 +1,23 @@
# SPDX-License-Identifier: Apache-2.0
zephyr_sources(
thread.c
cpu_idle.c
fatal.c
irq_manage.c
swap.S
prep_c.c
reset.S
cache.c
exception.S
crt0.S
)
zephyr_library()
zephyr_sources_if_kconfig(irq_offload.c)
zephyr_library_sources(
thread.c
cpu_idle.c
fatal.c
irq_manage.c
swap.S
prep_c.c
reset.S
cache.c
exception.S
crt0.S
)
zephyr_library_sources_if_kconfig(irq_offload.c)
zephyr_library_include_directories(
${ZEPHYR_BASE}/kernel/include
${ZEPHYR_BASE}/arch/nios2/include
)

View file

@ -4,7 +4,8 @@
* SPDX-License-Identifier: Apache-2.0
*/
#include <kernel_structs.h>
#include <toolchain.h>
#include <linker/sections.h>
/* exports */
GTEXT(__start)

View file

@ -4,7 +4,8 @@
* SPDX-License-Identifier: Apache-2.0
*/
#include <kernel_structs.h>
#include <toolchain.h>
#include <linker/sections.h>
#include <offsets_short.h>
/* exports */

View file

@ -24,8 +24,9 @@
*/
#include <kernel.h>
#include <kernel_arch_data.h>
#include <gen_offset.h>
#include <kernel_structs.h>
#include <kernel_offsets.h>
/* struct coop member offsets */

View file

@ -4,9 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
#include <arch/cpu.h>
#include <kernel_structs.h>
#include <offsets_short.h>
#include <toolchain.h>
GTEXT(__start)

View file

@ -4,7 +4,8 @@
* SPDX-License-Identifier: Apache-2.0
*/
#include <kernel_structs.h>
#include <toolchain.h>
#include <linker/sections.h>
#include <offsets_short.h>
/* exports */

View file

@ -5,10 +5,7 @@
*/
#include <kernel.h>
#include <kernel_internal.h>
#include <kernel_structs.h>
#include <wait_q.h>
#include <string.h>
#include <ksched.h>
/* forward declaration to asm function to adjust setup the arguments
* to z_thread_entry() since this arch puts the first four arguments

View file

@ -24,7 +24,6 @@
#include <toolchain.h>
#include <linker/sections.h>
#include <arch/cpu.h>
#include <kernel_arch_thread.h>
/* stacks */
@ -36,7 +35,6 @@
#ifndef _ASMLANGUAGE
#include <kernel.h>
#include <kernel_internal.h>
#include <zephyr/types.h>
#include <sys/util.h>
#include <sys/dlist.h>

View file

@ -20,6 +20,8 @@
#ifndef ZEPHYR_ARCH_NIOS2_INCLUDE_KERNEL_ARCH_FUNC_H_
#define ZEPHYR_ARCH_NIOS2_INCLUDE_KERNEL_ARCH_FUNC_H_
#include <kernel_arch_data.h>
#ifdef __cplusplus
extern "C" {
#endif

View file

@ -21,7 +21,7 @@
*/
#include "posix_core.h"
#include "posix_soc_if.h"
#include <arch/posix/posix_soc_if.h>
#include <debug/tracing.h>
void z_arch_cpu_idle(void)

View file

@ -11,7 +11,7 @@
#include <sys/printk.h>
#include <inttypes.h>
#include <logging/log_ctrl.h>
#include "posix_soc_if.h"
#include <arch/posix/posix_soc_if.h>
FUNC_NORETURN void z_arch_system_halt(unsigned int reason)
{

View file

@ -4,7 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
#include "posix_soc_if.h"
#include <arch/posix/posix_soc_if.h>
#include "board_irq.h"
#ifdef CONFIG_IRQ_OFFLOAD

View file

@ -23,18 +23,13 @@
* completeness.
*/
#include <gen_offset.h> /* located in kernel/include */
/* list of headers that define whose structure offsets will be generated */
#include <kernel_structs.h>
#include <kernel.h>
#include <kernel_arch_data.h>
#include <gen_offset.h>
#include <kernel_offsets.h>
#if defined(CONFIG_FP_SHARING)
GEN_OFFSET_SYM(_thread_arch_t, excNestCount);
#endif
GEN_ABS_SYM_END

View file

@ -44,7 +44,7 @@
#include "posix_core.h"
#include "posix_arch_internal.h"
#include "posix_soc_if.h"
#include <arch/posix/posix_soc_if.h>
#include "kernel_internal.h"
#include "kernel_structs.h"
#include "ksched.h"

View file

@ -15,10 +15,11 @@
#include <toolchain.h>
#include <kernel_structs.h>
#include <ksched.h>
#include <wait_q.h>
#include "posix_core.h"
#include "posix_soc_if.h"
#include <arch/posix/posix_soc_if.h>
/* Note that in this arch we cheat quite a bit: we use as stack a normal
* pthreads stack and therefore we ignore the stack size

View file

@ -14,8 +14,6 @@
#ifndef ZEPHYR_ARCH_POSIX_INCLUDE_KERNEL_ARCH_DATA_H_
#define ZEPHYR_ARCH_POSIX_INCLUDE_KERNEL_ARCH_DATA_H_
#include <kernel_internal.h>
/* stacks */
#define STACK_ROUND_UP(x) ROUND_UP(x, STACK_ALIGN_SIZE)
#define STACK_ROUND_DOWN(x) ROUND_DOWN(x, STACK_ALIGN_SIZE)

View file

@ -10,9 +10,7 @@
#ifndef ZEPHYR_ARCH_POSIX_INCLUDE_KERNEL_ARCH_FUNC_H_
#define ZEPHYR_ARCH_POSIX_INCLUDE_KERNEL_ARCH_FUNC_H_
#include "kernel.h"
#include <toolchain/common.h>
#include "posix_core.h"
#include <kernel_arch_data.h>
#ifndef _ASMLANGUAGE

View file

@ -1,6 +1,8 @@
# SPDX-License-Identifier: Apache-2.0
zephyr_sources(
zephyr_library()
zephyr_library_sources(
cpu_idle.c
fatal.c
irq_manage.c
@ -11,4 +13,9 @@ zephyr_sources(
thread.c
)
zephyr_sources_if_kconfig(irq_offload.c)
zephyr_library_sources_if_kconfig(irq_offload.c)
zephyr_library_include_directories(
${ZEPHYR_BASE}/kernel/include
${ZEPHYR_BASE}/arch/riscv/include
)

View file

@ -4,8 +4,8 @@
* SPDX-License-Identifier: Apache-2.0
*/
#include <toolchain.h>
#include <kernel_structs.h>
#include <kernel.h>
#include <kernel_internal.h>
#include <logging/log.h>
LOG_MODULE_DECLARE(os);

View file

@ -7,8 +7,8 @@
#include <toolchain.h>
#include <linker/sections.h>
#include <kernel_structs.h>
#include <offsets_short.h>
#include <arch/cpu.h>
/* imports */
GDATA(_sw_isr_table)

View file

@ -13,8 +13,9 @@
* structures.
*/
#include <kernel.h>
#include <kernel_arch_data.h>
#include <gen_offset.h>
#include <kernel_structs.h>
#include <kernel_offsets.h>
#ifdef CONFIG_RISCV_SOC_CONTEXT_SAVE

View file

@ -5,7 +5,9 @@
* SPDX-License-Identifier: Apache-2.0
*/
#include <kernel_structs.h>
#include <toolchain.h>
#include <linker/sections.h>
#include <arch/cpu.h>
/* exports */
GTEXT(__initialize)

View file

@ -4,9 +4,10 @@
* SPDX-License-Identifier: Apache-2.0
*/
#include <irq.h>
#include <kernel_structs.h>
#include <toolchain.h>
#include <linker/sections.h>
#include <offsets_short.h>
#include <arch/cpu.h>
/* exports */
GTEXT(z_arch_swap)

View file

@ -5,10 +5,7 @@
*/
#include <kernel.h>
#include <arch/cpu.h>
#include <kernel_structs.h>
#include <wait_q.h>
#include <string.h>
#include <ksched.h>
void z_thread_entry_wrapper(k_thread_entry_t thread,
void *arg1,

View file

@ -18,14 +18,12 @@
#include <toolchain.h>
#include <linker/sections.h>
#include <arch/cpu.h>
#include <kernel_arch_thread.h>
#ifndef _ASMLANGUAGE
#include <kernel.h>
#include <zephyr/types.h>
#include <sys/util.h>
#include <sys/dlist.h>
#include <kernel_internal.h>
#ifdef __cplusplus
extern "C" {

View file

@ -15,7 +15,7 @@
#ifndef ZEPHYR_ARCH_RISCV_INCLUDE_KERNEL_ARCH_FUNC_H_
#define ZEPHYR_ARCH_RISCV_INCLUDE_KERNEL_ARCH_FUNC_H_
#include <soc.h>
#include <kernel_arch_data.h>
#ifdef __cplusplus
extern "C" {

View file

@ -19,6 +19,11 @@ zephyr_library_sources_if_kconfig(x86_mmu.c)
zephyr_library_sources_ifdef(CONFIG_X86_VERY_EARLY_CONSOLE early_serial.c)
zephyr_library_include_directories(
${ZEPHYR_BASE}/kernel/include
${ZEPHYR_BASE}/arch/x86/include
)
if(CONFIG_X86_64)
include(intel64.cmake)
else()

View file

@ -14,7 +14,6 @@
* and exiting a C exception handler.
*/
#include <kernel_structs.h>
#include <arch/x86/ia32/asm.h>
#include <arch/x86/ia32/arch.h> /* For MK_ISR_NAME */
#include <offsets_short.h>

View file

@ -9,11 +9,8 @@
* @brief Kernel fatal error handler
*/
#include <toolchain.h>
#include <linker/sections.h>
#include <kernel.h>
#include <kernel_structs.h>
#include <kernel_internal.h>
#include <drivers/interrupt_controller/sysapic.h>
#include <arch/x86/ia32/segmentation.h>
#include <ia32/exception.h>

View file

@ -43,8 +43,8 @@
* to enable FP register sharing on its behalf.
*/
#include <kernel_structs.h>
#include <toolchain.h>
#include <kernel.h>
#include <kernel_internal.h>
/* SSE control/status register default value (used by assembler code) */
extern u32_t _sse_mxcsr_default_value;

View file

@ -14,7 +14,6 @@
* entering and exiting a C interrupt handler.
*/
#include <kernel_structs.h>
#include <arch/x86/ia32/asm.h>
#include <offsets_short.h>
#include <arch/cpu.h>

View file

@ -11,8 +11,10 @@
* This module implements the z_arch_swap() routine for the IA-32 architecture.
*/
#include <kernel_structs.h>
#include <arch/x86/ia32/asm.h>
#include <kernel.h>
#include <arch/cpu.h>
#include <kernel_arch_data.h>
#include <offsets_short.h>
/* exports (internal APIs) */

View file

@ -12,12 +12,9 @@
* processor architecture.
*/
#include <toolchain.h>
#include <linker/sections.h>
#include <kernel_structs.h>
#include <wait_q.h>
#include <kernel.h>
#include <ksched.h>
#include <arch/x86/mmustructs.h>
#include <sys/printk.h>
/* forward declaration */

View file

@ -4,7 +4,6 @@
* SPDX-License-Identifier: Apache-2.0
*/
#include <kernel_structs.h>
#include <arch/x86/ia32/asm.h>
#include <arch/cpu.h>
#include <offsets_short.h>

View file

@ -26,8 +26,6 @@
#include <arch/x86/mmustructs.h>
#include <kernel_offsets.h>
#if defined(CONFIG_LAZY_FP_SHARING)
GEN_OFFSET_SYM(_thread_arch_t, excNestCount);
#endif

View file

@ -3,10 +3,6 @@
* SPDX-License-Identifier: Apache-2.0
*/
#include <kernel_arch_thread.h>
#include <kernel_offsets.h>
GEN_OFFSET_SYM(_callee_saved_t, rsp);
GEN_OFFSET_SYM(_callee_saved_t, rbp);
GEN_OFFSET_SYM(_callee_saved_t, rbx);

View file

@ -3,10 +3,10 @@
* SPDX-License-Identifier: Apache-2.0
*/
#include <gen_offset.h>
#include <kernel_structs.h>
#include <kernel.h>
#include <kernel_arch_data.h>
#include <arch/x86/multiboot.h>
#include <gen_offset.h>
#include <kernel_offsets.h>
#ifdef CONFIG_X86_64
#include "intel64_offsets.c"

View file

@ -4,7 +4,8 @@
* SPDX-License-Identifier: Apache-2.0
*/
#include <kernel_structs.h>
#include <kernel.h>
#include <kernel_internal.h>
#include <arch/x86/acpi.h>
#include <arch/x86/multiboot.h>

View file

@ -29,12 +29,10 @@
#include <toolchain.h>
#include <linker/sections.h>
#include <ia32/exception.h>
#include <kernel_arch_thread.h>
#include <sys/util.h>
#ifndef _ASMLANGUAGE
#include <kernel.h>
#include <kernel_internal.h>
#include <zephyr/types.h>
#include <sys/dlist.h>
#endif

View file

@ -8,78 +8,12 @@
#include <arch/x86/mmustructs.h>
/*
* Some SSE definitions. Ideally these will ultimately be shared with 32-bit.
*/
#define X86_FXSAVE_SIZE 512 /* size and alignment of buffer ... */
#define X86_FXSAVE_ALIGN 16 /* ... for FXSAVE/FXRSTOR ops */
#define X86_MXCSR_SANE 0x1dc0 /* enable division-by-zero exception */
/*
* GDT selectors - these must agree with the GDT layout in locore.S.
*/
#define X86_KERNEL_CS_32 0x08 /* 32-bit kernel code */
#define X86_KERNEL_DS_32 0x10 /* 32-bit kernel data */
#define X86_KERNEL_CS 0x18 /* 64-bit kernel code */
#define X86_KERNEL_DS 0x20 /* 64-bit kernel data */
#define X86_KERNEL_CPU0_GS 0x30 /* data selector covering TSS */
#define X86_KERNEL_CPU0_TR 0x40 /* 64-bit task state segment */
#define X86_KERNEL_CPU1_GS 0x50 /* data selector covering TSS */
#define X86_KERNEL_CPU1_TR 0x60 /* 64-bit task state segment */
#define X86_KERNEL_CPU2_GS 0x70 /* data selector covering TSS */
#define X86_KERNEL_CPU2_TR 0x80 /* 64-bit task state segment */
#define X86_KERNEL_CPU3_GS 0x90 /* data selector covering TSS */
#define X86_KERNEL_CPU3_TR 0xA0 /* 64-bit task state segment */
#ifndef _ASMLANGUAGE
/* linker symbols defining the bounds of the kernel part loaded in locore */
extern char _locore_start[], _locore_end[];
/*
* 64-bit Task State Segment. One defined per CPU.
*/
struct x86_tss64 {
/*
* Architecturally-defined portion. It is somewhat tedious to
* enumerate each member specifically (rather than using arrays)
* but we need to get (some of) their offsets from assembly.
*/
u8_t reserved0[4];
u64_t rsp0; /* privileged stacks */
u64_t rsp1;
u64_t rsp2;
u8_t reserved[8];
u64_t ist1; /* interrupt stacks */
u64_t ist2;
u64_t ist3;
u64_t ist4;
u64_t ist5;
u64_t ist6;
u64_t ist7;
u8_t reserved1[10];
u16_t iomapb; /* offset to I/O base */
/*
* Zephyr specific portion. Stash per-CPU data here for convenience.
*/
struct _cpu *cpu;
} __packed __aligned(8);
typedef struct x86_tss64 x86_tss64_t;
/*
* Per-CPU bootstrapping parameters. See locore.S and cpu.c.
*/

View file

@ -30,16 +30,6 @@ static inline void z_arch_kernel_init(void)
/* nothing */;
}
static inline struct _cpu *z_arch_curr_cpu(void)
{
struct _cpu *cpu;
__asm__ volatile("movq %%gs:(%c1), %0"
: "=r" (cpu)
: "i" (offsetof(x86_tss64_t, cpu)));
return cpu;
}
#endif /* _ASMLANGUAGE */
#endif /* ZEPHYR_ARCH_X86_INCLUDE_INTEL64_KERNEL_ARCH_FUNC_H_ */

View file

@ -1,56 +0,0 @@
/*
* Copyright (c) 2019 Intel Corporation
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef ZEPHYR_ARCH_X86_INCLUDE_INTEL64_KERNEL_ARCH_THREAD_H_
#define ZEPHYR_ARCH_X86_INCLUDE_INTEL64_KERNEL_ARCH_THREAD_H_
#define X86_THREAD_FLAG_ALL 0x01 /* _thread_arch.flags: entire state saved */
#ifndef _ASMLANGUAGE
#include <zephyr/types.h>
#include <kernel_arch_data.h>
/*
* The _callee_saved registers are unconditionally saved/restored across
* context switches; the _thread_arch registers are only preserved when
* the thread is interrupted. _arch_thread.flags tells __resume when to
* cheat and only restore the first set. For more details see locore.S.
*/
struct _callee_saved {
u64_t rsp;
u64_t rbx;
u64_t rbp;
u64_t r12;
u64_t r13;
u64_t r14;
u64_t r15;
u64_t rip;
u64_t rflags;
};
typedef struct _callee_saved _callee_saved_t;
struct _thread_arch {
u8_t flags;
u64_t rax;
u64_t rcx;
u64_t rdx;
u64_t rsi;
u64_t rdi;
u64_t r8;
u64_t r9;
u64_t r10;
u64_t r11;
char __aligned(X86_FXSAVE_ALIGN) sse[X86_FXSAVE_SIZE];
};
typedef struct _thread_arch _thread_arch_t;
#endif /* _ASMLANGUAGE */
#endif /* ZEPHYR_ARCH_X86_INCLUDE_INTEL64_KERNEL_ARCH_THREAD_H_ */

View file

@ -6,6 +6,8 @@
#ifndef ZEPHYR_ARCH_X86_INCLUDE_KERNEL_ARCH_FUNC_H_
#define ZEPHYR_ARCH_X86_INCLUDE_KERNEL_ARCH_FUNC_H_
#include <kernel_arch_data.h>
#ifdef CONFIG_X86_64
#include <intel64/kernel_arch_func.h>
#else

View file

@ -1,15 +0,0 @@
/*
* Copyright (c) 2019 Intel Corporation
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef ZEPHYR_ARCH_X86_INCLUDE_KERNEL_ARCH_THREAD_H_
#define ZEPHYR_ARCH_X86_INCLUDE_KERNEL_ARCH_THREAD_H_
#ifdef CONFIG_X86_64
#include <intel64/kernel_arch_thread.h>
#else
#include <ia32/kernel_arch_thread.h>
#endif
#endif /* ZEPHYR_ARCH_X86_INCLUDE_KERNEL_ARCH_THREAD_H_ */

View file

@ -1,19 +1,24 @@
# SPDX-License-Identifier: Apache-2.0
zephyr_cc_option(-mlongcalls)
zephyr_sources(
cpu_idle.c
fatal.c
window_vectors.S
xtensa-asm2-util.S
xtensa-asm2.c
)
zephyr_sources_ifndef(CONFIG_ATOMIC_OPERATIONS_C atomic.S)
zephyr_sources_ifdef(CONFIG_XTENSA_USE_CORE_CRT1
crt1.S
)
zephyr_sources_ifdef(CONFIG_IRQ_OFFLOAD
irq_offload.c
)
zephyr_library()
zephyr_library_sources(
cpu_idle.c
fatal.c
window_vectors.S
xtensa-asm2-util.S
xtensa-asm2.c
)
zephyr_library_sources_ifndef(CONFIG_ATOMIC_OPERATIONS_C atomic.S)
zephyr_library_sources_ifdef(CONFIG_XTENSA_USE_CORE_CRT1 crt1.S)
zephyr_library_sources_ifdef(CONFIG_IRQ_OFFLOAD irq_offload.c)
zephyr_library_include_directories(
${ZEPHYR_BASE}/kernel/include
${ZEPHYR_BASE}/arch/xtensa/include
)
add_subdirectory(startup)

View file

@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
#include <xtensa_context.h>
#include <arch/xtensa/xtensa_context.h>
/**
*
* @brief Atomically clear a memory location

View file

@ -7,7 +7,7 @@
* Control arrives here at _start from the reset vector or from crt0-app.S.
*/
#include <xtensa_rtos.h>
#include <arch/xtensa/xtensa_rtos.h>
/* Exports */
.global _start

View file

@ -6,7 +6,7 @@
#include <kernel.h>
#include <irq_offload.h>
#include <arch/xtensa/arch.h>
#include <xtensa_api.h>
#include <arch/xtensa/xtensa_api.h>
/*
* Xtensa core should support software interrupt in order to allow using

View file

@ -23,12 +23,9 @@
* completeness.
*/
#include <gen_offset.h> /* located in kernel/arch/common/include */
/* list of headers that define whose structure offsets will be generated */
#include <kernel_structs.h>
#include <kernel.h>
#include <kernel_arch_data.h>
#include <gen_offset.h>
#include <kernel_offsets.h>
/* Xtensa-specific k_thread structure member offsets */

View file

@ -10,8 +10,13 @@ if(CONFIG_XTENSA_RESET_VECTOR)
)
zephyr_library_sources(
reset-vector.S
memerror-vector.S
memctl_default.S
reset-vector.S
memerror-vector.S
memctl_default.S
)
zephyr_library_include_directories(
${ZEPHYR_BASE}/kernel/include
${ZEPHYR_BASE}/arch/xtensa/include
)
endif()

View file

@ -2,7 +2,7 @@
* Copyright (c) 2016 Cadence Design Systems, Inc.
* SPDX-License-Identifier: Apache-2.0
*/
#include "xtensa_rtos.h"
#include <arch/xtensa/xtensa_rtos.h>
/* WINDOW OVERFLOW AND UNDERFLOW EXCEPTION VECTORS AND ALLOCA EXCEPTION
* HANDLER

View file

@ -23,7 +23,6 @@
#include <toolchain.h>
#include <linker/sections.h>
#include <arch/cpu.h>
#include <kernel_arch_thread.h>
/* stacks */
#define STACK_ROUND_UP(x) ROUND_UP(x, STACK_ALIGN_SIZE)
@ -31,7 +30,6 @@
#if !defined(_ASMLANGUAGE) && !defined(__ASSEMBLER__)
#include <kernel.h> /* public kernel API */
#include <kernel_internal.h>
#include <zephyr/types.h>
#include <sys/dlist.h>
#include <sys/util.h>

View file

@ -10,9 +10,8 @@
#define ZEPHYR_ARCH_XTENSA_INCLUDE_KERNEL_ARCH_FUNC_H_
#ifndef _ASMLANGUAGE
#include <kernel_arch_data.h>
#include <string.h>
#include <stdbool.h>
#include <stddef.h> /* For size_t */
#ifdef __cplusplus
extern "C" {
@ -23,16 +22,6 @@ extern "C" {
#define STACK_ROUND_UP(x) ROUND_UP(x, STACK_ALIGN_SIZE)
#define STACK_ROUND_DOWN(x) ROUND_DOWN(x, STACK_ALIGN_SIZE)
#define RSR(sr) \
({u32_t v; \
__asm__ volatile ("rsr." sr " %0" : "=a"(v)); \
v; })
#define WSR(sr, v) \
do { \
__asm__ volatile ("wsr." sr " %0" : : "r"(v)); \
} while (false)
extern void FatalErrorHandler(void);
extern void ReservedInterruptHandler(unsigned int intNo);
extern void z_xtensa_fatal_error(unsigned int reason, const z_arch_esf_t *esf);
@ -42,15 +31,6 @@ extern void z_xt_coproc_init(void);
extern K_THREAD_STACK_DEFINE(_interrupt_stack, CONFIG_ISR_STACK_SIZE);
static ALWAYS_INLINE _cpu_t *z_arch_curr_cpu(void)
{
void *val;
val = (void *)RSR(CONFIG_XTENSA_KERNEL_CPU_PTR_SR);
return val;
}
static ALWAYS_INLINE void z_arch_kernel_init(void)
{
_cpu_t *cpu0 = &_kernel.cpus[0];

View file

@ -1,7 +1,9 @@
# SPDX-License-Identifier: Apache-2.0
zephyr_library()
zephyr_library_compile_definitions(NO_POSIX_CHEATS)
zephyr_library_sources(
hw_models_top.c
timer_model.c
@ -14,6 +16,11 @@ zephyr_library_sources(
cmdline.c
)
zephyr_library_include_directories(
${ZEPHYR_BASE}/kernel/include
${ZEPHYR_BASE}/arch/posix/include
)
if(CONFIG_HAS_SDL)
find_package(PkgConfig REQUIRED)
pkg_search_module(SDL2 REQUIRED sdl2)

View file

@ -13,7 +13,7 @@
#include "timer_model.h"
#include "cmdline.h"
#include "toolchain.h"
#include "posix_trace.h"
#include <arch/posix/posix_trace.h>
#include "native_tracing.h"
static int s_argc, test_argc;

View file

@ -10,7 +10,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include "posix_trace.h"
#include <arch/posix/posix_trace.h>
#include "posix_board_if.h"
#include "zephyr/types.h"
#include "cmdline_common.h"

View file

@ -18,7 +18,7 @@
#include "timer_model.h"
#include "irq_ctrl.h"
#include "posix_board_if.h"
#include "posix_soc_if.h"
#include <arch/posix/posix_soc_if.h>
#include "posix_arch_internal.h"
#include "sdl_events.h"
#include <sys/util.h>

View file

@ -11,7 +11,7 @@
#include "native_rtc.h"
#include "hw_models_top.h"
#include "timer_model.h"
#include "posix_trace.h"
#include <arch/posix/posix_trace.h>
/**
* Return the (simulation) time in microseconds

View file

@ -6,7 +6,7 @@
#include <SDL.h>
#include "posix_board_if.h"
#include "posix_trace.h"
#include <arch/posix/posix_trace.h>
#include "posix_arch_internal.h"
#include "soc.h"
#include "hw_models_top.h"

View file

@ -26,7 +26,7 @@
#include "irq_ctrl.h"
#include "board_soc.h"
#include "zephyr/types.h"
#include "posix_trace.h"
#include <arch/posix/posix_trace.h>
#include <sys/util.h>
#include "cmdline.h"
#include "soc.h"

View file

@ -88,6 +88,8 @@ zephyr_library_include_directories(
$ENV{BSIM_COMPONENTS_PATH}/ext_NRF52_hw_models/src/HW_models/
$ENV{BSIM_COMPONENTS_PATH}/ext_NRF52_hw_models/src/nrfx_hal/
$ENV{BSIM_COMPONENTS_PATH}/libRandv2/src/
${ZEPHYR_BASE}/kernel/include
${ZEPHYR_BASE}/arch/posix/include
)
zephyr_ld_options(

View file

@ -6,7 +6,7 @@
#include "zephyr/types.h"
#include "fake_timer.h"
#include "time_machine.h"
#include "posix_soc_if.h"
#include <arch/posix/posix_soc_if.h>
#if defined(CONFIG_ARCH_HAS_CUSTOM_BUSY_WAIT)
/**

View file

@ -1148,6 +1148,12 @@ function(zephyr_library_sources_ifdef feature_toggle source)
endif()
endfunction()
function(zephyr_library_sources_ifndef feature_toggle source)
if(NOT ${feature_toggle})
zephyr_library_sources(${source} ${ARGN})
endif()
endfunction()
function(zephyr_sources_ifdef feature_toggle)
if(${${feature_toggle}})
zephyr_sources(${ARGN})

View file

@ -17,7 +17,7 @@
#include <sys/util.h>
#include <stdlib.h>
#include <string.h>
#include "posix_trace.h"
#include <arch/posix/posix_trace.h>
#include "soc.h"
#include "cmdline.h" /* native_posix command line options header */

View file

@ -25,7 +25,7 @@
#include <sys/select.h>
#include <net/if.h>
#include <time.h>
#include "posix_trace.h"
#include <arch/posix/posix_trace.h>
#ifdef __linux
#include <linux/if_tun.h>

View file

@ -17,7 +17,7 @@
#include "sys_clock.h"
#include "timer_model.h"
#include "soc.h"
#include "posix_trace.h"
#include <arch/posix/posix_trace.h>
static u64_t tick_period; /* System tick period in microseconds */
/* Time (microseconds since boot) of the last timer tick interrupt */

View file

@ -6,7 +6,7 @@
#include <drivers/timer/system_timer.h>
#include <sys_clock.h>
#include <spinlock.h>
#include <xtensa_rtos.h>
#include <arch/xtensa/xtensa_rtos.h>
#define TIMER_IRQ UTIL_CAT(XCHAL_TIMER, \
UTIL_CAT(CONFIG_XTENSA_TIMER_ID, _INTERRUPT))

View file

@ -18,6 +18,7 @@
#include <generated_dts_board.h>
#include <sw_isr_table.h>
#include <arch/arc/thread.h>
#ifdef CONFIG_CPU_ARCV2
#include <arch/arc/v2/exc.h>
#include <arch/arc/v2/irq.h>

View file

@ -0,0 +1,33 @@
/*
* Copyright (c) 2014-2016 Wind River Systems, Inc.
* Copyright (c) 2019 Stephanos Ioannidis <root@stephanos.io>
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef ZEPHYR_INCLUDE_ARCH_XTENSA_ARCH_INLINES_H_
#define ZEPHYR_INCLUDE_ARCH_XTENSA_ARCH_INLINES_H_
#ifndef _ASMLANGUAGE
#include <kernel_structs.h>
#ifdef CONFIG_CPU_ARCV2
#include <arch/arc/v2/aux_regs.h>
#endif
static ALWAYS_INLINE _cpu_t *z_arch_curr_cpu(void)
{
#ifdef CONFIG_SMP
u32_t core;
core = z_arc_v2_core_id();
return &_kernel.cpus[core];
#else
return &_kernel.cpus[0];
#endif /* CONFIG_SMP */
}
#endif /* !_ASMLANGUAGE */
#endif /* ZEPHYR_INCLUDE_ARCH_XTENSA_ARCH_INLINES_H_ */

View file

@ -16,8 +16,8 @@
* necessary to instantiate instances of struct k_thread.
*/
#ifndef ZEPHYR_ARCH_ARC_INCLUDE_KERNEL_ARCH_THREAD_H_
#define ZEPHYR_ARCH_ARC_INCLUDE_KERNEL_ARCH_THREAD_H_
#ifndef ZEPHYR_INCLUDE_ARCH_ARC_THREAD_H_
#define ZEPHYR_INCLUDE_ARCH_ARC_THREAD_H_
/*
* Reason a thread has relinquished control.
@ -70,4 +70,4 @@ typedef struct _thread_arch _thread_arch_t;
#endif /* _ASMLANGUAGE */
#endif /* ZEPHYR_ARCH_ARC_INCLUDE_KERNEL_ARCH_THREAD_H_ */
#endif /* ZEPHYR_INCLUDE_ARCH_ARC_THREAD_H_ */

View file

@ -0,0 +1,23 @@
/*
* arch_inlines.h - automatically selects the correct arch_inlines.h file to
* include based on the selected architecture.
*/
/*
* Copyright (c) 2019 Stephanos Ioannidis <root@stephanos.io>
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef ZEPHYR_INCLUDE_ARCH_INLINES_H_
#define ZEPHYR_INCLUDE_ARCH_INLINES_H_
#if defined(CONFIG_X86) || defined(CONFIG_X86_64)
#include <arch/x86/arch_inlines.h>
#elif defined(CONFIG_ARC)
#include <arch/arc/arch_inlines.h>
#elif defined(CONFIG_XTENSA)
#include <arch/xtensa/arch_inlines.h>
#endif
#endif /* ZEPHYR_INCLUDE_ARCH_INLINES_H_ */

View file

@ -22,6 +22,7 @@
/* ARM GPRs are often designated by two different names */
#define sys_define_gpr_with_alias(name1, name2) union { u32_t name1, name2; }
#include <arch/arm/thread.h>
#include <arch/arm/exc.h>
#include <arch/arm/irq.h>
#include <arch/arm/error.h>

Some files were not shown because too many files have changed in this diff Show more