From aa6d5b43f2644c2122adde223b13a4007298d613 Mon Sep 17 00:00:00 2001 From: "Charles E. Youse" Date: Sat, 29 Jun 2019 13:01:13 -0700 Subject: [PATCH] arch/x86: refactor kernel_arch_data.h Some of this is 32-bit specific, some applies to all subarchitectures. A preliminary attempt is made to refactor and place 32-bit-specific portions in ia32/kernel_arch_data.h. Signed-off-by: Charles E. Youse --- arch/x86/include/ia32/kernel_arch_data.h | 102 +++++++++++++++++++++++ arch/x86/include/kernel_arch_data.h | 99 ++-------------------- 2 files changed, 107 insertions(+), 94 deletions(-) create mode 100644 arch/x86/include/ia32/kernel_arch_data.h diff --git a/arch/x86/include/ia32/kernel_arch_data.h b/arch/x86/include/ia32/kernel_arch_data.h new file mode 100644 index 00000000000..893bfaf6069 --- /dev/null +++ b/arch/x86/include/ia32/kernel_arch_data.h @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2010-2014 Wind River Systems, Inc. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/** + * @file + * @brief Private kernel definitions (IA-32) + * + * This file contains private kernel structures definitions and various + * other definitions for the Intel Architecture 32 bit (IA-32) processor + * architecture. + * The header include/kernel.h contains the public kernel interface + * definitions, with include/arch/x86/ia32/arch.h supplying the + * IA-32 specific portions of the public kernel interface. + * + * This file is also included by assembly language files which must #define + * _ASMLANGUAGE before including this header file. Note that kernel + * assembly source files obtains structure offset values via "absolute symbols" + * in the offsets.o module. + */ + +/* this file is only meant to be included by kernel_structs.h */ + +#ifndef ZEPHYR_ARCH_X86_INCLUDE_IA32_KERNEL_ARCH_DATA_H_ +#define ZEPHYR_ARCH_X86_INCLUDE_IA32_KERNEL_ARCH_DATA_H_ + +#include +#include +#include +#include +#include + +#ifndef _ASMLANGUAGE +#include +#include +#include +#include +#endif + +/* Some configurations require that the stack/registers be adjusted before + * z_thread_entry. See discussion in swap.S for z_x86_thread_entry_wrapper() + */ +#if defined(CONFIG_X86_IAMCU) || defined(CONFIG_DEBUG_INFO) +#define _THREAD_WRAPPER_REQUIRED +#endif + + +/* increase to 16 bytes (or more?) to support SSE/SSE2 instructions? */ + +#define STACK_ALIGN_SIZE 4 + +/* x86 Bitmask definitions for struct k_thread.thread_state */ + +/* executing context is interrupt handler */ +#define _INT_ACTIVE (1 << 7) + +/* executing context is exception handler */ +#define _EXC_ACTIVE (1 << 6) + +#define _INT_OR_EXC_MASK (_INT_ACTIVE | _EXC_ACTIVE) + +/* end - states */ + +#if defined(CONFIG_LAZY_FP_SHARING) && defined(CONFIG_SSE) +#define _FP_USER_MASK (K_FP_REGS | K_SSE_REGS) +#elif defined(CONFIG_LAZY_FP_SHARING) +#define _FP_USER_MASK (K_FP_REGS) +#endif + +/* + * EFLAGS value to utilize for the initial context: IF=1. + */ + +#define EFLAGS_INITIAL 0x00000200U + +/* Enable paging and write protection */ +#define CR0_PG_WP_ENABLE 0x80010000 +/* Set the 5th bit in CR4 */ +#define CR4_PAE_ENABLE 0x00000020 + +#ifndef _ASMLANGUAGE + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _THREAD_WRAPPER_REQUIRED +extern void z_x86_thread_entry_wrapper(k_thread_entry_t entry, + void *p1, void *p2, void *p3); +#endif /* _THREAD_WRAPPER_REQUIRED */ + +#ifdef __cplusplus +} +#endif + +#endif /* _ASMLANGUAGE */ + +#endif /* ZEPHYR_ARCH_X86_INCLUDE_IA32_KERNEL_ARCH_DATA_H_ */ diff --git a/arch/x86/include/kernel_arch_data.h b/arch/x86/include/kernel_arch_data.h index 777dcad38c8..ce5da741033 100644 --- a/arch/x86/include/kernel_arch_data.h +++ b/arch/x86/include/kernel_arch_data.h @@ -1,77 +1,14 @@ /* - * Copyright (c) 2010-2014 Wind River Systems, Inc. - * + * Copyright (c) 2019 Intel Corporation * SPDX-License-Identifier: Apache-2.0 */ -/** - * @file - * @brief Private kernel definitions (IA-32) - * - * This file contains private kernel structures definitions and various - * other definitions for the Intel Architecture 32 bit (IA-32) processor - * architecture. - * The header include/kernel.h contains the public kernel interface - * definitions, with include/arch/x86/ia32/arch.h supplying the - * IA-32 specific portions of the public kernel interface. - * - * This file is also included by assembly language files which must #define - * _ASMLANGUAGE before including this header file. Note that kernel - * assembly source files obtains structure offset values via "absolute symbols" - * in the offsets.o module. - */ - -/* this file is only meant to be included by kernel_structs.h */ - #ifndef ZEPHYR_ARCH_X86_INCLUDE_KERNEL_ARCH_DATA_H_ #define ZEPHYR_ARCH_X86_INCLUDE_KERNEL_ARCH_DATA_H_ -#include -#include -#include -#include -#include - -#ifndef _ASMLANGUAGE -#include -#include -#include -#include -#endif - -/* Some configurations require that the stack/registers be adjusted before - * z_thread_entry. See discussion in swap.S for z_x86_thread_entry_wrapper() - */ -#if defined(CONFIG_X86_IAMCU) || defined(CONFIG_DEBUG_INFO) -#define _THREAD_WRAPPER_REQUIRED -#endif - - -/* increase to 16 bytes (or more?) to support SSE/SSE2 instructions? */ - -#define STACK_ALIGN_SIZE 4 - -/* x86 Bitmask definitions for struct k_thread.thread_state */ - -/* executing context is interrupt handler */ -#define _INT_ACTIVE (1 << 7) - -/* executing context is exception handler */ -#define _EXC_ACTIVE (1 << 6) - -#define _INT_OR_EXC_MASK (_INT_ACTIVE | _EXC_ACTIVE) - -/* end - states */ - -#if defined(CONFIG_LAZY_FP_SHARING) && defined(CONFIG_SSE) -#define _FP_USER_MASK (K_FP_REGS | K_SSE_REGS) -#elif defined(CONFIG_LAZY_FP_SHARING) -#define _FP_USER_MASK (K_FP_REGS) -#endif - /* - * Exception/interrupt vector definitions: vectors 20 to 31 are reserved for - * Intel; vectors 32 to 255 are user defined interrupt vectors. + * Exception/interrupt vector definitions: vectors 20 to 31 are reserved + * for Intel; vectors 32 to 255 are user defined interrupt vectors. */ #define IV_DIVIDE_ERROR 0 @@ -96,34 +33,8 @@ #define IV_SIMD_FP 19 #define IV_INTEL_RESERVED_END 31 -/* - * EFLAGS value to utilize for the initial context: IF=1. - */ - -#define EFLAGS_INITIAL 0x00000200U - -/* Enable paging and write protection */ -#define CR0_PG_WP_ENABLE 0x80010000 -/* Set the 5th bit in CR4 */ -#define CR4_PAE_ENABLE 0x00000020 - -#ifndef _ASMLANGUAGE - -#include - -#ifdef _THREAD_WRAPPER_REQUIRED -extern void z_x86_thread_entry_wrapper(k_thread_entry_t entry, - void *p1, void *p2, void *p3); -#endif /* _THREAD_WRAPPER_REQUIRED */ - -#ifdef __cplusplus -extern "C" { +#ifndef CONFIG_X86_LONGMODE +#include #endif -#ifdef __cplusplus -} -#endif - -#endif /* _ASMLANGUAGE */ - #endif /* ZEPHYR_ARCH_X86_INCLUDE_KERNEL_ARCH_DATA_H_ */