From c18f02836629f95a22b68fabbca0647e05327bff Mon Sep 17 00:00:00 2001 From: "Charles E. Youse" Date: Thu, 4 Jul 2019 11:02:41 -0700 Subject: [PATCH] arch/x86: refactor offsets.c The IA32 and Intel64 subarchitectures will generate different offset symbols, so they are refactored. No functional change. Signed-off-by: Charles E. Youse --- arch/x86/core/offsets/ia32_offsets.c | 79 +++++++++++++++++++++++++ arch/x86/core/offsets/intel64_offsets.c | 5 ++ arch/x86/core/offsets/offsets.c | 75 ++--------------------- 3 files changed, 89 insertions(+), 70 deletions(-) create mode 100644 arch/x86/core/offsets/ia32_offsets.c create mode 100644 arch/x86/core/offsets/intel64_offsets.c diff --git a/arch/x86/core/offsets/ia32_offsets.c b/arch/x86/core/offsets/ia32_offsets.c new file mode 100644 index 00000000000..f5ee9fcf138 --- /dev/null +++ b/arch/x86/core/offsets/ia32_offsets.c @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2010-2014 Wind River Systems, Inc. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/** + * @file + * @brief 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 IA-32 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 /* located in kernel/include */ + +/* list of headers that define whose structure offsets will be generated */ + +#include +#include +#include + +#include + +#if defined(CONFIG_LAZY_FP_SHARING) +GEN_OFFSET_SYM(_thread_arch_t, excNestCount); +#endif + +#ifdef CONFIG_USERSPACE +GEN_ABSOLUTE_SYM(Z_X86_PDPT_SIZE, sizeof(struct x86_mmu_pdpt)); +#endif + +GEN_OFFSET_SYM(_thread_arch_t, preempFloatReg); + +/** + * size of the struct k_thread structure sans save area for floating + * point regs + */ + +GEN_ABSOLUTE_SYM(_K_THREAD_NO_FLOAT_SIZEOF, + sizeof(struct k_thread) - sizeof(tPreempFloatReg)); + +GEN_OFFSET_SYM(_callee_saved_t, esp); + +/* z_arch_esf_t structure member offsets */ + +GEN_OFFSET_SYM(z_arch_esf_t, esp); +GEN_OFFSET_SYM(z_arch_esf_t, ebp); +GEN_OFFSET_SYM(z_arch_esf_t, ebx); +GEN_OFFSET_SYM(z_arch_esf_t, esi); +GEN_OFFSET_SYM(z_arch_esf_t, edi); +GEN_OFFSET_SYM(z_arch_esf_t, edx); +GEN_OFFSET_SYM(z_arch_esf_t, ecx); +GEN_OFFSET_SYM(z_arch_esf_t, eax); +GEN_OFFSET_SYM(z_arch_esf_t, errorCode); +GEN_OFFSET_SYM(z_arch_esf_t, eip); +GEN_OFFSET_SYM(z_arch_esf_t, cs); +GEN_OFFSET_SYM(z_arch_esf_t, eflags); + +/* size of the MMU_REGION structure. Used by linker scripts */ + +GEN_ABSOLUTE_SYM(__MMU_REGION_SIZEOF, sizeof(struct mmu_region)); + +/* size of struct x86_multiboot_info, used by crt0.S */ + +GEN_ABSOLUTE_SYM(__X86_MULTIBOOT_INFO_SIZEOF, + sizeof(struct x86_multiboot_info)); + +GEN_ABS_SYM_END diff --git a/arch/x86/core/offsets/intel64_offsets.c b/arch/x86/core/offsets/intel64_offsets.c new file mode 100644 index 00000000000..db415f31336 --- /dev/null +++ b/arch/x86/core/offsets/intel64_offsets.c @@ -0,0 +1,5 @@ +/* + * Copyright (c) 2019 Intel Corp. + * SPDX-License-Identifier: Apache-2.0 + */ + diff --git a/arch/x86/core/offsets/offsets.c b/arch/x86/core/offsets/offsets.c index c1a788f266c..b80375d2306 100644 --- a/arch/x86/core/offsets/offsets.c +++ b/arch/x86/core/offsets/offsets.c @@ -1,79 +1,14 @@ /* - * Copyright (c) 2010-2014 Wind River Systems, Inc. - * + * Copyright (c) 2019 Intel Corp. * SPDX-License-Identifier: Apache-2.0 */ -/** - * @file - * @brief 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 IA-32 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 /* located in kernel/include */ - -/* list of headers that define whose structure offsets will be generated */ - -#include -#include -#include - -#include - -#if defined(CONFIG_LAZY_FP_SHARING) -GEN_OFFSET_SYM(_thread_arch_t, excNestCount); +#ifdef CONFIG_X86_LONGMODE +#include "intel64_offsets.c" +#else +#include "ia32_offsets.c" #endif -GEN_OFFSET_SYM(_thread_arch_t, preempFloatReg); - -#ifdef CONFIG_USERSPACE -GEN_ABSOLUTE_SYM(Z_X86_PDPT_SIZE, sizeof(struct x86_mmu_pdpt)); -#endif - -/** - * size of the struct k_thread structure sans save area for floating - * point regs - */ - -GEN_ABSOLUTE_SYM(_K_THREAD_NO_FLOAT_SIZEOF, - sizeof(struct k_thread) - sizeof(tPreempFloatReg)); - -GEN_OFFSET_SYM(_callee_saved_t, esp); - -/* z_arch_esf_t structure member offsets */ - -GEN_OFFSET_SYM(z_arch_esf_t, esp); -GEN_OFFSET_SYM(z_arch_esf_t, ebp); -GEN_OFFSET_SYM(z_arch_esf_t, ebx); -GEN_OFFSET_SYM(z_arch_esf_t, esi); -GEN_OFFSET_SYM(z_arch_esf_t, edi); -GEN_OFFSET_SYM(z_arch_esf_t, edx); -GEN_OFFSET_SYM(z_arch_esf_t, ecx); -GEN_OFFSET_SYM(z_arch_esf_t, eax); -GEN_OFFSET_SYM(z_arch_esf_t, errorCode); -GEN_OFFSET_SYM(z_arch_esf_t, eip); -GEN_OFFSET_SYM(z_arch_esf_t, cs); -GEN_OFFSET_SYM(z_arch_esf_t, eflags); - -/* tTaskStateSegment structure member offsets */ - - -/* size of the MMU_REGION structure. Used by linker scripts */ - -GEN_ABSOLUTE_SYM(__MMU_REGION_SIZEOF, sizeof(struct mmu_region)); - /* size of struct x86_multiboot_info, used by crt0.S */ GEN_ABSOLUTE_SYM(__X86_MULTIBOOT_INFO_SIZEOF,