diff --git a/Kconfig b/Kconfig new file mode 100644 index 0000000000000000000000000000000000000000..d05911883a99f0a54d129ad7dda0d343e36b8a9b --- /dev/null +++ b/Kconfig @@ -0,0 +1,130 @@ +# Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of +# conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list +# of conditions and the following disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors may be used +# to endorse or promote products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +mainmenu "Kernel Configuration" + +menu "Compiler" +choice + prompt "Compiler type" + default COMPILER_GCC + help + Choose compiler type. + +config COMPILER_GCC + bool "GCC" + +config CROSS_COMPILE + string + depends on COMPILER_GCC + default "arm-none-eabi-" + +endchoice + +endmenu + +menu "Platform" + +######################### config options of bsp ##################### +config PLATFORM + string + default "virt" if PLATFORM_QEMU_ARM_VIRT_CM4 + +config PRODUCT_NAME + string + default "arm_mps2_an386" if PRODUCT_QEMU_ARM_MPS2_AN386 + +config DEVICE_COMPANY + string + default "qemu" if PLATFORM_QEMU_ARM_VIRT_CM4 + +choice + prompt "Chip" + default PLATFORM_QEMU_ARM_VIRT_CM4 + help + Qemu ARM Virt variants (based on different CPU types): + - qemu_arm_virt_cm4 + +config PLATFORM_QEMU_ARM_VIRT_CM4 + bool "qemu_arm_virt_cm4" + select ARCH_CORTEX_M4 + help + QEMU ARM Virtual Platform using Cortex-M4 CPU. + +endchoice + +choice + prompt "Product" + help + Select your target board. + +config PRODUCT_QEMU_ARM_MPS2_AN386 + bool "arm_mps2_an386" if PLATFORM_QEMU_ARM_VIRT_CM4 + +endchoice +endmenu + +######################### config options of UniProton ##################### +source config/Kconfig + +# Device Kconfig import +osource "$(DEVICE_PATH)/Kconfg" + +menu "Stack Smashing Protector (SSP) Compiler Feature" + +choice + prompt "Enable stack buffer overflow detection" + default CC_STACKPROTECTOR_STRONG + ---help--- + This option turns on the -fstack-protector GCC feature. This + feature puts, at the beginning of functions, a canary value on + the stack just before the return address, and validates + the value just before actually returning. Stack based buffer + overflows (that need to overwrite this return address) now also + overwrite the canary, which gets detected and the attack is then + neutralized via a kernel panic. + + This feature requires gcc version 4.2 or above, or a distribution + gcc with the feature backported. Older versions are automatically + detected and for those versions, this configuration option is + ignored. (and a warning is printed during bootup) + +config CC_NO_STACKPROTECTOR + bool "-fno-stack-protector" + +config CC_STACKPROTECTOR + bool "-fstack-protector" + +config CC_STACKPROTECTOR_STRONG + bool "-fstack-protector-strong" + +config CC_STACKPROTECTOR_ALL + bool "-fstack-protector-all" + +endchoice + +endmenu diff --git a/build/BUILD.gn b/build/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..915ee29d491edfb0a43a6a1559da6b7954a9b981 --- /dev/null +++ b/build/BUILD.gn @@ -0,0 +1,265 @@ +# Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of +# conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list +# of conditions and the following disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors may be used +# to endorse or promote products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import("//build/lite/config/component/lite_component.gni") +import("uniproton.gni") + +declare_args() { + uniproton_name = "OHOS_Image" + HAVE_DEVICE_SDK = true +} + +arch_cflags = [] +if (defined(ARCH_CPU)) { + arch_cflags += [ "-mcpu=$ARCH_CPU" ] +} +if (defined(ARCH_FPU) && defined(ARCH_FLOAT)) { + arch_cflags += [ "-mfloat-abi=$ARCH_FLOAT" ] + arch_cflags += [ "-mfpu=$ARCH_FPU" ] +} +if (defined(CONFIG_HARDWARE_PLATFORM)) { + arch_cflags += [ "-DOS_HARDWARE_PLATFORM=$CONFIG_HARDWARE_PLATFORM" ] +} + +cc = "$ohos_current_cc_command " + string_join(" ", arch_cflags) + +config("arch_config") { + cflags = arch_cflags + ldflags = cflags + if (defined(THUMB)) { + cflags += [ + "-mthumb", + "-Wa,-mimplicit-it=thumb" + ] + } + asmflags = cflags +} + +config("kconfig_config") { + cflags = [ + "-imacros", + "$MENUCONFIG_H", + ] + asmflags = cflags + cflags_cc = cflags +} + +config("kernel_config") { + include_dirs = [ + "$OSTOPDIR/arch/include", + "$OSTOPDIR/config", + "$OSTOPDIR/core/ipc/include", + "$OSTOPDIR/core/kernel/include", + "$OSTOPDIR/mem/include", + "$OSTOPDIR/om/include", + "$OSTOPDIR/utility/lib/include", + "$OSTOPDIR/include/uapi", + "$OSTOPDIR/arch/cpu/armv7-m/common", + "$OSTOPDIR/arch/cpu/armv7-m/cortex-m4", + "//kernel/uniproton/config", + "//third_party/bounds_checking_function/include", + ] +} + +config("strong_waring_flag") { + cflags = [ + "-Wunused", + "-Wredundant-decls", + "-Wfloat-conversion", + "-Wwrite-strings", + "-Wunused-macros", + "-Wswitch-default", + "-Wshift-overflow=2", + "-Wnested-externs", + "-Wmissing-include-dirs", + "-Wlogical-op", + "-Wjump-misses-init", + "-Wformat-security", + "-Wvla", + "-Wframe-larger-than=4096", + "-Wduplicated-cond", + "-Wdisabled-optimization", + "-Wduplicated-branches", + "-Wignored-qualifiers", + "-Wimplicit-fallthrough=3", + "-Wpointer-arith", + "-Wshift-negative-value", + "-Wsign-compare", + "-Wtype-limits", + "-Wcast-qual", + "-Wundef", + "-Wbad-function-cast", + "-Wold-style-definition", + "-Wpacked", + "-Wstrict-prototypes", + "-Wstack-usage=2048", + ] + + cflags_cc = cflags +} + +config("warn_config") { + cflags = [ + "-Wall", + "-Werror", + "-Wextra", + "-Wformat=2", + "-Wfloat-equal", + "-Wshadow", + "-Wtrampolines", + "-Wdate-time", + ] + + cflags_cc = cflags +} + +config("stdinc_config") { + std_include = exec_script("//build/lite/run_shell_cmd.py", + [ "$cc -print-file-name=include" ], + "trim string") + cflags = [ + "-isystem", + std_include, + ] + asmflags = cflags +} + +config("ssp_config") { + cflags = [] + if (defined(CC_STACKPROTECTOR_ALL)) { + cflags += [ "-fstack-protector-all" ] + } else if (defined(CC_STACKPROTECTOR_STRONG)) { + cflags += [ "-fstack-protector-strong" ] + } else if (defined(CC_STACKPROTECTOR)) { + cflags += [ + "-fstack-protector", + "--param", + "ssp-buffer-size=4", + ] + } else { + cflags += [ "-fno-stack-protector" ] + } + asmflags = cflags +} + +config("misc_config") { + cflags = [ + "-fno-pic", + "-fno-builtin", + "-fms-extensions", + "-fno-strict-aliasing", + "-fno-common", + "-fsigned-char", + "-ffunction-sections", + "-fdata-sections", + "-fno-exceptions", + "-fno-omit-frame-pointer", + ] + + asmflags = cflags + asmflags += [ "-DCLZ=CLZ" ] +} + +config("os_config") { + configs = [ + ":arch_config", + ":stdinc_config", + ":ssp_config", + #":warn_config", + ":strong_waring_flag", + ":misc_config", + ] + + configs += [ ":kernel_config" ] + if (HAVE_DEVICE_SDK) { + configs += [ "$device_path:public" ] + } +} + +static_library("libkernel") { + sources = kernel_base_sources + sources += kernel_mem_sources + sources += kernel_om_sources + sources += kernel_security_sources + sources += kernel_utility_sources + + if ("$board_cpu" == "cortex-m4") { + sources += arch_cortex_m4_sources + } + + configs += [ ":os_config" ] + + deps = [ "//third_party/bounds_checking_function:libsec_static" ] + deps += [ "//third_party/musl/porting/rtos/kernel:kernel" ] +} + +group("kernel") { + deps = [ ":libkernel" ] +} + +executable("uniproton") { + configs += [ + ":os_config", + ] + + ldflags = [ + "-static", + "-Wl,--gc-sections", + "-Wl,-Map=$uniproton_name.map", + ] + + output_dir = target_out_dir + + deps = [ ":kernel" ] + + if (HAVE_DEVICE_SDK) { + deps += [ + "$device_path:device", + "$product_path:$product" + ] + } +} + +copy("copy_image") { + deps = [ ":uniproton" ] + sources = [ "$target_out_dir/unstripped/bin/uniproton" ] + outputs = [ "$root_out_dir/$uniproton_name" ] +} + +build_ext_component("build_kernel_image") { + deps = [ ":copy_image" ] + exec_path = rebase_path(root_out_dir) + + objcopy = "${compile_prefix}objcopy$toolchain_cmd_suffix" + objdump = "${compile_prefix}objdump$toolchain_cmd_suffix" + + command = "$objcopy -O binary $uniproton_name $uniproton_name.bin" + command += + " && sh -c '$objdump -t $uniproton_name | sort >$uniproton_name.sym.sorted'" + command += " && sh -c '$objdump -d $uniproton_name >$uniproton_name.asm'" +} diff --git a/build/bundle.json b/build/bundle.json new file mode 100644 index 0000000000000000000000000000000000000000..da15cfd2de46228810bb2f1c5a0e0b2696e1500c --- /dev/null +++ b/build/bundle.json @@ -0,0 +1,55 @@ +{ + "name": "@ohos/uniproton", + "version": "3.1.0", + "description": "uniproton kernel", + "publishAs": "code-segment", + "homePage": "https://gitee.com/openeuler/UniProton", + "repository": "https://gitee.com/openeuler/UniProton", + "license": "BSD 3-clause", + "domain": "os", + "language": "", + "private": false, + "scripts": {}, + "tags": [ + "kernel" + ], + "keywords": [ + "kernel", + "uniproton" + ], + "envs": [], + "dirs": [], + "author": {}, + "contributors": [], + "segment": { + "destPath": "kernel/uniproton/build" + }, + "component": { + "name": "uniproton", + "subsystem": "kernel", + "syscap": [ + "SystemCapability.Kernel.uniproton" + ], + "features": [], + "adapted_system_type": [ + "mini" + ], + "rom": "300KB", + "ram": "100KB", + "deps": { + "components": [ + "utils_lite" + ], + "third_party": [ + "bounds_checking_function" + ] + }, + "build": { + "sub_component": [ + "//kernel/uniproton/build:build_kernel_image" + ], + "inner_kits": [], + "test": [] + } + } +} diff --git a/build/uniproton.gni b/build/uniproton.gni new file mode 100644 index 0000000000000000000000000000000000000000..0693f6038e59a5dca88ae4d98909acb75cd005d8 --- /dev/null +++ b/build/uniproton.gni @@ -0,0 +1,132 @@ +# Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of +# conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list +# of conditions and the following disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors may be used +# to endorse or promote products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import("//build/lite/config/component/lite_component.gni") + +MENUCONFIG_H = rebase_path("$root_out_dir/config.h") + +os_config_file = "${ohos_build_type}.config" + +os_config_file = + rebase_path(os_config_file, "", "$product_path/kernel_configs") +print("os_config_file:", os_config_file) + +exec_script("//build/lite/run_shell_cmd.py", + [ "env" + " CONFIG_=" + " KCONFIG_CONFIG_HEADER='y=true'" + + " KCONFIG_CONFIG=$os_config_file" + + " BOARD_COMPANY=$device_company" + + " DEVICE_PATH=$device_path" + " srctree=" + rebase_path(".") + "/../" + + " genconfig" + " --header-path $MENUCONFIG_H" + + " --file-list kconfig_files.txt" + + " --env-list kconfig_env.txt" + " --config-out config.gni" ], + "", + [ os_config_file ]) + +import("$root_out_dir/config.gni") + +OSTOPDIR = "//kernel/uniproton/UniProton/src" +OSTHIRDPARTY = "//third_party" + +kernel_base_sources = [ + "$OSTOPDIR/config/prt_config.c", + "$OSTOPDIR/core/ipc/event/prt_event.c", + "$OSTOPDIR/core/ipc/queue/prt_queue.c", + "$OSTOPDIR/core/ipc/queue/prt_queue_del.c", + "$OSTOPDIR/core/ipc/queue/prt_queue_init.c", + "$OSTOPDIR/core/ipc/queue/prt_queue_minor.c", + "$OSTOPDIR/core/ipc/sem/prt_sem.c", + "$OSTOPDIR/core/ipc/sem/prt_sem_init.c", + "$OSTOPDIR/core/ipc/sem/prt_sem_minor.c", + "$OSTOPDIR/core/kernel/irq/prt_irq.c", + "$OSTOPDIR/core/kernel/kexc/prt_kexc.c", + "$OSTOPDIR/core/kernel/sys/prt_sys.c", + "$OSTOPDIR/core/kernel/sys/prt_sys_init.c", + "$OSTOPDIR/core/kernel/sys/prt_sys_time.c", + "$OSTOPDIR/core/kernel/task/prt_amp_task.c", + "$OSTOPDIR/core/kernel/task/prt_amp_task_del.c", + "$OSTOPDIR/core/kernel/task/prt_amp_task_init.c", + "$OSTOPDIR/core/kernel/task/prt_amp_task_minor.c", + "$OSTOPDIR/core/kernel/task/prt_task.c", + "$OSTOPDIR/core/kernel/task/prt_task_attrib.c", + "$OSTOPDIR/core/kernel/task/prt_task_del.c", + "$OSTOPDIR/core/kernel/task/prt_task_global.c", + "$OSTOPDIR/core/kernel/task/prt_task_info.c", + "$OSTOPDIR/core/kernel/task/prt_task_init.c", + "$OSTOPDIR/core/kernel/task/prt_task_minor.c", + "$OSTOPDIR/core/kernel/task/prt_task_priority.c", + "$OSTOPDIR/core/kernel/task/prt_task_sem.c", + "$OSTOPDIR/core/kernel/task/prt_taskself_id.c", + "$OSTOPDIR/core/kernel/tick/prt_tick.c", + "$OSTOPDIR/core/kernel/tick/prt_tick_init.c", + "$OSTOPDIR/core/kernel/timer/swtmr/prt_swtmr.c", + "$OSTOPDIR/core/kernel/timer/swtmr/prt_swtmr_init.c", + "$OSTOPDIR/core/kernel/timer/swtmr/prt_swtmr_minor.c", + "$OSTOPDIR/core/kernel/timer/prt_timer.c", + "$OSTOPDIR/core/kernel/timer/prt_timer_minor.c", +] + +kernel_mem_sources = [ + "$OSTOPDIR/mem/prt_mem.c", + "$OSTOPDIR/mem/fsc/prt_fscmem.c" +] + +kernel_om_sources = [ + "$OSTOPDIR/om/cpup/prt_cpup.c", + "$OSTOPDIR/om/cpup/prt_cpup_minor.c", + "$OSTOPDIR/om/cpup/prt_cpup_thread.c", + "$OSTOPDIR/om/cpup/prt_cpup_thread_64.c", + "$OSTOPDIR/om/cpup/prt_cpup_thread_init.c", + "$OSTOPDIR/om/cpup/prt_cpup_warn.c", + "$OSTOPDIR/om/err/prt_err.c", + "$OSTOPDIR/om/err/prt_err_init.c", + "$OSTOPDIR/om/hook/prt_hook_init.c", +] + +kernel_security_sources = [ + "$OSTOPDIR/security/rnd/prt_rnd_set.c" +] + +kernel_utility_sources = [ + "$OSTOPDIR/utility/lib/prt_lib_math64.c", + "$OSTOPDIR/utility/lib/prt_lib_version.c" +] + +arch_cortex_m4_sources = [ + "$OSTOPDIR/arch/cpu/armv7-m/common/boot/prt_hw_boot.c", + "$OSTOPDIR/arch/cpu/armv7-m/common/exc/prt_exc.c", + "$OSTOPDIR/arch/cpu/armv7-m/common/hwi/prt_hwi.c", + "$OSTOPDIR/arch/cpu/armv7-m/common/hwi/prt_vi_dispatch.c", + "$OSTOPDIR/arch/cpu/armv7-m/common/tick/prt_hw_tick.c", + "$OSTOPDIR/arch/cpu/armv7-m/common/tick/prt_hw_tick_minor.c", + "$OSTOPDIR/arch/cpu/armv7-m/common/prt_port.c", + "$OSTOPDIR/arch/cpu/armv7-m/cortex-m4/prt_dispatch.S", + "$OSTOPDIR/arch/cpu/armv7-m/cortex-m4/prt_div64.c", + "$OSTOPDIR/arch/cpu/armv7-m/cortex-m4/prt_hw.S", + "$OSTOPDIR/arch/cpu/armv7-m/cortex-m4/prt_hw_exc.S", + "$OSTOPDIR/arch/cpu/armv7-m/cortex-m4/prt_vector.S", +] diff --git a/config/Kconfig b/config/Kconfig new file mode 100644 index 0000000000000000000000000000000000000000..618660cb769690a9f22459b9b90007eb423a0f88 --- /dev/null +++ b/config/Kconfig @@ -0,0 +1,9 @@ +mainmenu "UniProton Configuration" + +#should source arch Kconfig first +source "config/arch/Kconfig" +source "config/core/Kconfig" +source "config/mem/Kconfig" +source "config/om/Kconfig" +source "config/security/Kconfig" +source "config/utility/Kconfig" diff --git a/config/arch/Kconfig b/config/arch/Kconfig new file mode 100644 index 0000000000000000000000000000000000000000..19e0b7d90983717e5a031c2a04a702ee51b29c84 --- /dev/null +++ b/config/arch/Kconfig @@ -0,0 +1,31 @@ +menu "Arch Modules Configuration" + +source "config/arch/cpu/Kconfig" + +menu "Generic Configuration" +config CONFIG_HARDWARE_PLATFORM + string + default "OS_CORTEX_M4" if INTERNAL_OS_PLATFORM_M4 + +config OS_CPU_TYPE + string + default "OS_STM32F407" if INTERNAL_OS_CORTEX_M4 + +config OS_MAX_CORE_NUM + int "The maxinum number of cores" + default 1 if INTERNAL_OS_PLATFORM_M4 + +config INTERNAL_OS_BYTE_ORDER_LE + bool + default y + help + This indicates little endian if y + +config OS_BYTE_ORDER + string + default "OS_LITTLE_ENDIAN" if INTERNAL_OS_BYTE_ORDER_LE + default "OS_BIG_ENDIAN" if !INTERNAL_OS_BYTE_ORDER_LE + +endmenu + +endmenu diff --git a/config/arch/cpu/Kconfig b/config/arch/cpu/Kconfig new file mode 100644 index 0000000000000000000000000000000000000000..ce7b1e68b4d063d67997df0ca3227c55a0b54a61 --- /dev/null +++ b/config/arch/cpu/Kconfig @@ -0,0 +1,8 @@ +choice + prompt "Platform Setup" +config OS_ARCH_ARMV7_M + bool "ARMV7_M" +endchoice + +source "config/arch/cpu/armv7-m/Kconfig" + diff --git a/config/arch/cpu/armv7-m/Kconfig b/config/arch/cpu/armv7-m/Kconfig new file mode 100644 index 0000000000000000000000000000000000000000..3d26fef4c9dd005cebea46881adc7c405ed51a7c --- /dev/null +++ b/config/arch/cpu/armv7-m/Kconfig @@ -0,0 +1,78 @@ +menu "ARM7-M Sepecfic Configuration" + +depends on OS_ARCH_ARMV7_M + +config INTERNAL_OS_CORTEX_M4 + bool + select INTERNAL_OS_BYTE_ORDER_LE + +choice + prompt "Cpu Type" + +config INTERNAL_OS_PLATFORM_M4 + bool "CORTEX_M4" + select INTERNAL_OS_CORTEX_M4 + +endchoice + +config ARCH_CPU + string + default "cortex-m4" if INTERNAL_OS_CORTEX_M4 + +config THUMB + string + default "thumb" if INTERNAL_OS_CORTEX_M4 + +choice + prompt "Arch float type" + default ARCH_FLOAT_SOFTFP + +config ARCH_FLOAT_SOFT + bool "soft" + +config ARCH_FLOAT_SOFTFP + bool "softfp" + +config ARCH_FLOAT_HARD + bool "hard" + +endchoice + +config ARCH_FLOAT + string + default "soft" if ARCH_FLOAT_SOFT + default "softfp" if ARCH_FLOAT_SOFTFP + default "hard" if ARCH_FLOAT_HARD + +choice + prompt "Arch fpu type" + default ARCH_FPU_VFPV4_D16 + +config ARCH_FPU_VFPV3 + bool "vfpv3" + +config ARCH_FPU_VFPV3_D16 + bool "vfpv3-d16" + +config ARCH_FPU_NEON_VFPV4 + bool "neon-vfpv4" + +config ARCH_FPU_VFPV4 + bool "vfpv4" + +config ARCH_FPU_VFPV4_D16 + bool "vfpv4-d16" + +endchoice + +config ARCH_FPU + string + default "vfpv3" if ARCH_FPU_VFPV3 + default "vfpv3-d16" if ARCH_FPU_VFPV3_D16 + default "neon-vfpv4" if ARCH_FPU_NEON_VFPV4 + default "vfpv4" if ARCH_FPU_VFPV4 + default "vfpv4-d16" if ARCH_FPU_VFPV4_D16 + +source config/arch/cpu/armv7-m/cortex-m4/Kconfig + +endmenu diff --git a/config/arch/cpu/armv7-m/cortex-m4/Kconfig b/config/arch/cpu/armv7-m/cortex-m4/Kconfig new file mode 100644 index 0000000000000000000000000000000000000000..5fbda2e62bf2589389a74b4fbb96146776145d75 --- /dev/null +++ b/config/arch/cpu/armv7-m/cortex-m4/Kconfig @@ -0,0 +1,4 @@ +menu "M4 Sepecfic Configuration" +depends on INTERNAL_OS_PLATFORM_M4 + +endmenu diff --git a/config/core/Kconfig b/config/core/Kconfig new file mode 100644 index 0000000000000000000000000000000000000000..3a02484d934dd1f7b5f8e5884f9b6f9b6f90b176 --- /dev/null +++ b/config/core/Kconfig @@ -0,0 +1,6 @@ +menu "Core Modules Configuration" + +source "config/core/ipc/Kconfig" +source "config/core/kernel/Kconfig" + +endmenu diff --git a/config/core/ipc/Kconfig b/config/core/ipc/Kconfig new file mode 100644 index 0000000000000000000000000000000000000000..3b891c972abc2e1efb37f71dd01bdf90e7770055 --- /dev/null +++ b/config/core/ipc/Kconfig @@ -0,0 +1,6 @@ +menu "IPC Modules Configuration" +source "config/core/ipc/event/Kconfig" +source "config/core/ipc/queue/Kconfig" +source "config/core/ipc/sem/Kconfig" + +endmenu diff --git a/config/core/ipc/event/Kconfig b/config/core/ipc/event/Kconfig new file mode 100644 index 0000000000000000000000000000000000000000..b0ba40f6e7f54d0b8f5cc9fd10d8187be7ed812d --- /dev/null +++ b/config/core/ipc/event/Kconfig @@ -0,0 +1,7 @@ +menu "Event feature configuration" + +config OS_OPTION_EVENT + bool "Whether support event module or not" + default n + +endmenu diff --git a/config/core/ipc/queue/Kconfig b/config/core/ipc/queue/Kconfig new file mode 100644 index 0000000000000000000000000000000000000000..f6b32610edb66a3c34a764b897b07332c43c1a21 --- /dev/null +++ b/config/core/ipc/queue/Kconfig @@ -0,0 +1,4 @@ +config OS_OPTION_QUEUE + bool "Whether support normal queue module or not" + default n + diff --git a/config/core/ipc/sem/Kconfig b/config/core/ipc/sem/Kconfig new file mode 100644 index 0000000000000000000000000000000000000000..98be101fbb96a56de99aa0f7aa4f73e9c33637a0 --- /dev/null +++ b/config/core/ipc/sem/Kconfig @@ -0,0 +1,2 @@ +menu "Semaphore feature configuration" +endmenu diff --git a/config/core/kernel/Kconfig b/config/core/kernel/Kconfig new file mode 100644 index 0000000000000000000000000000000000000000..d9104dff4d986f77ace43cfde1230b8d2b312d18 --- /dev/null +++ b/config/core/kernel/Kconfig @@ -0,0 +1,8 @@ +menu "Kernel Modules Configuration" +source "config/core/kernel/irq/Kconfig" +source "config/core/kernel/kexc/Kconfig" +source "config/core/kernel/sys/Kconfig" +source "config/core/kernel/task/Kconfig" +source "config/core/kernel/tick/Kconfig" +source "config/core/kernel/timer/Kconfig" +endmenu diff --git a/config/core/kernel/irq/Kconfig b/config/core/kernel/irq/Kconfig new file mode 100644 index 0000000000000000000000000000000000000000..d45973d30394db48d63881c02e3186a25ea106b9 --- /dev/null +++ b/config/core/kernel/irq/Kconfig @@ -0,0 +1,23 @@ +menu "IRQ Modules Configuration" + +config OS_OPTION_HWI_COMBINE + bool "Whether support hw interrupt combination feature or not" + default y if OS_OPTION_HWI_ATTRIBUTE + default n if !OS_OPTION_HWI_ATTRIBUTE + +config OS_OPTION_HWI_PRIORITY + bool "Whether support hwi priority set or not" + default y + +config OS_OPTION_HWI_ATTRIBUTE + bool "Whether support hwi attribute and Param set or not" + default y + +config OS_OPTION_HWI_MAX_NUM_CONFIG + bool "Whether support interrupt max number config or not" + default n + help + If the number of interrupts needs to be configured, select Y. Otherwise, select N. + Select Y for the current M4 platform and N for other platforms. + +endmenu diff --git a/config/core/kernel/kexc/Kconfig b/config/core/kernel/kexc/Kconfig new file mode 100644 index 0000000000000000000000000000000000000000..366b03ab4485a6254bc808ab7a25d508e513de3e --- /dev/null +++ b/config/core/kernel/kexc/Kconfig @@ -0,0 +1,2 @@ +menu "Exc Modules Configuration" +endmenu diff --git a/config/core/kernel/sys/Kconfig b/config/core/kernel/sys/Kconfig new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/config/core/kernel/task/Kconfig b/config/core/kernel/task/Kconfig new file mode 100644 index 0000000000000000000000000000000000000000..94e89393c03a60479a889f2592c781c7630de4b0 --- /dev/null +++ b/config/core/kernel/task/Kconfig @@ -0,0 +1,46 @@ +menu "Task module Configuration" + +config OS_OPTION_TASK + bool "Whether support task module or not" + default n + +menu "TASK features configuration" + depends on OS_OPTION_TASK + +config OS_OPTION_TASK_DELETE + bool "Whether support task delete feature or not" + default n + +config OS_OPTION_TASK_SUSPEND + bool "Whether support suspend task feature or not" + default n + +config OS_OPTION_TASK_INFO + bool "Whether support get task information or not" + default n + +config OS_OPTION_TASK_YIELD + bool "Whether support task yield feature or not" + default n + help + if OS_OPTION_TASK_YIELD=y,when taskdelay(0),can sch task to end list + +endmenu + +config OS_TSK_PRIORITY_HIGHEST + int "The highest priority" + default 0 + +config OS_TSK_PRIORITY_LOWEST + int "The lowest priority" + default 31 + +config OS_TSK_NUM_OF_PRIORITIES + int "The number of priority" + default 32 + +config OS_TSK_CORE_BYTES_IN_PID + int "The number of bytes used to indicate core ID in PID " + default 3 + +endmenu diff --git a/config/core/kernel/tick/Kconfig b/config/core/kernel/tick/Kconfig new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/config/core/kernel/timer/Kconfig b/config/core/kernel/timer/Kconfig new file mode 100644 index 0000000000000000000000000000000000000000..40ea69574a14860d1a6f896d05242446c985893f --- /dev/null +++ b/config/core/kernel/timer/Kconfig @@ -0,0 +1,7 @@ +menu "Timer Modules Configuration" + +config INTERNAL_OS_SWTMR + bool "Whether support software timer or not" + default n + +endmenu diff --git a/config/mem/Kconfig b/config/mem/Kconfig new file mode 100644 index 0000000000000000000000000000000000000000..dca79700bc304bc637bca01be35b1d45da299956 --- /dev/null +++ b/config/mem/Kconfig @@ -0,0 +1,2 @@ +menu "MM Modules Configuration" +endmenu diff --git a/config/om/Kconfig b/config/om/Kconfig new file mode 100644 index 0000000000000000000000000000000000000000..8f08eb5dc20b12711fb598c38ac5f56b100efff7 --- /dev/null +++ b/config/om/Kconfig @@ -0,0 +1,8 @@ +menu "OM Modules Configuration" + +source "config/om/cpup/Kconfig" +source "config/om/err/Kconfig" +source "config/om/hook/Kconfig" + +endmenu +#must ended with empty line diff --git a/config/om/cpup/Kconfig b/config/om/cpup/Kconfig new file mode 100644 index 0000000000000000000000000000000000000000..e65bef92b4ff8ea7571c08e5c0fe4d70412ea86e --- /dev/null +++ b/config/om/cpup/Kconfig @@ -0,0 +1,17 @@ +config OS_OPTION_CPUP + bool "Whether support cpup or not" + default n + +menu "CPUP features configuration" + depends on OS_OPTION_CPUP + +choice + prompt "Cpup Mode" +config INTERNAL_OS_CPUP_THREAD + bool "CPUP_MODE_THREAD" +endchoice + +config OS_OPTION_CPUP_WARN + bool "Whether support cpup warn or not" + default n +endmenu diff --git a/config/om/err/Kconfig b/config/om/err/Kconfig new file mode 100644 index 0000000000000000000000000000000000000000..1a8607ab2ebb7d2b0d93cf771d1e4b0a0e3d560e --- /dev/null +++ b/config/om/err/Kconfig @@ -0,0 +1,2 @@ +menu "Error Report Module Configuration" +endmenu diff --git a/config/om/hook/Kconfig b/config/om/hook/Kconfig new file mode 100644 index 0000000000000000000000000000000000000000..41f3cd8c4ad6f3a75eb2bf1122c070a2a8d3fb19 --- /dev/null +++ b/config/om/hook/Kconfig @@ -0,0 +1,2 @@ +menu "Hook feature configuration" +endmenu diff --git a/config/prt_buildef.h b/config/prt_buildef.h new file mode 100755 index 0000000000000000000000000000000000000000..52412a41c569ab018cc4458486ecf4853b756000 --- /dev/null +++ b/config/prt_buildef.h @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef _PRT_BUILDEF_H +#define _PRT_BUILDEF_H + +#ifdef OS_ARCH_ARMV7_M +#include "os_attr_armv7_m_external.h" +#endif + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cplusplus */ +#endif /* __cplusplus */ + +#ifndef OS_TSK_NUM_OF_PRIORITIES +#define OS_TSK_NUM_OF_PRIORITIES 63 +#endif + +#ifndef OS_TSK_PRIORITY_LOWEST +#define OS_TSK_PRIORITY_LOWEST (OS_TSK_NUM_OF_PRIORITIES - 1) +#endif + +#ifndef OS_TSK_STACK_ADDR_ALIGN +#define OS_TSK_STACK_ADDR_ALIGN 16 +#endif + +#ifndef OS_REGISTER_ID +#define OS_REGISTER_ID 0 +#endif + +#ifndef OS_INIT_ID +#define OS_INIT_ID 1 +#endif + +#ifndef OS_TSK_CORE_BYTES_IN_PID +#define OS_TSK_CORE_BYTES_IN_PID 3 +#endif + +#ifndef OS_MOUDLE_CONFIG +#define OS_MOUDLE_CONFIG 2 +#endif + +#define OS_CORTEX_M4 4 + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cplusplus */ +#endif /* __cplusplus */ + +#endif /* _PRT_BUILDEF_H */ diff --git a/config/prt_config.h b/config/prt_config.h new file mode 100644 index 0000000000000000000000000000000000000000..0873c5cfe89750eacf6a55bf1d25ffd6adba571d --- /dev/null +++ b/config/prt_config.h @@ -0,0 +1,167 @@ +/* + * Copyright (c) 2022-2022 Huawei Technologies Co., Ltd. All rights reserved. + * + * UniProton is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * http://license.coscl.org.cn/MulanPSL2 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + * Create: 2009-12-22 + * Description: UniProton配置头文件,裁剪开关和配置项。 + */ +#ifndef PRT_CONFIG_H +#define PRT_CONFIG_H + +#ifdef OS_DEVICE_CONFIG +#include "target_config.h" +#endif + +#include "prt_buildef.h" +#include "prt_typedef.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif +#endif + +/* ***************************** 配置系统基本信息 ******************************* */ +/* 芯片主频 */ +#ifndef OS_SYS_CLOCK +#define OS_SYS_CLOCK 0 +#endif + +/* ***************************** 中断模块配置 ************************** */ +/* 硬中断最大支持个数 */ +#ifndef OS_HWI_MAX_NUM_CONFIG +#define OS_HWI_MAX_NUM_CONFIG 150 +#endif + +/* ***************************** 配置Tick中断模块 *************************** */ +/* Tick中断模块裁剪开关 */ +#ifndef OS_INCLUDE_TICK +#define OS_INCLUDE_TICK YES +#endif + +/* Tick中断时间间隔,tick处理时间不能超过1/OS_TICK_PER_SECOND(s) */ +#ifndef OS_TICK_PER_SECOND +#define OS_TICK_PER_SECOND 5000 +#endif + +/* ***************************** 配置定时器模块 ***************************** */ +/* 基于TICK的软件定时器裁剪开关 */ +#ifndef OS_INCLUDE_TICK_SWTMER +#define OS_INCLUDE_TICK_SWTMER NO +#endif + +/* 基于TICK的软件定时器最大个数 */ +#ifndef OS_TICK_SWITIMER_MAX_NUM +#define OS_TICK_SWITIMER_MAX_NUM 8 +#endif + +/* ***************************** 配置任务模块 ******************************* */ +/* 任务模块裁剪开关 */ +#ifndef OS_INCLUDE_TASK +#define OS_INCLUDE_TASK YES +#endif +/* 最大支持的任务数,最大共支持254个 */ +#ifndef OS_TSK_MAX_SUPPORT_NUM +#define OS_TSK_MAX_SUPPORT_NUM 8 +#endif +/* 缺省的任务栈大小 */ +#ifndef OS_TSK_DEFAULT_STACK_SIZE +#define OS_TSK_DEFAULT_STACK_SIZE 0x800 +#endif +/* IDLE任务栈的大小 */ +#ifndef OS_TSK_IDLE_STACK_SIZE +#define OS_TSK_IDLE_STACK_SIZE 0x800 +#endif +/* 任务栈初始化魔术字,默认是0xCA,只支持配置一个字节 */ +#ifndef OS_TSK_STACK_MAGIC_WORD +#define OS_TSK_STACK_MAGIC_WORD 0xCA +#endif + +/* ***************************** 配置CPU占用率及CPU告警模块 **************** */ +/* CPU占用率模块裁剪开关 */ +#ifndef OS_INCLUDE_CPUP +#define OS_INCLUDE_CPUP NO +#endif +/* 采样时间间隔(单位tick),若其值大于0,则作为采样周期,否则两次调用PRT_CpupNow或PRT_CpupThread间隔作为周期 */ +#ifndef OS_CPUP_SAMPLE_INTERVAL +#define OS_CPUP_SAMPLE_INTERVAL 0 +#endif +/* CPU占用率告警动态配置项 */ +#ifndef OS_CONFIG_CPUP_WARN +#define OS_CONFIG_CPUP_WARN NO +#endif +/* CPU占用率告警阈值(精度为万分比) */ +#ifndef OS_CPUP_SHORT_WARN +#define OS_CPUP_SHORT_WARN 0 +#endif +/* CPU占用率告警恢复阈值(精度为万分比) */ +#ifndef OS_CPUP_SHORT_RESUME +#define OS_CPUP_SHORT_RESUME 0 +#endif + +/* ***************************** 配置内存管理模块 ************************** */ +/* 用户可以创建的最大分区数,取值范围[0,253] */ +#ifndef OS_MEM_MAX_PT_NUM +#define OS_MEM_MAX_PT_NUM 10 +#endif +/* 私有FSC内存分区起始地址 */ +#ifndef OS_MEM_FSC_PT_ADDR +#define OS_MEM_FSC_PT_ADDR NULL +#endif +/* 私有FSC内存分区大小 */ +#ifndef OS_MEM_FSC_PT_SIZE +#define OS_MEM_FSC_PT_SIZE 0 +#endif + +/* ***************************** 配置信号量管理模块 ************************* */ +/* 信号量模块裁剪开关 */ +#ifndef OS_INCLUDE_SEM +#define OS_INCLUDE_SEM NO +#endif +/* 最大支持的信号量数 */ +#ifndef OS_SEM_MAX_SUPPORT_NUM +#define OS_SEM_MAX_SUPPORT_NUM 0 +#endif + +/* ***************************** 配置队列模块 ******************************* */ +/* 队列模块裁剪开关 */ +#ifndef OS_INCLUDE_QUEUE +#define OS_INCLUDE_QUEUE NO +#endif +/* 最大支持的队列数,范围(0,0xFFFF] */ +#ifndef OS_QUEUE_MAX_SUPPORT_NUM +#define OS_QUEUE_MAX_SUPPORT_NUM 10 +#endif + +/* ************************* 钩子模块配置 *********************************** */ +/* 硬中断进入钩子最大支持个数, 范围[0, 255] */ +#ifndef OS_HOOK_HWI_ENTRY_NUM +#define OS_HOOK_HWI_ENTRY_NUM 0 +#endif +/* 硬中断退出钩子最大支持个数, 范围[0, 255] */ +#ifndef OS_HOOK_HWI_EXIT_NUM +#define OS_HOOK_HWI_EXIT_NUM 0 +#endif +/* 任务切换钩子最大支持个数, 范围[0, 255] */ +#ifndef OS_HOOK_TSK_SWITCH_NUM +#define OS_HOOK_TSK_SWITCH_NUM 0 +#endif +/* IDLE钩子最大支持个数, 范围[0, 255] */ +#ifndef OS_HOOK_IDLE_NUM +#define OS_HOOK_IDLE_NUM 0 +#endif + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +#endif /* PRT_CONFIG_H */ diff --git a/config/security/Kconfig b/config/security/Kconfig new file mode 100644 index 0000000000000000000000000000000000000000..b5d51bbd41af46a392ec0aaaf8e2d3807d0d3614 --- /dev/null +++ b/config/security/Kconfig @@ -0,0 +1,7 @@ +menu "security Modules Configuration" + +config OS_OPTION_RND + bool "Whether support user set rnd or not" + default n + +endmenu diff --git a/config/utility/Kconfig b/config/utility/Kconfig new file mode 100644 index 0000000000000000000000000000000000000000..bbf464700b0f8d2d565288262f0a65939c7fae88 --- /dev/null +++ b/config/utility/Kconfig @@ -0,0 +1,2 @@ +menu "Utility Modules Configuration" +endmenu