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>
118 lines
3.7 KiB
C
118 lines
3.7 KiB
C
/*
|
|
* Copyright (c) 2014 Wind River Systems, Inc.
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
/**
|
|
* @file
|
|
* @brief ARCv2 kernel structure member offset definition file
|
|
*
|
|
* This module is responsible for the generation of the absolute symbols whose
|
|
* value represents the member offsets for various ARCv2 kernel structures.
|
|
*
|
|
* All of the absolute symbols defined by this module will be present in the
|
|
* final kernel ELF image (due to the linker's reference to the _OffsetAbsSyms
|
|
* symbol).
|
|
*
|
|
* INTERNAL
|
|
* It is NOT necessary to define the offset for every member of a structure.
|
|
* Typically, only those members that are accessed by assembly language routines
|
|
* are defined; however, it doesn't hurt to define all fields for the sake of
|
|
* completeness.
|
|
*/
|
|
|
|
#include <kernel.h>
|
|
#include <kernel_arch_data.h>
|
|
#include <gen_offset.h>
|
|
#include <kernel_offsets.h>
|
|
|
|
GEN_OFFSET_SYM(_thread_arch_t, relinquish_cause);
|
|
#ifdef CONFIG_ARC_STACK_CHECKING
|
|
GEN_OFFSET_SYM(_thread_arch_t, k_stack_base);
|
|
GEN_OFFSET_SYM(_thread_arch_t, k_stack_top);
|
|
#ifdef CONFIG_USERSPACE
|
|
GEN_OFFSET_SYM(_thread_arch_t, u_stack_base);
|
|
GEN_OFFSET_SYM(_thread_arch_t, u_stack_top);
|
|
#endif
|
|
#endif
|
|
|
|
/* ARCv2-specific IRQ stack frame structure member offsets */
|
|
GEN_OFFSET_SYM(_isf_t, r0);
|
|
GEN_OFFSET_SYM(_isf_t, r1);
|
|
GEN_OFFSET_SYM(_isf_t, r2);
|
|
GEN_OFFSET_SYM(_isf_t, r3);
|
|
GEN_OFFSET_SYM(_isf_t, r4);
|
|
GEN_OFFSET_SYM(_isf_t, r5);
|
|
GEN_OFFSET_SYM(_isf_t, r6);
|
|
GEN_OFFSET_SYM(_isf_t, r7);
|
|
GEN_OFFSET_SYM(_isf_t, r8);
|
|
GEN_OFFSET_SYM(_isf_t, r9);
|
|
GEN_OFFSET_SYM(_isf_t, r10);
|
|
GEN_OFFSET_SYM(_isf_t, r11);
|
|
GEN_OFFSET_SYM(_isf_t, r12);
|
|
GEN_OFFSET_SYM(_isf_t, r13);
|
|
GEN_OFFSET_SYM(_isf_t, blink);
|
|
GEN_OFFSET_SYM(_isf_t, lp_end);
|
|
GEN_OFFSET_SYM(_isf_t, lp_start);
|
|
GEN_OFFSET_SYM(_isf_t, lp_count);
|
|
#ifdef CONFIG_CODE_DENSITY
|
|
GEN_OFFSET_SYM(_isf_t, ei_base);
|
|
GEN_OFFSET_SYM(_isf_t, ldi_base);
|
|
GEN_OFFSET_SYM(_isf_t, jli_base);
|
|
#endif
|
|
GEN_OFFSET_SYM(_isf_t, pc);
|
|
#ifdef CONFIG_ARC_HAS_SECURE
|
|
GEN_OFFSET_SYM(_isf_t, sec_stat);
|
|
#endif
|
|
GEN_OFFSET_SYM(_isf_t, status32);
|
|
GEN_ABSOLUTE_SYM(___isf_t_SIZEOF, sizeof(_isf_t));
|
|
|
|
GEN_OFFSET_SYM(_callee_saved_t, sp);
|
|
GEN_ABSOLUTE_SYM(___callee_saved_t_SIZEOF, sizeof(_callee_saved_t));
|
|
|
|
GEN_OFFSET_SYM(_callee_saved_stack_t, r13);
|
|
GEN_OFFSET_SYM(_callee_saved_stack_t, r14);
|
|
GEN_OFFSET_SYM(_callee_saved_stack_t, r15);
|
|
GEN_OFFSET_SYM(_callee_saved_stack_t, r16);
|
|
GEN_OFFSET_SYM(_callee_saved_stack_t, r17);
|
|
GEN_OFFSET_SYM(_callee_saved_stack_t, r18);
|
|
GEN_OFFSET_SYM(_callee_saved_stack_t, r19);
|
|
GEN_OFFSET_SYM(_callee_saved_stack_t, r20);
|
|
GEN_OFFSET_SYM(_callee_saved_stack_t, r21);
|
|
GEN_OFFSET_SYM(_callee_saved_stack_t, r22);
|
|
GEN_OFFSET_SYM(_callee_saved_stack_t, r23);
|
|
GEN_OFFSET_SYM(_callee_saved_stack_t, r24);
|
|
GEN_OFFSET_SYM(_callee_saved_stack_t, r25);
|
|
GEN_OFFSET_SYM(_callee_saved_stack_t, r26);
|
|
GEN_OFFSET_SYM(_callee_saved_stack_t, fp);
|
|
#ifdef CONFIG_USERSPACE
|
|
#ifdef CONFIG_ARC_HAS_SECURE
|
|
GEN_OFFSET_SYM(_callee_saved_stack_t, kernel_sp);
|
|
GEN_OFFSET_SYM(_callee_saved_stack_t, user_sp);
|
|
#else
|
|
GEN_OFFSET_SYM(_callee_saved_stack_t, user_sp);
|
|
#endif
|
|
#endif
|
|
GEN_OFFSET_SYM(_callee_saved_stack_t, r30);
|
|
#ifdef CONFIG_ARC_HAS_ACCL_REGS
|
|
GEN_OFFSET_SYM(_callee_saved_stack_t, r58);
|
|
GEN_OFFSET_SYM(_callee_saved_stack_t, r59);
|
|
#endif
|
|
#ifdef CONFIG_FP_SHARING
|
|
GEN_OFFSET_SYM(_callee_saved_stack_t, fpu_status);
|
|
GEN_OFFSET_SYM(_callee_saved_stack_t, fpu_ctrl);
|
|
#ifdef CONFIG_FP_FPU_DA
|
|
GEN_OFFSET_SYM(_callee_saved_stack_t, dpfp2h);
|
|
GEN_OFFSET_SYM(_callee_saved_stack_t, dpfp2l);
|
|
GEN_OFFSET_SYM(_callee_saved_stack_t, dpfp1h);
|
|
GEN_OFFSET_SYM(_callee_saved_stack_t, dpfp1l);
|
|
#endif
|
|
|
|
#endif
|
|
GEN_ABSOLUTE_SYM(___callee_saved_stack_t_SIZEOF, sizeof(_callee_saved_stack_t));
|
|
|
|
GEN_ABSOLUTE_SYM(_K_THREAD_NO_FLOAT_SIZEOF, sizeof(struct k_thread));
|
|
|
|
GEN_ABS_SYM_END
|