Skip to content

Commit 426c6ca

Browse files
committed
headers: Refactor kernel_structs.h and introduce kernel_arch.h.
This commit refactors kernel_structs.h to be more truthful to its name (i.e. define kernel structures only), and introduces kernel_arch.h to provide the definitions that are not kernel structure related and were previously provided by kernel_structs.h. In addition, this commit updates all required inclusions of kernel_structs.h to use kernel_arch.h instead and makes the necessary adjustments to resolve header dependencies. The primary reason for refactoring kernel_structs.h is to remove its dependency on kernel.h so that the kernel structure definitions provided by it can be used in arch headers (for instance, in include/arch/arm/irq.h). This was not possible until now due to a circular dependency of these headers as described in the issue #3056. Signed-off-by: Stephanos Ioannidis <[email protected]>
1 parent cc1b94c commit 426c6ca

File tree

42 files changed

+163
-128
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+163
-128
lines changed

arch/arm/core/cortex_m/fault.c

+1-4
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,8 @@
1111
* Common fault handler for ARM Cortex-M processors.
1212
*/
1313

14-
#include <toolchain.h>
15-
#include <linker/sections.h>
16-
1714
#include <kernel.h>
18-
#include <kernel_structs.h>
15+
#include <kernel_arch.h>
1916
#include <inttypes.h>
2017
#include <exc_handle.h>
2118
#include <logging/log.h>

arch/arm/core/cortex_r/fault.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66

77
#include <kernel.h>
8-
#include <kernel_structs.h>
8+
#include <kernel_arch.h>
99

1010
/**
1111
*

arch/arm/core/fatal.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include <inttypes.h>
1818

1919
#include <kernel.h>
20-
#include <kernel_structs.h>
20+
#include <kernel_arch.h>
2121
#include <logging/log.h>
2222
LOG_MODULE_DECLARE(os);
2323

arch/arm/core/offsets/offsets.c

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
*/
2424

2525
#include <gen_offset.h>
26+
#include <kernel.h>
27+
#include <kernel_arch_data.h>
2628
#include <kernel_structs.h>
2729
#include <kernel_offsets.h>
2830

arch/arm/core/swap.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
#include <kernel.h>
88
#include <toolchain.h>
9-
#include <kernel_structs.h>
9+
#include <kernel_arch.h>
1010

1111
#ifdef CONFIG_EXECUTION_BENCHMARKING
1212
extern void read_timer_start_of_swap(void);

arch/arm/core/thread.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
#include <kernel.h>
1616
#include <toolchain.h>
17-
#include <kernel_structs.h>
17+
#include <kernel_arch.h>
1818
#include <wait_q.h>
1919

2020
#ifdef CONFIG_USERSPACE

arch/arm/include/kernel_arch_func.h

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#ifndef ZEPHYR_ARCH_ARM_INCLUDE_KERNEL_ARCH_FUNC_H_
2323
#define ZEPHYR_ARCH_ARM_INCLUDE_KERNEL_ARCH_FUNC_H_
2424

25+
#include <kernel_arch_data.h>
26+
2527
#ifdef __cplusplus
2628
extern "C" {
2729
#endif

arch/nios2/core/crt0.S

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7-
#include <kernel_structs.h>
7+
#include <toolchain.h>
8+
#include <linker/sections.h>
89

910
/* exports */
1011
GTEXT(__start)

arch/nios2/core/exception.S

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7-
#include <kernel_structs.h>
7+
#include <toolchain.h>
8+
#include <linker/sections.h>
89
#include <offsets_short.h>
910

1011
/* exports */

arch/nios2/core/prep_c.c

+1-5
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,7 @@
1616
* initialization is performed.
1717
*/
1818

19-
#include <zephyr/types.h>
20-
#include <toolchain.h>
21-
#include <linker/linker-defs.h>
22-
#include <kernel_structs.h>
23-
#include <kernel_internal.h>
19+
#include <kernel_arch.h>
2420

2521
/**
2622
*

arch/nios2/core/reset.S

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7-
#include <arch/cpu.h>
8-
#include <kernel_structs.h>
7+
#include <toolchain.h>
98
#include <offsets_short.h>
9+
#include <arch/cpu.h>
1010

1111
GTEXT(__start)
1212

arch/nios2/core/swap.S

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7-
#include <kernel_structs.h>
7+
#include <toolchain.h>
8+
#include <linker/sections.h>
89
#include <offsets_short.h>
910

1011
/* exports */

arch/nios2/include/kernel_arch_func.h

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#ifndef ZEPHYR_ARCH_NIOS2_INCLUDE_KERNEL_ARCH_FUNC_H_
2121
#define ZEPHYR_ARCH_NIOS2_INCLUDE_KERNEL_ARCH_FUNC_H_
2222

23+
#include <kernel_arch_data.h>
24+
2325
#ifdef __cplusplus
2426
extern "C" {
2527
#endif

arch/riscv/core/irq_manage.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7-
#include <toolchain.h>
8-
#include <kernel_structs.h>
7+
#include <kernel.h>
8+
#include <kernel_arch.h>
99
#include <logging/log.h>
1010
LOG_MODULE_DECLARE(os);
1111

arch/riscv/core/isr.S

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
#include <toolchain.h>
99
#include <linker/sections.h>
10-
#include <kernel_structs.h>
1110
#include <offsets_short.h>
11+
#include <arch/cpu.h>
1212

1313
/* imports */
1414
GDATA(_sw_isr_table)

arch/riscv/core/reset.S

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
* SPDX-License-Identifier: Apache-2.0
66
*/
77

8-
#include <kernel_structs.h>
8+
#include <toolchain.h>
9+
#include <linker/sections.h>
910

1011
/* exports */
1112
GTEXT(__initialize)

arch/riscv/core/swap.S

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7-
#include <irq.h>
8-
#include <kernel_structs.h>
7+
#include <toolchain.h>
8+
#include <linker/sections.h>
99
#include <offsets_short.h>
10+
#include <arch/cpu.h>
1011

1112
/* exports */
1213
GTEXT(z_arch_swap)

arch/riscv/include/kernel_arch_func.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#ifndef ZEPHYR_ARCH_RISCV_INCLUDE_KERNEL_ARCH_FUNC_H_
1616
#define ZEPHYR_ARCH_RISCV_INCLUDE_KERNEL_ARCH_FUNC_H_
1717

18-
#include <soc.h>
18+
#include <kernel_arch_data.h>
1919

2020
#ifdef __cplusplus
2121
extern "C" {

arch/x86/core/ia32/cache_s.S

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
* This module contains functions for manipulating caches.
1111
*/
1212

13+
#include <toolchain.h>
14+
#include <linker/sections.h>
1315
#include <arch/x86/ia32/asm.h>
1416

1517
#ifndef CONFIG_CLFLUSH_INSTRUCTION_SUPPORTED

arch/x86/core/ia32/crt0.S

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
* after having been loaded into RAM.
1212
*/
1313

14+
#include <toolchain.h>
15+
#include <linker/sections.h>
1416
#include <arch/x86/ia32/asm.h>
1517
#include <arch/x86/msr.h>
1618
#include <kernel_arch_data.h>

arch/x86/core/ia32/excstub.S

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@
1414
* and exiting a C exception handler.
1515
*/
1616

17-
#include <kernel_structs.h>
17+
#include <toolchain.h>
18+
#include <linker/sections.h>
19+
#include <offsets_short.h>
1820
#include <arch/x86/ia32/asm.h>
1921
#include <arch/x86/ia32/arch.h> /* For MK_ISR_NAME */
20-
#include <offsets_short.h>
2122

2223

2324
/* exports (internal APIs) */

arch/x86/core/ia32/fatal.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include <linker/sections.h>
1414

1515
#include <kernel.h>
16-
#include <kernel_structs.h>
16+
#include <kernel_arch.h>
1717
#include <drivers/interrupt_controller/sysapic.h>
1818
#include <arch/x86/ia32/segmentation.h>
1919
#include <ia32/exception.h>

arch/x86/core/ia32/float.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@
4343
* to enable FP register sharing on its behalf.
4444
*/
4545

46-
#include <kernel_structs.h>
47-
#include <toolchain.h>
46+
#include <kernel_arch.h>
4847

4948
/* SSE control/status register default value (used by assembler code) */
5049
extern u32_t _sse_mxcsr_default_value;

arch/x86/core/ia32/intstub.S

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@
1414
* entering and exiting a C interrupt handler.
1515
*/
1616

17-
#include <kernel_structs.h>
18-
#include <arch/x86/ia32/asm.h>
17+
#include <toolchain.h>
18+
#include <linker/sections.h>
1919
#include <offsets_short.h>
20+
#include <arch/x86/ia32/asm.h>
2021
#include <arch/cpu.h>
2122
#include <drivers/interrupt_controller/sysapic.h>
2223

arch/x86/core/ia32/swap.S

+5-2
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,12 @@
1111
* This module implements the z_arch_swap() routine for the IA-32 architecture.
1212
*/
1313

14-
#include <kernel_structs.h>
15-
#include <arch/x86/ia32/asm.h>
14+
#include <toolchain.h>
15+
#include <linker/sections.h>
1616
#include <offsets_short.h>
17+
#include <kernel.h>
18+
#include <kernel_arch_data.h>
19+
#include <arch/x86/ia32/asm.h>
1720

1821
/* exports (internal APIs) */
1922

arch/x86/core/ia32/userspace.S

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7-
#include <kernel_structs.h>
7+
#include <toolchain.h>
8+
#include <linker/sections.h>
9+
#include <offsets_short.h>
810
#include <arch/x86/ia32/asm.h>
911
#include <arch/cpu.h>
10-
#include <offsets_short.h>
1112
#include <syscall.h>
1213

1314
/* Exports */

arch/x86/core/ia32/x86_mmu.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include <arch/x86/mmustructs.h>
99
#include <linker/linker-defs.h>
1010
#include <kernel_internal.h>
11-
#include <kernel_structs.h>
11+
#include <kernel_arch.h>
1212
#include <init.h>
1313
#include <ctype.h>
1414
#include <string.h>

arch/x86/core/prep_c.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7-
#include <kernel_structs.h>
7+
#include <kernel_arch.h>
88
#include <arch/x86/acpi.h>
99
#include <arch/x86/multiboot.h>
1010

arch/x86/include/ia32/kernel_arch_func.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
#ifndef _ASMLANGUAGE
1414

15-
#include <stddef.h> /* For size_t */
15+
#include <kernel_arch_data.h>
1616

1717
#ifdef __cplusplus
1818
extern "C" {

arch/x86/include/intel64/kernel_arch_func.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#ifndef ZEPHYR_ARCH_X86_INCLUDE_INTEL64_KERNEL_ARCH_FUNC_H_
77
#define ZEPHYR_ARCH_X86_INCLUDE_INTEL64_KERNEL_ARCH_FUNC_H_
88

9-
#include <kernel_structs.h>
9+
#include <kernel_arch_data.h>
1010

1111
#ifndef _ASMLANGUAGE
1212

arch/xtensa/core/offsets/offsets.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727

2828
/* list of headers that define whose structure offsets will be generated */
2929

30+
#include <kernel_arch_data.h>
3031
#include <kernel_structs.h>
31-
3232
#include <kernel_offsets.h>
3333

3434
/* Xtensa-specific k_thread structure member offsets */

include/arch/arm/irq.h

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#ifndef ZEPHYR_INCLUDE_ARCH_ARM_CORTEX_M_IRQ_H_
1515
#define ZEPHYR_INCLUDE_ARCH_ARM_CORTEX_M_IRQ_H_
1616

17+
#include <kernel_structs.h>
1718
#include <irq.h>
1819
#include <sw_isr_table.h>
1920
#include <stdbool.h>

include/sys/mutex.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ static inline int sys_mutex_unlock(struct sys_mutex *mutex)
110110

111111
#else
112112
#include <kernel.h>
113-
#include <kernel_structs.h>
113+
#include <kernel_arch.h>
114114

115115
struct sys_mutex {
116116
struct k_mutex kernel_mutex;

kernel/errno.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
* context switching.
1313
*/
1414

15-
#include <kernel_structs.h>
16-
#include <syscall_handler.h>
15+
#include <kernel.h>
16+
#include <kernel_arch.h>
1717

1818
/*
1919
* Define _k_neg_eagain for use in assembly files as errno.h is

0 commit comments

Comments
 (0)