Compare commits
352 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e268ef95a9 | |||
| 296a546bcd | |||
| a7135e252d | |||
| e76dd685c2 | |||
| 54a5365a25 | |||
| 2d1160fdc4 | |||
| f3d606b6dd | |||
| 392e4c2cec | |||
| b334658723 | |||
| 2b1f2d554e | |||
| 2cf290bb7c | |||
| 8fc9852e34 | |||
| 816d03f5c1 | |||
| 61877ec97a | |||
| 0f952132c0 | |||
| f94d3ee119 | |||
| 784429d0dc | |||
| 1a764df92a | |||
| cf50cde1b7 | |||
| bfef7bfb2e | |||
| 5bae8b58c6 | |||
| 044cf59583 | |||
| 0adbafb9c2 | |||
| 3398937b1b | |||
| 3c010b4717 | |||
| c237ff63fa | |||
| 3508110f6d | |||
| ffa868a81c | |||
| 7d391c9bbf | |||
| e4a1c18d40 | |||
| 83790f4f9b | |||
| 6377f98e9e | |||
| b8f8ab5a36 | |||
| a0b776a709 | |||
| f5f18ca669 | |||
| 5756d45e84 | |||
| 8a25f31aa4 | |||
| f7cc6ff14e | |||
| bf9e0c9e2b | |||
| e9de74a94a | |||
| b38f135242 | |||
| 0cb50baa55 | |||
| 565049f1eb | |||
| 9add4b4b92 | |||
| 5992506c75 | |||
| d4db5a5a75 | |||
| fe8b68826a | |||
| 99640e9977 | |||
| 0dc3c7ae9e | |||
| 699bb81fc3 | |||
| f2c4b59773 | |||
| b656553c5c | |||
| 7653bd8da1 | |||
| 1275ecbc8a | |||
| ebc57397f0 | |||
| cce6365f4f | |||
| 04f391d814 | |||
| 14e64fc89b | |||
| 2ce5ce9397 | |||
| eb40e4a068 | |||
| dc5feb9e19 | |||
| 7a61f8d836 | |||
| 330760dbb3 | |||
| 2739a00c55 | |||
| 7f14b060d4 | |||
| 8be6e129fc | |||
| f465c15d7a | |||
| 0af2577498 | |||
| 238ff396b8 | |||
| 5917c4b01b | |||
| 5c4edb9b1a | |||
| ce176e77e6 | |||
| 8ef012bdad | |||
| 933efffba7 | |||
| ae692bfbc4 | |||
| ab46b9c836 | |||
| b83d17039e | |||
| 08404f3252 | |||
| 8b19c3cbe4 | |||
| 192a2a6e61 | |||
| 2ec2c369e7 | |||
| f2b280bdbd | |||
| c09b3a8774 | |||
| 04cded2f0a | |||
| ddfb363675 | |||
| d0c50a4af0 | |||
| 6affe19d5a | |||
| a36d5d9058 | |||
| 63bf098b0f | |||
| 252052f024 | |||
| 8c46636052 | |||
| 6ff615b9ca | |||
| 732a346399 | |||
| 2931dc6013 | |||
| df30bc4e0a | |||
| 1599669290 | |||
| d8104f6290 | |||
| 3a190a1a1b | |||
| e1f986305b | |||
| 0c8b7d2a1b | |||
| 62eb96dd8d | |||
| 009d2503fb | |||
| 39839d313c | |||
| d92c10d92d | |||
| 915b97b18e | |||
| 9d0460b546 | |||
| 12e8541b6f | |||
| 8170152730 | |||
| f7d79148b7 | |||
| ad29f69777 | |||
| 85663b9258 | |||
| 4bd88ffb1f | |||
| 6f92337be2 | |||
| 7add94de1f | |||
| dd36f4482c | |||
| dcb2dbee77 | |||
| 6a7a18e2d3 | |||
| 7ecdbbe6d7 | |||
| e9425d1833 | |||
| 527f6cf86e | |||
| df9387c28f | |||
| d08a3e3f13 | |||
| 48ff5189b8 | |||
| 600283a96f | |||
| a333e8f88e | |||
| ce49331798 | |||
| fc8c547b05 | |||
| 8cfadb9b4d | |||
| 2c5b750a46 | |||
| 3df936f1a1 | |||
| 6fa1fe5993 | |||
| 8a05eb6e08 | |||
| 243fe55c68 | |||
| a7341d81d1 | |||
| c8ce65f408 | |||
| c1e3856bbe | |||
| 3a887c616a | |||
| 3303cd7bc1 | |||
| 7c5a05f352 | |||
| 5df101eae5 | |||
| 128c3dffb5 | |||
| e8f3f9674c | |||
| 5cfec18d24 | |||
| def41f8edd | |||
| 3387c32b8a | |||
| 6881d3da46 | |||
| e21e8753d1 | |||
| 397f24dd6f | |||
| 831d089652 | |||
| f5fa92feff | |||
| bed1d28df8 | |||
| efebc00f87 | |||
| 28c1529e2f | |||
| 159d304275 | |||
| 18f65ae0b3 | |||
| 5363e4b472 | |||
| c65d908905 | |||
| 1b9d59aa9a | |||
| c6958aa181 | |||
| 315a448142 | |||
| 32a2e193f4 | |||
| b35792fa6c | |||
| a5e651cb01 | |||
| f12dd8bbe6 | |||
| 3f41c36926 | |||
| a3daa77e53 | |||
| fb740f9b23 | |||
| a45bf8797c | |||
| 84f89b9660 | |||
| 03b4650a16 | |||
| 728aca27f5 | |||
| 91743d3ea4 | |||
| fcd677feba | |||
| c4fd9be138 | |||
| 81249a0384 | |||
| 8746f5abe5 | |||
| 56565beeb6 | |||
| a77aa7de98 | |||
| db8c284cd1 | |||
| b1daca7f82 | |||
| 46546688c9 | |||
| d017af7459 | |||
| 4e9f8c71f9 | |||
| e34c4050f9 | |||
| 67b579161d | |||
| d5b90399b7 | |||
| 1ab2ffcd4a | |||
| ec9f0e47e9 | |||
| 8550117b01 | |||
| f29973e995 | |||
| 9e0e39f277 | |||
| 2f19ba3653 | |||
| fe7191183e | |||
| d84471ff29 | |||
| 45654cee93 | |||
| 110ee01118 | |||
| b51e7f93d4 | |||
| 2d9e476c0b | |||
| 9ee49f1bb8 | |||
| befe8ecf9d | |||
| 637de91170 | |||
| 390a488a97 | |||
| 9d3d983376 | |||
| 0e2dded346 | |||
| b0393151a6 | |||
| 38f8472ddb | |||
| 7167ba7578 | |||
| d28c8a0423 | |||
| 17daa50fa2 | |||
| 57a0002252 | |||
| 4f12ab9a2a | |||
| e703376d68 | |||
| 8f1dc3a1ff | |||
| 9bf8ff9ce5 | |||
| a09d4882c4 | |||
| 98a82ba357 | |||
| e7e850a6a6 | |||
| 3ad47afec4 | |||
| 6f04b5345c | |||
| 83b6331aad | |||
| 67a5b580f6 | |||
| f5ee192962 | |||
| a42ba7aed6 | |||
| 1fc024a158 | |||
| 21ee0b2c1d | |||
| b0cfa5e52c | |||
| 543732f522 | |||
| dab1a0d62f | |||
| 6a8f24ba01 | |||
| 40bbb4d6c4 | |||
| 90a027090a | |||
| bcd177bbd3 | |||
| cde2b3bd31 | |||
| e3e9b2f5a5 | |||
| 536e9b4584 | |||
| 632ea10418 | |||
| 73b77d11a1 | |||
| 9aa32ae743 | |||
| 133e87b1b1 | |||
| 09034de68a | |||
| 867a6edcdc | |||
| 3dceae52aa | |||
| 43baa4fdc4 | |||
| bedef30658 | |||
| 7e284239b3 | |||
| f34b94e98d | |||
| bc33bcd319 | |||
| ae7a374ebb | |||
| fb76350771 | |||
| ea5b2e8ae4 | |||
| c5a3ed4fb1 | |||
| 7688a3f52d | |||
| 590ab9182d | |||
| ed863e90dd | |||
| 491cefae76 | |||
| 36887d467d | |||
| 9f393bcc6d | |||
| fe4db41b7c | |||
| 5c982f1087 | |||
| 9a3745384a | |||
| 0245b1a7b2 | |||
| d4d59cf08f | |||
| 692651fe40 | |||
| e4d08ba896 | |||
| 021e5299ab | |||
| 16e87d78d8 | |||
| 96cc92d035 | |||
| 4983542b46 | |||
| 6c68adad4d | |||
| 6efd469a4f | |||
| cc57f81ab8 | |||
| 5dbac3ab4c | |||
| 60805e1a7c | |||
| 7cf08722a0 | |||
| 21b46e82f3 | |||
| 35971d660e | |||
| 289ad2c57d | |||
| e20444cda6 | |||
| b9830c61f5 | |||
| cee9714a90 | |||
| ffd228cd8d | |||
| 5af4c2e213 | |||
| b423d9f7bb | |||
| fb11ab181e | |||
| c811efbf37 | |||
| 9bc9f3aa53 | |||
| db7d641c22 | |||
| a68323683d | |||
| 59e9c6ed73 | |||
| d1d412255c | |||
| b534083056 | |||
| 968c00f049 | |||
| df0ed8d219 | |||
| 4b607fd074 | |||
| 1013f24209 | |||
| 207efc15b8 | |||
| f2e55bd6a3 | |||
| 607152c434 | |||
| 39558ae1a3 | |||
| eae638be6c | |||
| e0b12758da | |||
| 6e1780546c | |||
| ad6f249d1e | |||
| 907dfc63f3 | |||
| 5a2c176651 | |||
| 05642f05ae | |||
| 300e83214d | |||
| 8b586fb2bf | |||
| d986648e9c | |||
| e133ce6865 | |||
| 168fde70d4 | |||
| fede33b32a | |||
| 3eba6cb2af | |||
| d8e7a477f3 | |||
| 2d1b6f1cc0 | |||
| 30ff05c6a5 | |||
| 295681f08f | |||
| 161e631dcd | |||
| 7b86f69cc0 | |||
| 8a034a6202 | |||
| e8538d041a | |||
| 5b1380ebfd | |||
| 017adac7a4 | |||
| 1b78e6ae78 | |||
| 911043ed4b | |||
| a641899cd9 | |||
| 08921dc7a0 | |||
| 1edfa86bc9 | |||
| f4add1711a | |||
| 8d7468b44c | |||
| 93e1edf81e | |||
| af0db5562b | |||
| bd04d9f29a | |||
| 9314b2fe81 | |||
| 1f8151649b | |||
| 1e5aeb9eed | |||
| 5a535f9f1f | |||
| 3a978d51b8 | |||
| 194ac5898d | |||
| 1ee543d5d3 | |||
| a305119a4a | |||
| a906dfaa99 | |||
| c2d3518c42 | |||
| 4a8d3a52ec | |||
| 2c07ddb2b0 | |||
| 4890222e7c | |||
| eef7c80a72 | |||
| 2294ff93d8 | |||
| ca6801dce8 | |||
| 566f46dee2 | |||
| 2219c32784 | |||
| 1c605a338a |
@@ -1,6 +1,6 @@
|
|||||||
### 相关的Issue
|
### 相关的Issue
|
||||||
|
|
||||||
|
|
||||||
### 原因(目的、解决的问题等)
|
### 原因(目的、解决的问题等)
|
||||||
|
|
||||||
|
|
||||||
@@ -8,5 +8,14 @@
|
|||||||
|
|
||||||
|
|
||||||
### 测试用例(新增、改动、可能影响的功能)
|
### 测试用例(新增、改动、可能影响的功能)
|
||||||
|
|
||||||
|
|
||||||
|
### 是否需要同步至release(如:3.0LTS ... )分支?
|
||||||
|
|
||||||
|
必须选择一项(在MarkDown模式下用[x]替换[ ]即可勾选对应选项):
|
||||||
|
- [ ] 是,需要同步的分支:
|
||||||
|
- [ ] 否
|
||||||
|
|
||||||
|
理由:
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
# Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without modification,
|
# Redistribution and use in source and binary forms, with or without modification,
|
||||||
# are permitted provided that the following conditions are met:
|
# are permitted provided that the following conditions are met:
|
||||||
@@ -31,163 +31,75 @@ import("//build/lite/config/component/lite_component.gni")
|
|||||||
|
|
||||||
LITEOS_MENUCONFIG_H = rebase_path("$root_out_dir/config.h")
|
LITEOS_MENUCONFIG_H = rebase_path("$root_out_dir/config.h")
|
||||||
|
|
||||||
declare_args() {
|
|
||||||
liteos_name = "OHOS_Image"
|
|
||||||
liteos_kernel_only = false
|
|
||||||
}
|
|
||||||
|
|
||||||
import("liteos.gni")
|
import("liteos.gni")
|
||||||
|
|
||||||
liteos_arch_cflags = []
|
if (defined(LOSCFG_COMPILER_ICCARM)) {
|
||||||
if (defined(LOSCFG_ARCH_ARM)) {
|
import("config_iccarm.gni")
|
||||||
mcpu = LOSCFG_ARCH_CPU
|
} else {
|
||||||
if (defined(LOSCFG_ARCH_ARM_AARCH64) && defined(LOSCFG_ARCH_FPU_DISABLE)) {
|
import("config.gni")
|
||||||
mcpu += "+nofp"
|
|
||||||
}
|
|
||||||
liteos_arch_cflags += [ "-mcpu=$mcpu" ]
|
|
||||||
if (defined(LOSCFG_ARCH_ARM_AARCH32) && defined(LOSCFG_ARCH_FPU)) {
|
|
||||||
liteos_arch_cflags += [ "-mfpu=$LOSCFG_ARCH_FPU" ]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cc = "$ohos_current_cc_command " + string_join(" ", liteos_arch_cflags)
|
cc = "$ohos_current_cc_command " + string_join(" ", liteos_arch_config_cflags)
|
||||||
if (ohos_build_compiler == "clang") {
|
if (ohos_build_compiler == "clang") {
|
||||||
cc += " --target=$target_triple"
|
cc += " --target=$target_triple"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
config("arch_config") {
|
config("arch_config") {
|
||||||
cflags = liteos_arch_cflags
|
cflags = arch_config_cflags
|
||||||
asmflags = cflags
|
asmflags = arch_config_asmflags
|
||||||
ldflags = cflags
|
ldflags = arch_config_ldflags
|
||||||
if (defined(LOSCFG_ARCH_ARM_AARCH32)) {
|
|
||||||
if (!defined(LOSCFG_COMPILER_CLANG_LLVM)) {
|
|
||||||
cflags += [ "-mthumb-interwork" ]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (defined(LOSCFG_THUMB)) {
|
|
||||||
cflags += [ "-mthumb" ]
|
|
||||||
if (defined(LOSCFG_COMPILER_CLANG_LLVM)) {
|
|
||||||
cflags += [ "-mimplicit-it=thumb" ]
|
|
||||||
} else {
|
|
||||||
cflags += [ "-Wa,-mimplicit-it=thumb" ]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
config("stdinc_config") {
|
config("stdinc_config") {
|
||||||
std_include = exec_script("//build/lite/run_shell_cmd.py",
|
cflags = stdinc_config_cflags
|
||||||
[ "$cc -print-file-name=include" ],
|
asmflags = stdinc_config_asmflags
|
||||||
"trim string")
|
if (!defined(LOSCFG_COMPILER_ICCARM)) {
|
||||||
cflags = [
|
std_include = exec_script("//build/lite/run_shell_cmd.py",
|
||||||
"-isystem",
|
[ "$cc -print-file-name=include" ],
|
||||||
std_include,
|
"trim string")
|
||||||
]
|
cflags += [
|
||||||
cflags += [ "-nostdinc" ]
|
"-isystem",
|
||||||
asmflags = cflags
|
std_include,
|
||||||
if (defined(LOSCFG_LIBC_NEWLIB)) {
|
]
|
||||||
cflags -= [ "-nostdinc" ]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
config("ssp_config") {
|
config("ssp_config") {
|
||||||
cflags = []
|
cflags = ssp_config_cflags
|
||||||
if (defined(LOSCFG_CC_STACKPROTECTOR_ALL)) {
|
asmflags = ssp_config_asmflags
|
||||||
cflags += [ "-fstack-protector-all" ]
|
|
||||||
} else if (defined(LOSCFG_CC_STACKPROTECTOR_STRONG)) {
|
|
||||||
cflags += [ "-fstack-protector-strong" ]
|
|
||||||
} else if (defined(LOSCFG_CC_STACKPROTECTOR)) {
|
|
||||||
cflags += [
|
|
||||||
"-fstack-protector",
|
|
||||||
"--param",
|
|
||||||
"ssp-buffer-size=4",
|
|
||||||
]
|
|
||||||
} else {
|
|
||||||
cflags += [ "-fno-stack-protector" ]
|
|
||||||
}
|
|
||||||
asmflags = cflags
|
|
||||||
}
|
}
|
||||||
|
|
||||||
config("optimize_config") {
|
config("optimize_config") {
|
||||||
cflags = []
|
cflags = optimize_config_cflags
|
||||||
if (defined(LOSCFG_COMPILE_DEBUG)) {
|
asmflags = optimize_config_asmflags
|
||||||
cflags += [
|
|
||||||
"-g",
|
|
||||||
"-gdwarf-2",
|
|
||||||
]
|
|
||||||
optimization_cflag = "-O0"
|
|
||||||
}
|
|
||||||
if (defined(LOSCFG_COMPILE_OPTIMIZE)) {
|
|
||||||
optimization_cflag = "-O2"
|
|
||||||
}
|
|
||||||
if (defined(LOSCFG_COMPILE_OPTIMIZE_SIZE)) {
|
|
||||||
if (defined(LOSCFG_COMPILER_CLANG_LLVM)) {
|
|
||||||
optimization_cflag = "-Oz"
|
|
||||||
} else {
|
|
||||||
optimization_cflag = "-Os"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (defined(LOSCFG_COMPILE_LTO)) {
|
|
||||||
if (defined(LOSCFG_COMPILER_CLANG_LLVM)) {
|
|
||||||
cflags += [ "-flto=thin" ]
|
|
||||||
} else {
|
|
||||||
#cflags += [ "-flto" ]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
cflags += [ optimization_cflag ]
|
|
||||||
asmflags = cflags
|
|
||||||
}
|
}
|
||||||
|
|
||||||
config("kconfig_config") {
|
config("kconfig_config") {
|
||||||
cflags = [
|
cflags = kconfig_config_cflags
|
||||||
"-imacros",
|
asmflags = kconfig_config_asmflags
|
||||||
"$LITEOS_MENUCONFIG_H",
|
|
||||||
]
|
|
||||||
asmflags = cflags
|
|
||||||
}
|
}
|
||||||
|
|
||||||
config("warn_config") {
|
config("warn_config") {
|
||||||
cflags = [
|
cflags = warn_config_cflags
|
||||||
"-Wall",
|
asmflags = warn_config_asmflags
|
||||||
"-Werror",
|
|
||||||
"-Wpointer-arith",
|
|
||||||
"-Wstrict-prototypes",
|
|
||||||
"-Winvalid-pch",
|
|
||||||
"-Wno-address-of-packed-member",
|
|
||||||
]
|
|
||||||
asmflags = cflags
|
|
||||||
}
|
}
|
||||||
|
|
||||||
config("dialect_config") {
|
config("dialect_config") {
|
||||||
cflags_c = [ "-std=c99" ]
|
cflags_c = dialect_config_cflags
|
||||||
cflags_cc = [ "-std=c++11" ]
|
cflags_cc = dialect_config_ccflags
|
||||||
|
asmflags = dialect_config_asmflags
|
||||||
}
|
}
|
||||||
|
|
||||||
config("misc_config") {
|
config("misc_config") {
|
||||||
defines = [ "__LITEOS__" ]
|
if (!defined(LOSCFG_COMPILER_ICCARM)) {
|
||||||
defines += [ "__LITEOS_M__" ]
|
defines = [ "__LITEOS__" ]
|
||||||
|
defines += [ "__LITEOS_M__" ]
|
||||||
|
}
|
||||||
if (!defined(LOSCFG_DEBUG_VERSION)) {
|
if (!defined(LOSCFG_DEBUG_VERSION)) {
|
||||||
defines += [ "NDEBUG" ]
|
defines += [ "NDEBUG" ]
|
||||||
}
|
}
|
||||||
|
cflags = misc_config_cflags
|
||||||
cflags = [
|
asmflags = misc_config_asmflags
|
||||||
"-fno-pic",
|
|
||||||
"-fno-builtin",
|
|
||||||
"-fms-extensions",
|
|
||||||
"-fno-strict-aliasing",
|
|
||||||
"-fno-common",
|
|
||||||
"-fsigned-char",
|
|
||||||
"-ffunction-sections",
|
|
||||||
"-fdata-sections",
|
|
||||||
"-fno-exceptions",
|
|
||||||
"-fno-omit-frame-pointer",
|
|
||||||
]
|
|
||||||
|
|
||||||
if (!defined(LOSCFG_COMPILER_CLANG_LLVM)) {
|
|
||||||
cflags += [ "-fno-aggressive-loop-optimizations" ]
|
|
||||||
}
|
|
||||||
|
|
||||||
asmflags = cflags
|
|
||||||
asmflags += [ "-DCLZ=CLZ" ]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
config("los_config") {
|
config("los_config") {
|
||||||
@@ -208,8 +120,11 @@ config("los_config") {
|
|||||||
cmd = "if [ -f $device_path/BUILD.gn ]; then echo true; else echo false; fi"
|
cmd = "if [ -f $device_path/BUILD.gn ]; then echo true; else echo false; fi"
|
||||||
HAVE_DEVICE_SDK = exec_script("//build/lite/run_shell_cmd.py", [ cmd ], "value")
|
HAVE_DEVICE_SDK = exec_script("//build/lite/run_shell_cmd.py", [ cmd ], "value")
|
||||||
|
|
||||||
# board and soc decoupling feature, device_path should contains board
|
# If device_path points to vendor, use device_path directly,
|
||||||
BOARD_SOC_FEATURE = device_path != string_replace(device_path, "/board/", "")
|
# otherwise board is decoupled from soc, device_path should contain board
|
||||||
|
BOARD_SOC_FEATURE =
|
||||||
|
device_path == string_replace(device_path, "/vendor/", "") &&
|
||||||
|
device_path != string_replace(device_path, "/board/", "")
|
||||||
|
|
||||||
config("public") {
|
config("public") {
|
||||||
configs = [
|
configs = [
|
||||||
@@ -257,7 +172,11 @@ not_needed([ "HAVE_DEVICE_SDK" ])
|
|||||||
|
|
||||||
static_library("libkernel") {
|
static_library("libkernel") {
|
||||||
deps = [ ":modules" ]
|
deps = [ ":modules" ]
|
||||||
complete_static_lib = false
|
if (defined(LOSCFG_COMPILER_ICCARM)) {
|
||||||
|
complete_static_lib = true
|
||||||
|
} else {
|
||||||
|
complete_static_lib = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
group("kernel") {
|
group("kernel") {
|
||||||
@@ -273,11 +192,7 @@ executable("liteos") {
|
|||||||
":los_config",
|
":los_config",
|
||||||
]
|
]
|
||||||
|
|
||||||
ldflags = [
|
ldflags = executable_config_ldflags
|
||||||
"-static",
|
|
||||||
"-Wl,--gc-sections",
|
|
||||||
"-Wl,-Map=$liteos_name.map",
|
|
||||||
]
|
|
||||||
|
|
||||||
output_dir = target_out_dir
|
output_dir = target_out_dir
|
||||||
|
|
||||||
@@ -298,11 +213,5 @@ build_ext_component("build_kernel_image") {
|
|||||||
deps = [ ":copy_liteos" ]
|
deps = [ ":copy_liteos" ]
|
||||||
exec_path = rebase_path(root_out_dir)
|
exec_path = rebase_path(root_out_dir)
|
||||||
|
|
||||||
objcopy = "${compile_prefix}objcopy$toolchain_cmd_suffix"
|
command = toochain_config_command
|
||||||
objdump = "${compile_prefix}objdump$toolchain_cmd_suffix"
|
|
||||||
|
|
||||||
command = "$objcopy -O binary $liteos_name $liteos_name.bin"
|
|
||||||
command +=
|
|
||||||
" && sh -c '$objdump -t $liteos_name | sort >$liteos_name.sym.sorted'"
|
|
||||||
command += " && sh -c '$objdump -d $liteos_name >$liteos_name.asm'"
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
# Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without modification,
|
# Redistribution and use in source and binary forms, with or without modification,
|
||||||
# are permitted provided that the following conditions are met:
|
# are permitted provided that the following conditions are met:
|
||||||
@@ -52,6 +52,9 @@ config LLVM_TARGET
|
|||||||
depends on COMPILER_CLANG_LLVM
|
depends on COMPILER_CLANG_LLVM
|
||||||
default "arm-liteos-ohos" if ARCH_ARM_AARCH32
|
default "arm-liteos-ohos" if ARCH_ARM_AARCH32
|
||||||
|
|
||||||
|
config COMPILER_ICCARM
|
||||||
|
bool "ICCARM"
|
||||||
|
|
||||||
endchoice
|
endchoice
|
||||||
|
|
||||||
config COMPILE_DEBUG
|
config COMPILE_DEBUG
|
||||||
@@ -91,19 +94,20 @@ menu "Platform"
|
|||||||
######################### config options of bsp #####################
|
######################### config options of bsp #####################
|
||||||
config PLATFORM
|
config PLATFORM
|
||||||
string
|
string
|
||||||
default "virt" if PLATFORM_QEMU_ARM_VIRT_CM7 || PLATFORM_QEMU_ARM_VIRT_CM4 || PRODUCT_QEMU_RISCV32_VIRT || PLATFORM_QEMU_CSKY_SMARTL || PLATFORM_QEMU_XTENSA_ESP32
|
default "virt" if PLATFORM_QEMU_ARM_VIRT_CM7 || PLATFORM_QEMU_ARM_VIRT_CM4 || PLATFORM_QEMU_ARM_VIRT_CM55 || PRODUCT_QEMU_RISCV32_VIRT || PLATFORM_QEMU_CSKY_SMARTL || PLATFORM_QEMU_XTENSA_ESP32
|
||||||
|
|
||||||
config PRODUCT_NAME
|
config PRODUCT_NAME
|
||||||
string
|
string
|
||||||
default "arm_virt" if PRODUCT_QEMU_ARM
|
default "arm_virt" if PRODUCT_QEMU_ARM
|
||||||
default "arm_mps2_an386" if PRODUCT_QEMU_ARM_MPS2_AN386
|
default "arm_mps2_an386" if PRODUCT_QEMU_ARM_MPS2_AN386
|
||||||
|
default "arm_mps3_an547" if PRODUCT_QEMU_ARM_MPS3_AN547
|
||||||
default "riscv32_virt" if PRODUCT_QEMU_RISCV32_VIRT
|
default "riscv32_virt" if PRODUCT_QEMU_RISCV32_VIRT
|
||||||
default "csky_smartl_e802" if PRODUCT_QEMU_CSKY_SMARTL_E802
|
default "csky_smartl_e802" if PRODUCT_QEMU_CSKY_SMARTL_E802
|
||||||
default "xtensa_esp32" if PRODUCT_QEMU_XTENSA_ESP32
|
default "xtensa_esp32" if PRODUCT_QEMU_XTENSA_ESP32
|
||||||
|
|
||||||
config DEVICE_COMPANY
|
config DEVICE_COMPANY
|
||||||
string
|
string
|
||||||
default "qemu" if PLATFORM_QEMU_ARM_VIRT_CM7 || PLATFORM_QEMU_ARM_VIRT_CM4 || PRODUCT_QEMU_RISCV32_VIRT || PLATFORM_QEMU_CSKY_SMARTL || PLATFORM_QEMU_XTENSA_ESP32
|
default "qemu" if PLATFORM_QEMU_ARM_VIRT_CM7 || PLATFORM_QEMU_ARM_VIRT_CM4 || PLATFORM_QEMU_ARM_VIRT_CM55 || PRODUCT_QEMU_RISCV32_VIRT || PLATFORM_QEMU_CSKY_SMARTL || PLATFORM_QEMU_XTENSA_ESP32
|
||||||
|
|
||||||
choice
|
choice
|
||||||
prompt "Chip"
|
prompt "Chip"
|
||||||
@@ -128,6 +132,12 @@ config PLATFORM_QEMU_ARM_VIRT_CM4
|
|||||||
help
|
help
|
||||||
QEMU ARM Virtual Platform using Cortex-M4 CPU.
|
QEMU ARM Virtual Platform using Cortex-M4 CPU.
|
||||||
|
|
||||||
|
config PLATFORM_QEMU_ARM_VIRT_CM55
|
||||||
|
bool "qemu_arm_virt_cm55"
|
||||||
|
select ARCH_CORTEX_M55
|
||||||
|
help
|
||||||
|
QEMU ARM Virtual Platform using Cortex-M55 CPU.
|
||||||
|
|
||||||
config PLATFORM_QEMU_RISCV32_VIRT
|
config PLATFORM_QEMU_RISCV32_VIRT
|
||||||
bool "qemu_riscv32_virt"
|
bool "qemu_riscv32_virt"
|
||||||
select ARCH_RISCV32
|
select ARCH_RISCV32
|
||||||
@@ -159,6 +169,9 @@ config PRODUCT_QEMU_ARM
|
|||||||
config PRODUCT_QEMU_ARM_MPS2_AN386
|
config PRODUCT_QEMU_ARM_MPS2_AN386
|
||||||
bool "arm_mps2_an386" if PLATFORM_QEMU_ARM_VIRT_CM4
|
bool "arm_mps2_an386" if PLATFORM_QEMU_ARM_VIRT_CM4
|
||||||
|
|
||||||
|
config PRODUCT_QEMU_ARM_MPS3_AN547
|
||||||
|
bool "arm_mps3_an547" if PLATFORM_QEMU_ARM_VIRT_CM55
|
||||||
|
|
||||||
config PRODUCT_QEMU_RISCV32_VIRT
|
config PRODUCT_QEMU_RISCV32_VIRT
|
||||||
bool "riscv32_virt" if PLATFORM_QEMU_RISCV32_VIRT
|
bool "riscv32_virt" if PLATFORM_QEMU_RISCV32_VIRT
|
||||||
|
|
||||||
@@ -286,6 +299,8 @@ config KERNEL_CPPSUPPORT
|
|||||||
help
|
help
|
||||||
If you wish to build LiteOS with support for C++.
|
If you wish to build LiteOS with support for C++.
|
||||||
|
|
||||||
|
rsource "components/signal/Kconfig"
|
||||||
|
|
||||||
config BASE_CORE_CPUP
|
config BASE_CORE_CPUP
|
||||||
bool
|
bool
|
||||||
default n
|
default n
|
||||||
@@ -305,7 +320,7 @@ config CPUP_INCLUDE_IRQ
|
|||||||
help
|
help
|
||||||
If you wish to include irq usage for cpup.
|
If you wish to include irq usage for cpup.
|
||||||
|
|
||||||
config DYNLINK
|
config KERNEL_DYNLINK
|
||||||
bool "Enable Dynamic Link Feature"
|
bool "Enable Dynamic Link Feature"
|
||||||
default n
|
default n
|
||||||
depends on KERNEL_EXTKERNEL && ARCH_ARM
|
depends on KERNEL_EXTKERNEL && ARCH_ARM
|
||||||
@@ -342,22 +357,17 @@ config KERNEL_PM_DEBUG
|
|||||||
help
|
help
|
||||||
Configuration item for low power frame debug tailoring.
|
Configuration item for low power frame debug tailoring.
|
||||||
|
|
||||||
config DEBUG_HOOK
|
|
||||||
bool
|
|
||||||
default n
|
|
||||||
|
|
||||||
config PLATFORM_EXC
|
config PLATFORM_EXC
|
||||||
bool "Enable Hook Feature"
|
bool "Enable Platform Exc Hook"
|
||||||
default n
|
default n
|
||||||
depends on KERNEL_EXTKERNEL
|
depends on KERNEL_EXTKERNEL
|
||||||
select DEBUG_HOOK
|
|
||||||
|
|
||||||
config KERNEL_LMK
|
config KERNEL_LMK
|
||||||
bool "Enable Low Memory Killer"
|
bool "Enable Low Memory Killer"
|
||||||
default n
|
default n
|
||||||
depends on KERNEL_EXTKERNEL
|
depends on KERNEL_EXTKERNEL
|
||||||
help
|
help
|
||||||
Configuration item for low momery killer tailoring.
|
Configuration item for low memory killer tailoring.
|
||||||
If you wish to build LiteOS with support for low memory killer.
|
If you wish to build LiteOS with support for low memory killer.
|
||||||
|
|
||||||
config KERNEL_LMK_DEBUG
|
config KERNEL_LMK_DEBUG
|
||||||
@@ -517,14 +527,20 @@ config DEBUG_SEMAPHORE
|
|||||||
help
|
help
|
||||||
Answer Y to enable debug semaphore.
|
Answer Y to enable debug semaphore.
|
||||||
|
|
||||||
source "components/shell/Kconfig"
|
|
||||||
config NET_LWIP_SACK_TFTP
|
config NET_LWIP_SACK_TFTP
|
||||||
bool "Enable Tftp"
|
bool "Enable Tftp"
|
||||||
default y
|
default y
|
||||||
depends on SHELL && NET_LWIP_SACK && DEBUG_VERSION
|
depends on SHELL && NET_LWIP_SACK && DEBUG_VERSION
|
||||||
help
|
help
|
||||||
Answer Y to enable LiteOS support tftp cmd and tftp tool.
|
Answer Y to enable LiteOS support tftp cmd and tftp tool.
|
||||||
osource "net/telnet/Kconfig"
|
|
||||||
|
config DEBUG_HOOK
|
||||||
|
bool "Enable Hook Framework"
|
||||||
|
default n
|
||||||
|
depends on DEBUG_VERSION
|
||||||
|
help
|
||||||
|
Enable the kernel hook framework to support customized trace information capture.
|
||||||
|
|
||||||
config SCHED_DEBUG
|
config SCHED_DEBUG
|
||||||
bool "Enable sched debug Feature"
|
bool "Enable sched debug Feature"
|
||||||
default n
|
default n
|
||||||
@@ -542,6 +558,13 @@ config SHELL_CMD_DEBUG
|
|||||||
default n
|
default n
|
||||||
depends on DEBUG_VERSION && SHELL
|
depends on DEBUG_VERSION && SHELL
|
||||||
|
|
||||||
|
config DEBUG_TOOLS
|
||||||
|
bool "Enable DEBUG TOOLS"
|
||||||
|
default n
|
||||||
|
depends on DEBUG_VERSION
|
||||||
|
help
|
||||||
|
Answer Y to enable LiteOS debug tools, include stackdump, hwidump, tasktrack.
|
||||||
|
|
||||||
config USB_DEBUG
|
config USB_DEBUG
|
||||||
bool "Enable USB Debug"
|
bool "Enable USB Debug"
|
||||||
default n
|
default n
|
||||||
@@ -562,7 +585,7 @@ config MEM_LEAKCHECK
|
|||||||
depends on DEBUG_VERSION && MEM_DEBUG
|
depends on DEBUG_VERSION && MEM_DEBUG
|
||||||
select KERNEL_BACKTRACE
|
select KERNEL_BACKTRACE
|
||||||
help
|
help
|
||||||
Answer Y to enable record the LR of Function call stack of Mem operation, it can check the mem leak through the infomations of mem node.
|
Answer Y to enable record the LR of Function call stack of Mem operation, it can check the mem leak through the information of mem node.
|
||||||
config BASE_MEM_NODE_INTEGRITY_CHECK
|
config BASE_MEM_NODE_INTEGRITY_CHECK
|
||||||
bool "Enable integrity check or not"
|
bool "Enable integrity check or not"
|
||||||
default n
|
default n
|
||||||
@@ -578,6 +601,13 @@ config VM_OVERLAP_CHECK
|
|||||||
depends on DEBUG_VERSION && MEM_DEBUG
|
depends on DEBUG_VERSION && MEM_DEBUG
|
||||||
help
|
help
|
||||||
Answer Y to enable vm overlap check.
|
Answer Y to enable vm overlap check.
|
||||||
|
|
||||||
|
config TASK_MEM_USED
|
||||||
|
bool "Enable show task mem used or not"
|
||||||
|
default n
|
||||||
|
depends on DEBUG_VERSION && MEM_DEBUG
|
||||||
|
|
||||||
|
source "components/shell/Kconfig"
|
||||||
|
|
||||||
endmenu
|
endmenu
|
||||||
|
|
||||||
@@ -588,11 +618,11 @@ endmenu
|
|||||||
|
|
||||||
######################## config options os security #######################
|
######################## config options os security #######################
|
||||||
menu "Security"
|
menu "Security"
|
||||||
osource "security/Kconfig"
|
|
||||||
config SECURE_TRUSTZONE
|
config SECURE_TRUSTZONE
|
||||||
bool "Enable ARM TrustZone"
|
bool "Enable ARM TrustZone"
|
||||||
default n
|
default n
|
||||||
depends on ARCH_ARM
|
depends on ARCH_ARM
|
||||||
|
depends on ARCH_ARM_V8M
|
||||||
config SECURE_HEAP_SIZE
|
config SECURE_HEAP_SIZE
|
||||||
int "TrustZone Heap Size (bytes)"
|
int "TrustZone Heap Size (bytes)"
|
||||||
default 2048
|
default 2048
|
||||||
@@ -603,6 +633,13 @@ config SECURE_STACK_DEFAULT_SIZE
|
|||||||
depends on SECURE_TRUSTZONE
|
depends on SECURE_TRUSTZONE
|
||||||
help
|
help
|
||||||
The secure stack must be allocated before the task calls non-secure functions.
|
The secure stack must be allocated before the task calls non-secure functions.
|
||||||
|
config SECURE
|
||||||
|
bool "Enable Security"
|
||||||
|
default n
|
||||||
|
select MPU_ENABLE
|
||||||
|
config MPU_ENABLE
|
||||||
|
bool "Enable MPU"
|
||||||
|
default n
|
||||||
endmenu
|
endmenu
|
||||||
|
|
||||||
menu "Test"
|
menu "Test"
|
||||||
|
|||||||
@@ -59,7 +59,6 @@ The directory structure is as follows. For more details, see [arch_spec.md](arch
|
|||||||
├── kernel # Minimum kernel function set
|
├── kernel # Minimum kernel function set
|
||||||
│ ├── include # APIs exposed externally
|
│ ├── include # APIs exposed externally
|
||||||
│ └── src # Source code of the minimum kernel function set
|
│ └── src # Source code of the minimum kernel function set
|
||||||
├── targets # Board-level projects
|
|
||||||
├── testsuites # Kernel testsuites
|
├── testsuites # Kernel testsuites
|
||||||
├── tools # Kernel tools
|
├── tools # Kernel tools
|
||||||
├── utils # Common directory
|
├── utils # Common directory
|
||||||
@@ -85,11 +84,11 @@ Before setting up the environment for a development board, you must set up the b
|
|||||||
|
|
||||||
For details about how to obtain the source code, see [Source Code Acquisition](https://gitee.com/openharmony/docs/blob/HEAD/en/device-dev/get-code/sourcecode-acquire.md). This document assumes that the clone directory is `~/openHarmony` after the complete OpenHarmony repository code is obtained.
|
For details about how to obtain the source code, see [Source Code Acquisition](https://gitee.com/openharmony/docs/blob/HEAD/en/device-dev/get-code/sourcecode-acquire.md). This document assumes that the clone directory is `~/openHarmony` after the complete OpenHarmony repository code is obtained.
|
||||||
|
|
||||||
### Example projects that are already supported
|
### Example projects
|
||||||
|
|
||||||
Qemu simulator: `arm_mps2_an386、esp32、riscv32_virt、SmartL_E802`, For details about how to compile and run, see [qemu guide](https://gitee.com/openharmony/device_qemu)
|
Qemu simulator: `arm_mps2_an386、esp32、riscv32_virt、SmartL_E802`. For details about how to compile and run, see [qemu guide](https://gitee.com/openharmony/device_qemu).
|
||||||
|
|
||||||
Bestechnic: `bes2600`, For details about how to compile and run, see [Bestechnic developer guide](https://gitee.com/openharmony/device_soc_bestechnic)
|
Bestechnic: `bes2600`. For details about how to compile and run, see [Bestechnic developer guide](https://gitee.com/openharmony/device_soc_bestechnic).
|
||||||
|
|
||||||
### Community Porting Project Links
|
### Community Porting Project Links
|
||||||
|
|
||||||
@@ -107,12 +106,6 @@ The LiteOS-M kernel porting projects for specific development boards are provide
|
|||||||
|
|
||||||
This repository provides the project code for porting the OpenHarmony LiteOS-M kernel to support the STM32F429IGTb development board. The code supports build in Ninja, GCC, and IAR modes.
|
This repository provides the project code for porting the OpenHarmony LiteOS-M kernel to support the STM32F429IGTb development board. The code supports build in Ninja, GCC, and IAR modes.
|
||||||
|
|
||||||
- Cortex-M7:
|
|
||||||
|
|
||||||
- Nucleo-F767ZI https://gitee.com/harylee/nucleo_f767zi
|
|
||||||
|
|
||||||
This repository provides the project code for porting the OpenHarmony LiteOS-M kernel to support the Nucleo-F767ZI development board. The code supports build in Ninja, GCC, and IAR modes.
|
|
||||||
|
|
||||||
## Contribution<a name="section1371123476307"></a>
|
## Contribution<a name="section1371123476307"></a>
|
||||||
|
|
||||||
[How to involve](https://gitee.com/openharmony/docs/blob/HEAD/en/contribute/contribution.md)
|
[How to involve](https://gitee.com/openharmony/docs/blob/HEAD/en/contribute/contribution.md)
|
||||||
@@ -131,4 +124,4 @@ How to contribute a chip based on Liteos-M kernel:
|
|||||||
|
|
||||||
[Kernel Subsystem](https://gitee.com/openharmony/docs/blob/HEAD/en/readme/kernel-subsystem.md)
|
[Kernel Subsystem](https://gitee.com/openharmony/docs/blob/HEAD/en/readme/kernel-subsystem.md)
|
||||||
|
|
||||||
**kernel\_liteos\_m**
|
[kernel\_liteos\_m](https://gitee.com/openharmony/kernel_liteos_m/blob/master/README.md)
|
||||||
|
|||||||
+2
-8
@@ -26,6 +26,7 @@ OpenHarmony LiteOS-M内核是面向IoT领域构建的轻量级物联网操作系
|
|||||||
│ │ ├── cortex-m3 # cortex-m3架构代码
|
│ │ ├── cortex-m3 # cortex-m3架构代码
|
||||||
│ │ ├── cortex-m33 # cortex-m33架构代码
|
│ │ ├── cortex-m33 # cortex-m33架构代码
|
||||||
│ │ ├── cortex-m4 # cortex-m4架构代码
|
│ │ ├── cortex-m4 # cortex-m4架构代码
|
||||||
|
│ │ ├── cortex-m55 # cortex-m55架构代码
|
||||||
│ │ ├── cortex-m7 # cortex-m7架构代码
|
│ │ ├── cortex-m7 # cortex-m7架构代码
|
||||||
│ │ └── include # arm架构公共头文件目录
|
│ │ └── include # arm架构公共头文件目录
|
||||||
│ ├── csky # csky架构代码
|
│ ├── csky # csky架构代码
|
||||||
@@ -56,7 +57,6 @@ OpenHarmony LiteOS-M内核是面向IoT领域构建的轻量级物联网操作系
|
|||||||
├── kernel # 内核最小功能集支持
|
├── kernel # 内核最小功能集支持
|
||||||
│ ├── include # 对外接口存放目录
|
│ ├── include # 对外接口存放目录
|
||||||
│ └── src # 内核最小功能集源码
|
│ └── src # 内核最小功能集源码
|
||||||
├── targets # 板级工程目录
|
|
||||||
├── testsuites # 内核测试用例
|
├── testsuites # 内核测试用例
|
||||||
├── tools # 内核工具
|
├── tools # 内核工具
|
||||||
├── utils # 通用公共目录
|
├── utils # 通用公共目录
|
||||||
@@ -105,12 +105,6 @@ LiteOS-M内核移植的具体开发板的工程由社区开发者提供,可以
|
|||||||
|
|
||||||
该仓包含OpenHarmony LiteOS-M内核移植支持`野火挑战者STM32F429IGTb`开发板的工程代码,支持Ninja、GCC、IAR等方式进行编译。
|
该仓包含OpenHarmony LiteOS-M内核移植支持`野火挑战者STM32F429IGTb`开发板的工程代码,支持Ninja、GCC、IAR等方式进行编译。
|
||||||
|
|
||||||
- cortex-m7:
|
|
||||||
|
|
||||||
- Nucleo-F767ZI https://gitee.com/harylee/nucleo_f767zi
|
|
||||||
|
|
||||||
该仓包含OpenHarmony LiteOS-M内核移植支持`Nucleo-F767ZI`开发板的工程代码,支持Ninja、GCC、IAR等方式进行编译。
|
|
||||||
|
|
||||||
## 贡献<a name="section1371123476307"></a>
|
## 贡献<a name="section1371123476307"></a>
|
||||||
|
|
||||||
[如何贡献](https://gitee.com/openharmony/docs/blob/HEAD/zh-cn/contribute/%E5%8F%82%E4%B8%8E%E8%B4%A1%E7%8C%AE.md)
|
[如何贡献](https://gitee.com/openharmony/docs/blob/HEAD/zh-cn/contribute/%E5%8F%82%E4%B8%8E%E8%B4%A1%E7%8C%AE.md)
|
||||||
@@ -131,5 +125,5 @@ LiteOS-M内核移植的具体开发板的工程由社区开发者提供,可以
|
|||||||
|
|
||||||
[内核子系统](https://gitee.com/openharmony/docs/blob/HEAD/zh-cn/readme/%E5%86%85%E6%A0%B8%E5%AD%90%E7%B3%BB%E7%BB%9F.md)
|
[内核子系统](https://gitee.com/openharmony/docs/blob/HEAD/zh-cn/readme/%E5%86%85%E6%A0%B8%E5%AD%90%E7%B3%BB%E7%BB%9F.md)
|
||||||
|
|
||||||
**kernel\_liteos\_m**
|
[kernel\_liteos\_m](https://gitee.com/openharmony/kernel_liteos_m/blob/master/README_zh.md)
|
||||||
|
|
||||||
|
|||||||
+4
-3
@@ -37,12 +37,13 @@ module_group("arch") {
|
|||||||
modules = []
|
modules = []
|
||||||
if ("$board_cpu" == "arm9" || "$board_cpu" == "cortex-m3" ||
|
if ("$board_cpu" == "arm9" || "$board_cpu" == "cortex-m3" ||
|
||||||
"$board_cpu" == "cortex-m4" || "$board_cpu" == "cortex-m7" ||
|
"$board_cpu" == "cortex-m4" || "$board_cpu" == "cortex-m7" ||
|
||||||
"$board_cpu" == "cortex-m33") {
|
"$board_cpu" == "cortex-m33" || "$board_cpu" == "cortex-m55") {
|
||||||
modules += [ "arm" ]
|
modules += [ "arm" ]
|
||||||
} else if ("$board_cpu" == "ck802" || "$board_cpu" == "e802") {
|
} else if ("$board_cpu" == "ck802" || "$board_cpu" == "e802" ||
|
||||||
|
"$board_cpu" == "ck804ef") {
|
||||||
modules += [ "csky" ]
|
modules += [ "csky" ]
|
||||||
} else if ("$board_cpu" == "") {
|
} else if ("$board_cpu" == "") {
|
||||||
if ("$board_arch" == "rv32imac" || "$board_arch" == "rv32imafdc") {
|
if ("$board_arch" != string_replace("$board_arch", "rv32i", "")) {
|
||||||
modules += [ "risc-v" ]
|
modules += [ "risc-v" ]
|
||||||
} else if ("$board" == "esp32") {
|
} else if ("$board" == "esp32") {
|
||||||
modules += [ "xtensa" ]
|
modules += [ "xtensa" ]
|
||||||
|
|||||||
+6
-2
@@ -1,5 +1,5 @@
|
|||||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
# Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without modification,
|
# Redistribution and use in source and binary forms, with or without modification,
|
||||||
# are permitted provided that the following conditions are met:
|
# are permitted provided that the following conditions are met:
|
||||||
@@ -34,6 +34,10 @@ config("arm_config") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
module_group("arm") {
|
module_group("arm") {
|
||||||
modules = [ "$board_cpu/gcc" ]
|
if (defined(LOSCFG_COMPILER_ICCARM)) {
|
||||||
|
modules = [ "$board_cpu/iar" ]
|
||||||
|
} else {
|
||||||
|
modules = [ "$board_cpu/gcc" ]
|
||||||
|
}
|
||||||
configs = [ ":arm_config" ]
|
configs = [ ":arm_config" ]
|
||||||
}
|
}
|
||||||
|
|||||||
+68
-41
@@ -16,54 +16,76 @@ config ARCH_ARM_AARCH32
|
|||||||
config ARCH_ARM_V7M
|
config ARCH_ARM_V7M
|
||||||
bool
|
bool
|
||||||
|
|
||||||
|
config ARCH_ARM_V8M
|
||||||
|
bool
|
||||||
|
|
||||||
config ARCH_ARM_V5TE
|
config ARCH_ARM_V5TE
|
||||||
bool
|
bool
|
||||||
|
|
||||||
config ARCH_ARM_VER
|
config ARCH_ARM_VER
|
||||||
string
|
string
|
||||||
default "armv7-m" if ARCH_ARM_V7M
|
default "armv7-m" if ARCH_ARM_V7M
|
||||||
|
default "armv8-m" if ARCH_ARM_V8M
|
||||||
default "armv5te" if ARCH_ARM_V5TE
|
default "armv5te" if ARCH_ARM_V5TE
|
||||||
|
|
||||||
#
|
#
|
||||||
# VFP Hardware
|
# VFP Hardware
|
||||||
#
|
#
|
||||||
config ARCH_FPU_VFP_V3
|
choice
|
||||||
bool
|
prompt "Choose FPU type"
|
||||||
help
|
depends on !ARCH_FPU_DISABLE
|
||||||
An optional extension to the Arm, Thumb, and ThumbEE instruction sets in the ARMv7-A and ARMv7-R profiles.
|
|
||||||
VFPv3U is a variant of VFPv3 that supports the trapping of floating-point exceptions to support code.
|
|
||||||
|
|
||||||
config ARCH_FPU_VFP_V4
|
choice
|
||||||
bool
|
prompt "Choose FPU version"
|
||||||
help
|
default ARCH_FPU_VFP_V4
|
||||||
An optional extension to the Arm, Thumb, and ThumbEE instruction sets in the ARMv7-A and ARMv7-R profiles.
|
depends on !ARCH_FPU_DISABLE
|
||||||
VFPv4U is a variant of VFPv4 that supports the trapping of floating-point exceptions to support code.
|
help
|
||||||
VFPv4 and VFPv4U add both the Half-precision Extension and the fused multiply-add instructions to the features of VFPv3.
|
Choose FPU version.
|
||||||
|
|
||||||
|
config ARCH_FPU_VFP_V3
|
||||||
|
bool "VFP_V3"
|
||||||
|
help
|
||||||
|
An optional extension to the Arm, Thumb, and ThumbEE instruction sets in the ARMv7-A and ARMv7-R profiles.
|
||||||
|
VFPv3U is a variant of VFPv3 that supports the trapping of floating-point exceptions to support code.
|
||||||
|
|
||||||
config ARCH_FPU_VFP_D16
|
config ARCH_FPU_VFP_V4
|
||||||
bool
|
bool "VFP_V4"
|
||||||
depends on ARCH_ARM_AARCH32
|
help
|
||||||
help
|
An optional extension to the Arm, Thumb, and ThumbEE instruction sets in the ARMv7-A and ARMv7-R profiles.
|
||||||
VPU implemented with 16 doubleword registers (16 x 64-bit).
|
VFPv4U is a variant of VFPv4 that supports the trapping of floating-point exceptions to support code.
|
||||||
|
VFPv4 and VFPv4U add both the Half-precision Extension and the fused multiply-add instructions to the features of VFPv3.
|
||||||
|
endchoice
|
||||||
|
|
||||||
config ARCH_FPU_VFP_D32
|
choice
|
||||||
bool
|
prompt "Choose num of FPU doubleword registers"
|
||||||
depends on ARCH_ARM_AARCH32
|
default ARCH_FPU_VFP_D32
|
||||||
help
|
depends on !ARCH_FPU_DISABLE
|
||||||
VPU implemented with 32 doubleword registers (32 x 64-bit).
|
help
|
||||||
|
Choose num of FPU doubleword registers.
|
||||||
|
|
||||||
config ARCH_FPU_VFP_NEON
|
config ARCH_FPU_VFP_D16
|
||||||
bool
|
bool "FPU_VFP_D16"
|
||||||
help
|
depends on ARCH_ARM_AARCH32
|
||||||
Advanced SIMD extension (NEON) support.
|
help
|
||||||
|
VPU implemented with 16 doubleword registers (16 x 64-bit).
|
||||||
|
|
||||||
|
config ARCH_FPU_VFP_D32
|
||||||
|
bool "FPU_VFP_D32"
|
||||||
|
depends on ARCH_ARM_AARCH32
|
||||||
|
help
|
||||||
|
VPU implemented with 32 doubleword registers (32 x 64-bit).
|
||||||
|
endchoice
|
||||||
|
endchoice
|
||||||
config ARCH_FPU
|
config ARCH_FPU
|
||||||
string
|
string
|
||||||
default "vfpv3" if ARCH_FPU_VFP_V3 && ARCH_FPU_VFP_D32
|
default "vfpv3" if ARCH_FPU_VFP_V3 && ARCH_FPU_VFP_D32 && !COMPILER_ICCARM
|
||||||
default "vfpv3-d16" if ARCH_FPU_VFP_V3 && ARCH_FPU_VFP_D16
|
default "vfpv3-d16" if ARCH_FPU_VFP_V3 && ARCH_FPU_VFP_D16 && !COMPILER_ICCARM
|
||||||
default "neon-vfpv4" if ARCH_FPU_VFP_V4 && ARCH_FPU_VFP_D32 && ARCH_FPU_VFP_NEON
|
default "vfpv4" if ARCH_FPU_VFP_V4 && ARCH_FPU_VFP_D32 && !COMPILER_ICCARM
|
||||||
default "vfpv4" if ARCH_FPU_VFP_V4 && ARCH_FPU_VFP_D32
|
default "vfpv4-d16" if ARCH_FPU_VFP_V4 && ARCH_FPU_VFP_D16 && !COMPILER_ICCARM
|
||||||
default "vfpv4-d16" if ARCH_FPU_VFP_V4 && ARCH_FPU_VFP_D16
|
default "VFPv3" if ARCH_FPU_VFP_V3 && ARCH_FPU_VFP_D32 && COMPILER_ICCARM
|
||||||
|
default "VFPv3_D16" if ARCH_FPU_VFP_V3 && ARCH_FPU_VFP_D16 && COMPILER_ICCARM
|
||||||
|
default "VFPv4" if ARCH_FPU_VFP_V4 && ARCH_FPU_VFP_D32 && COMPILER_ICCARM
|
||||||
|
default "VFPv4_D16" if ARCH_FPU_VFP_V4 && ARCH_FPU_VFP_D16 && COMPILER_ICCARM
|
||||||
|
|
||||||
#
|
#
|
||||||
# Supported Processor Cores
|
# Supported Processor Cores
|
||||||
@@ -82,17 +104,16 @@ config ARCH_CORTEX_M7
|
|||||||
bool
|
bool
|
||||||
select ARCH_ARM_V7M
|
select ARCH_ARM_V7M
|
||||||
select ARCH_ARM_AARCH32
|
select ARCH_ARM_AARCH32
|
||||||
select ARCH_FPU_VFP_V4
|
|
||||||
select ARCH_FPU_VFP_D32
|
|
||||||
select ARCH_FPU_VFP_NEON
|
|
||||||
|
|
||||||
config ARCH_CORTEX_M33
|
config ARCH_CORTEX_M33
|
||||||
bool
|
bool
|
||||||
select ARCH_ARM_V7M
|
select ARCH_ARM_V8M
|
||||||
|
select ARCH_ARM_AARCH32
|
||||||
|
|
||||||
|
config ARCH_CORTEX_M55
|
||||||
|
bool
|
||||||
|
select ARCH_ARM_V8M
|
||||||
select ARCH_ARM_AARCH32
|
select ARCH_ARM_AARCH32
|
||||||
select ARCH_FPU_VFP_V4
|
|
||||||
select ARCH_FPU_VFP_D32
|
|
||||||
select ARCH_FPU_VFP_NEON
|
|
||||||
|
|
||||||
config ARCH_ARM9
|
config ARCH_ARM9
|
||||||
bool
|
bool
|
||||||
@@ -101,8 +122,14 @@ config ARCH_ARM9
|
|||||||
|
|
||||||
config ARCH_CPU
|
config ARCH_CPU
|
||||||
string
|
string
|
||||||
default "cortex-m3" if ARCH_CORTEX_M3
|
default "cortex-m3" if ARCH_CORTEX_M3 && !COMPILER_ICCARM
|
||||||
default "cortex-m4" if ARCH_CORTEX_M4
|
default "cortex-m4" if ARCH_CORTEX_M4 && !COMPILER_ICCARM
|
||||||
default "cortex-m7" if ARCH_CORTEX_M7
|
default "cortex-m7" if ARCH_CORTEX_M7 && !COMPILER_ICCARM
|
||||||
default "cortex-m33" if ARCH_CORTEX_M33
|
default "cortex-m33" if ARCH_CORTEX_M33 && !COMPILER_ICCARM
|
||||||
|
default "cortex-m55" if ARCH_CORTEX_M55 && !COMPILER_ICCARM
|
||||||
|
default "Cortex-M3" if ARCH_CORTEX_M3 && COMPILER_ICCARM
|
||||||
|
default "Cortex-M4" if ARCH_CORTEX_M4 && COMPILER_ICCARM
|
||||||
|
default "Cortex-M7" if ARCH_CORTEX_M7 && COMPILER_ICCARM
|
||||||
|
default "Cortex-M33" if ARCH_CORTEX_M33 && COMPILER_ICCARM
|
||||||
|
default "Cortex-M55" if ARCH_CORTEX_M55 && COMPILER_ICCARM
|
||||||
default "arm9" if ARCH_ARM9
|
default "arm9" if ARCH_ARM9
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ kernel_module(module_name) {
|
|||||||
"los_timer.c",
|
"los_timer.c",
|
||||||
"reset_vector.S",
|
"reset_vector.S",
|
||||||
]
|
]
|
||||||
|
configs += [ "$LITEOSTOPDIR:warn_config" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
config("public") {
|
config("public") {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
* Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
* are permitted provided that the following conditions are met:
|
* are permitted provided that the following conditions are met:
|
||||||
@@ -33,6 +33,7 @@
|
|||||||
#define _LOS_ARCH_ATOMIC_H
|
#define _LOS_ARCH_ATOMIC_H
|
||||||
|
|
||||||
#include "los_compiler.h"
|
#include "los_compiler.h"
|
||||||
|
#include "los_interrupt.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
|
|||||||
@@ -97,7 +97,8 @@ extern UINT32 g_intCount;
|
|||||||
*
|
*
|
||||||
* Value: 0x02000900
|
* Value: 0x02000900
|
||||||
*
|
*
|
||||||
* Solution: Ensure that the interrupt number is valid. The value range of the interrupt number applicable for a Cortex-A7 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
|
* Solution: Ensure that the interrupt number is valid.
|
||||||
|
* The value range of the interrupt number applicable for a arm9 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
|
||||||
*/
|
*/
|
||||||
#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
|
#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
|
||||||
|
|
||||||
@@ -147,7 +148,8 @@ extern UINT32 g_intCount;
|
|||||||
*
|
*
|
||||||
* Value: 0x02000905
|
* Value: 0x02000905
|
||||||
*
|
*
|
||||||
* Solution: Ensure that the interrupt priority is valid. The value range of the interrupt priority applicable for a Cortex-A7 platform is [0,15].
|
* Solution: Ensure that the interrupt priority is valid.
|
||||||
|
* The value range of the interrupt priority applicable for a arm9 platform is [0,15].
|
||||||
*/
|
*/
|
||||||
#define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05)
|
#define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05)
|
||||||
|
|
||||||
@@ -157,7 +159,8 @@ extern UINT32 g_intCount;
|
|||||||
*
|
*
|
||||||
* Value: 0x02000906
|
* Value: 0x02000906
|
||||||
*
|
*
|
||||||
* Solution: The interrupt creation mode can be only set to OS_HWI_MODE_COMM or OS_HWI_MODE_FAST of which the value can be 0 or 1.
|
* Solution: The interrupt creation mode can be only set to OS_HWI_MODE_COMM or
|
||||||
|
* OS_HWI_MODE_FAST of which the value can be 0 or 1.
|
||||||
*/
|
*/
|
||||||
#define OS_ERRNO_HWI_MODE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x06)
|
#define OS_ERRNO_HWI_MODE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x06)
|
||||||
|
|
||||||
@@ -204,25 +207,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
|
|||||||
*/
|
*/
|
||||||
extern VOID HalInterrupt(VOID);
|
extern VOID HalInterrupt(VOID);
|
||||||
|
|
||||||
/* *
|
|
||||||
* @ingroup los_arch_interrupt
|
|
||||||
* @brief: Get an interrupt number.
|
|
||||||
*
|
|
||||||
* @par Description:
|
|
||||||
* This API is used to get the current interrupt number.
|
|
||||||
*
|
|
||||||
* @attention:
|
|
||||||
* <ul><li>None.</li></ul>
|
|
||||||
*
|
|
||||||
* @param: None.
|
|
||||||
*
|
|
||||||
* @retval: Interrupt Indexes number.
|
|
||||||
* @par Dependency:
|
|
||||||
* <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
|
|
||||||
* @see None.
|
|
||||||
*/
|
|
||||||
extern UINT32 HalIntNumGet(VOID);
|
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_arch_interrupt
|
* @ingroup los_arch_interrupt
|
||||||
* @brief: Default vector handling function.
|
* @brief: Default vector handling function.
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ LITE_OS_SEC_TEXT_INIT VOID ArchInit(VOID)
|
|||||||
**************************************************************************** */
|
**************************************************************************** */
|
||||||
LITE_OS_SEC_TEXT_MINOR VOID ArchSysExit(VOID)
|
LITE_OS_SEC_TEXT_MINOR VOID ArchSysExit(VOID)
|
||||||
{
|
{
|
||||||
LOS_IntLock();
|
(VOID)LOS_IntLock();
|
||||||
while (1) {
|
while (1) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -75,18 +75,8 @@ LITE_OS_SEC_TEXT_MINOR VOID ArchSysExit(VOID)
|
|||||||
**************************************************************************** */
|
**************************************************************************** */
|
||||||
LITE_OS_SEC_TEXT_INIT VOID *ArchTskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack)
|
LITE_OS_SEC_TEXT_INIT VOID *ArchTskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack)
|
||||||
{
|
{
|
||||||
TaskContext *context = NULL;
|
TaskContext *context = (TaskContext *)((UINTPTR)topStack + stackSize - sizeof(TaskContext));
|
||||||
LosTaskCB *taskCB = OS_TCB_FROM_TID(taskID);
|
LosTaskCB *taskCB = OS_TCB_FROM_TID(taskID);
|
||||||
errno_t result;
|
|
||||||
|
|
||||||
/* initialize the task stack, write magic num to stack top */
|
|
||||||
result = memset_s(topStack, stackSize, (INT32)(OS_TASK_STACK_INIT & 0xFF), stackSize);
|
|
||||||
if (result != EOK) {
|
|
||||||
PRINT_ERR("memset_s is failed:%s[%d]\r\n", __FUNCTION__, __LINE__);
|
|
||||||
}
|
|
||||||
*((UINT32 *)(topStack)) = OS_TASK_MAGIC_WORD;
|
|
||||||
|
|
||||||
context = (TaskContext *)(((UINTPTR)topStack + stackSize) - sizeof(TaskContext));
|
|
||||||
|
|
||||||
context->r0 = taskID;
|
context->r0 = taskID;
|
||||||
context->r1 = 0x01010101L;
|
context->r1 = 0x01010101L;
|
||||||
|
|||||||
@@ -39,6 +39,9 @@
|
|||||||
#include "los_sched.h"
|
#include "los_sched.h"
|
||||||
#include "los_memory.h"
|
#include "los_memory.h"
|
||||||
#include "los_membox.h"
|
#include "los_membox.h"
|
||||||
|
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
|
||||||
|
#include "los_cpup.h"
|
||||||
|
#endif
|
||||||
#include "los_reg.h"
|
#include "los_reg.h"
|
||||||
|
|
||||||
#define OS_INT_IRQ_ENABLE (1U << 0)
|
#define OS_INT_IRQ_ENABLE (1U << 0)
|
||||||
@@ -48,9 +51,6 @@
|
|||||||
#define OS_INT_ENABLE_ADDR (OS_INT_REG_BASE)
|
#define OS_INT_ENABLE_ADDR (OS_INT_REG_BASE)
|
||||||
#define OS_INT_STATUS_ADDR (OS_INT_REG_BASE + 12)
|
#define OS_INT_STATUS_ADDR (OS_INT_REG_BASE + 12)
|
||||||
|
|
||||||
#define OS_INT_ENABLE(num) (*((volatile UINT32 *)OS_INT_ENABLE_ADDR) |= (1U << (num)))
|
|
||||||
#define OS_INT_DISABLE(num) (*((volatile UINT32 *)OS_INT_ENABLE_ADDR ) &= ~(1U << (num)))
|
|
||||||
|
|
||||||
#define OS_INSTR_SET_MASK 0x01000020U
|
#define OS_INSTR_SET_MASK 0x01000020U
|
||||||
#define OS_ARM_INSTR_LEN 4
|
#define OS_ARM_INSTR_LEN 4
|
||||||
#define OS_THUMB_INSTR_LEN 2
|
#define OS_THUMB_INSTR_LEN 2
|
||||||
@@ -64,6 +64,30 @@ ExcInfo g_excInfo = {0};
|
|||||||
*/
|
*/
|
||||||
STATIC HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT] = {0};
|
STATIC HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT] = {0};
|
||||||
|
|
||||||
|
#if (LOSCFG_DEBUG_TOOLS == 1)
|
||||||
|
STATIC UINT32 g_hwiFormCnt[OS_HWI_MAX_NUM] = {0};
|
||||||
|
STATIC CHAR *g_hwiFormName[OS_HWI_MAX_NUM] = {0};
|
||||||
|
|
||||||
|
UINT32 OsGetHwiFormCnt(UINT32 index)
|
||||||
|
{
|
||||||
|
return g_hwiFormCnt[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
CHAR *OsGetHwiFormName(UINT32 index)
|
||||||
|
{
|
||||||
|
return g_hwiFormName[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL OsGetHwiCreated(UINT32 index)
|
||||||
|
{
|
||||||
|
if (g_hwiForm[index] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
|
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -112,20 +136,49 @@ VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector)
|
|||||||
|
|
||||||
|
|
||||||
/* ****************************************************************************
|
/* ****************************************************************************
|
||||||
Function : HalIntNumGet
|
Function : HwiNumGet
|
||||||
Description : Get an interrupt number
|
Description : Get an interrupt number
|
||||||
Input : None
|
Input : None
|
||||||
Output : None
|
Output : None
|
||||||
Return : Interrupt Indexes number
|
Return : Interrupt Indexes number
|
||||||
**************************************************************************** */
|
**************************************************************************** */
|
||||||
LITE_OS_SEC_TEXT_MINOR UINT32 HalIntNumGet(VOID)
|
STATIC UINT32 HwiNumGet(VOID)
|
||||||
{
|
{
|
||||||
UINT32 status;
|
UINT32 status;
|
||||||
|
|
||||||
READ_UINT32(status, OS_INT_STATUS_ADDR);
|
READ_UINT32(status, OS_INT_STATUS_ADDR);
|
||||||
|
|
||||||
return (31 - CLZ(status));
|
return (31 - CLZ(status));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
|
||||||
|
{
|
||||||
|
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||||
|
return OS_ERRNO_HWI_NUM_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
*((volatile UINT32 *)OS_INT_ENABLE_ADDR) |= (1U << (hwiNum));
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
|
||||||
|
{
|
||||||
|
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||||
|
return OS_ERRNO_HWI_NUM_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
*((volatile UINT32 *)OS_INT_ENABLE_ADDR) &= ~(1U << (hwiNum));
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
HwiControllerOps g_archHwiOps = {
|
||||||
|
.enableIrq = HwiUnmask,
|
||||||
|
.disableIrq = HwiMask,
|
||||||
|
.getCurIrqNum = HwiNumGet,
|
||||||
|
};
|
||||||
|
|
||||||
inline UINT32 ArchIsIntActive(VOID)
|
inline UINT32 ArchIsIntActive(VOID)
|
||||||
{
|
{
|
||||||
return (g_intCount > 0);
|
return (g_intCount > 0);
|
||||||
@@ -137,21 +190,21 @@ inline UINT32 ArchIsIntActive(VOID)
|
|||||||
Output : None
|
Output : None
|
||||||
Return : None
|
Return : None
|
||||||
**************************************************************************** */
|
**************************************************************************** */
|
||||||
/*lint -e529*/
|
|
||||||
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
|
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
|
||||||
{
|
{
|
||||||
UINT32 irqNum = HalIntNumGet();
|
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet());
|
||||||
PRINT_ERR("%s irqnum:%d\n", __FUNCTION__, irqNum);
|
|
||||||
while (1) {}
|
while (1) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
WEAK VOID HalPreInterruptHandler(UINT32 arg)
|
WEAK VOID HalPreInterruptHandler(UINT32 arg)
|
||||||
{
|
{
|
||||||
|
(VOID)arg;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
WEAK VOID HalAftInterruptHandler(UINT32 arg)
|
WEAK VOID HalAftInterruptHandler(UINT32 arg)
|
||||||
{
|
{
|
||||||
|
(VOID)arg;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,9 +228,12 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
|
|||||||
OsSchedUpdateSleepTime();
|
OsSchedUpdateSleepTime();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
hwiIndex = HalIntNumGet();
|
hwiIndex = HwiNumGet();
|
||||||
|
|
||||||
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
|
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
|
||||||
|
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
|
||||||
|
OsCpupIrqStart(hwiIndex);
|
||||||
|
#endif
|
||||||
|
|
||||||
HalPreInterruptHandler(hwiIndex);
|
HalPreInterruptHandler(hwiIndex);
|
||||||
|
|
||||||
@@ -191,8 +247,16 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if (LOSCFG_DEBUG_TOOLS == 1)
|
||||||
|
++g_hwiFormCnt[hwiIndex];
|
||||||
|
#endif
|
||||||
|
|
||||||
HalAftInterruptHandler(hwiIndex);
|
HalAftInterruptHandler(hwiIndex);
|
||||||
|
|
||||||
|
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
|
||||||
|
OsCpupIrqEnd(hwiIndex);
|
||||||
|
#endif
|
||||||
|
|
||||||
OsHookCall(LOS_HOOK_TYPE_ISR_EXIT, hwiIndex);
|
OsHookCall(LOS_HOOK_TYPE_ISR_EXIT, hwiIndex);
|
||||||
|
|
||||||
intSave = LOS_IntLock();
|
intSave = LOS_IntLock();
|
||||||
@@ -205,21 +269,22 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
|
|||||||
Description : create hardware interrupt
|
Description : create hardware interrupt
|
||||||
Input : hwiNum --- hwi num to create
|
Input : hwiNum --- hwi num to create
|
||||||
hwiPrio --- priority of the hwi
|
hwiPrio --- priority of the hwi
|
||||||
mode --- unused
|
hwiMode --- unused
|
||||||
handler --- hwi handler
|
hwiHandler --- hwi handler
|
||||||
arg --- param of the hwi handler
|
irqParam --- param of the hwi handler
|
||||||
Output : None
|
Output : None
|
||||||
Return : LOS_OK on success or error code on failure
|
Return : LOS_OK on success or error code on failure
|
||||||
**************************************************************************** */
|
**************************************************************************** */
|
||||||
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
||||||
HWI_PRIOR_T hwiPrio,
|
HWI_PRIOR_T hwiPrio,
|
||||||
HWI_MODE_T mode,
|
HWI_MODE_T hwiMode,
|
||||||
HWI_PROC_FUNC handler,
|
HWI_PROC_FUNC hwiHandler,
|
||||||
HWI_ARG_T arg)
|
HwiIrqParam *irqParam)
|
||||||
{
|
{
|
||||||
|
(VOID)hwiMode;
|
||||||
UINT32 intSave;
|
UINT32 intSave;
|
||||||
|
|
||||||
if (handler == NULL) {
|
if (hwiHandler == NULL) {
|
||||||
return OS_ERRNO_HWI_PROC_FUNC_NULL;
|
return OS_ERRNO_HWI_PROC_FUNC_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -233,11 +298,22 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
|||||||
|
|
||||||
intSave = LOS_IntLock();
|
intSave = LOS_IntLock();
|
||||||
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
|
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
|
||||||
OsSetVector(hwiNum, handler, arg);
|
if (irqParam != NULL) {
|
||||||
|
OsSetVector(hwiNum, hwiHandler, irqParam->pDevId);
|
||||||
|
} else {
|
||||||
|
OsSetVector(hwiNum, hwiHandler, NULL);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
OsSetVector(hwiNum, handler);
|
(VOID)irqParam;
|
||||||
|
OsSetVector(hwiNum, hwiHandler);
|
||||||
#endif
|
#endif
|
||||||
OS_INT_ENABLE(hwiNum);
|
#if (LOSCFG_DEBUG_TOOLS == 1)
|
||||||
|
if ((irqParam != NULL) && (irqParam->pName != NULL)) {
|
||||||
|
g_hwiFormName[hwiNum + OS_SYS_VECTOR_CNT] = (CHAR *)irqParam->pName;
|
||||||
|
}
|
||||||
|
g_hwiFormCnt[hwiNum + OS_SYS_VECTOR_CNT] = 0;
|
||||||
|
#endif
|
||||||
|
HwiUnmask(hwiNum);
|
||||||
LOS_IntRestore(intSave);
|
LOS_IntRestore(intSave);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
@@ -247,18 +323,20 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
|||||||
Function : ArchHwiDelete
|
Function : ArchHwiDelete
|
||||||
Description : Delete hardware interrupt
|
Description : Delete hardware interrupt
|
||||||
Input : hwiNum --- hwi num to delete
|
Input : hwiNum --- hwi num to delete
|
||||||
|
irqParam --- param of the hwi handler
|
||||||
Output : None
|
Output : None
|
||||||
Return : LOS_OK on success or error code on failure
|
Return : LOS_OK on success or error code on failure
|
||||||
**************************************************************************** */
|
**************************************************************************** */
|
||||||
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum)
|
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam)
|
||||||
{
|
{
|
||||||
|
(VOID)irqParam;
|
||||||
UINT32 intSave;
|
UINT32 intSave;
|
||||||
|
|
||||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
return OS_ERRNO_HWI_NUM_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
OS_INT_DISABLE(hwiNum);
|
HwiMask(hwiNum);
|
||||||
|
|
||||||
intSave = LOS_IntLock();
|
intSave = LOS_IntLock();
|
||||||
g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
|
g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
|
||||||
@@ -316,6 +394,7 @@ STATIC VOID OsExcRegInfo(const ExcInfo *excInfo)
|
|||||||
PRINTK("xPSR = 0x%x\n", excInfo->context->spsr);
|
PRINTK("xPSR = 0x%x\n", excInfo->context->spsr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if (LOSCFG_KERNEL_BACKTRACE == 1)
|
||||||
STATIC VOID OsExcBackTraceInfo(const ExcInfo *excInfo)
|
STATIC VOID OsExcBackTraceInfo(const ExcInfo *excInfo)
|
||||||
{
|
{
|
||||||
UINTPTR LR[LOSCFG_BACKTRACE_DEPTH] = {0};
|
UINTPTR LR[LOSCFG_BACKTRACE_DEPTH] = {0};
|
||||||
@@ -332,6 +411,7 @@ STATIC VOID OsExcBackTraceInfo(const ExcInfo *excInfo)
|
|||||||
}
|
}
|
||||||
PRINTK("----- backtrace end -----\n");
|
PRINTK("----- backtrace end -----\n");
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
STATIC VOID OsExcMemPoolCheckInfo(VOID)
|
STATIC VOID OsExcMemPoolCheckInfo(VOID)
|
||||||
{
|
{
|
||||||
@@ -381,7 +461,9 @@ STATIC VOID OsExcInfoDisplay(const ExcInfo *excInfo)
|
|||||||
OsExcTypeInfo(excInfo);
|
OsExcTypeInfo(excInfo);
|
||||||
OsExcCurTaskInfo(excInfo);
|
OsExcCurTaskInfo(excInfo);
|
||||||
OsExcRegInfo(excInfo);
|
OsExcRegInfo(excInfo);
|
||||||
|
#if (LOSCFG_KERNEL_BACKTRACE == 1)
|
||||||
OsExcBackTraceInfo(excInfo);
|
OsExcBackTraceInfo(excInfo);
|
||||||
|
#endif
|
||||||
OsGetAllTskInfo();
|
OsGetAllTskInfo();
|
||||||
OsExcMemPoolCheckInfo();
|
OsExcMemPoolCheckInfo();
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -52,7 +52,7 @@
|
|||||||
#define OS_TIMER_READ_VAL_ADDR (OS_TIMER_REG_BASE + 20)
|
#define OS_TIMER_READ_VAL_ADDR (OS_TIMER_REG_BASE + 20)
|
||||||
|
|
||||||
STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler);
|
STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler);
|
||||||
STATIC VOID SysTickReload(UINT64 nextResponseTime);
|
STATIC UINT64 SysTickReload(UINT64 nextResponseTime);
|
||||||
STATIC UINT64 SysTickCycleGet(UINT32 *period);
|
STATIC UINT64 SysTickCycleGet(UINT32 *period);
|
||||||
STATIC VOID SysTickLock(VOID);
|
STATIC VOID SysTickLock(VOID);
|
||||||
STATIC VOID SysTickUnlock(VOID);
|
STATIC VOID SysTickUnlock(VOID);
|
||||||
@@ -60,6 +60,7 @@ STATIC VOID SysTickUnlock(VOID);
|
|||||||
STATIC ArchTickTimer g_archTickTimer = {
|
STATIC ArchTickTimer g_archTickTimer = {
|
||||||
.freq = 0,
|
.freq = 0,
|
||||||
.irqNum = OS_TIMER_IRQ_NUM,
|
.irqNum = OS_TIMER_IRQ_NUM,
|
||||||
|
.periodMax = LOSCFG_BASE_CORE_TICK_RESPONSE_MAX,
|
||||||
.init = SysTickStart,
|
.init = SysTickStart,
|
||||||
.getCycle = SysTickCycleGet,
|
.getCycle = SysTickCycleGet,
|
||||||
.reload = SysTickReload,
|
.reload = SysTickReload,
|
||||||
@@ -107,12 +108,17 @@ STATIC VOID SysTickClockIrqClear(VOID)
|
|||||||
} while (status & mask);
|
} while (status & mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC VOID SysTickReload(UINT64 nextResponseTime)
|
STATIC UINT64 SysTickReload(UINT64 nextResponseTime)
|
||||||
{
|
{
|
||||||
|
if (nextResponseTime > g_archTickTimer.periodMax) {
|
||||||
|
nextResponseTime = g_archTickTimer.periodMax;
|
||||||
|
}
|
||||||
|
|
||||||
SysTickLock();
|
SysTickLock();
|
||||||
WRITE_UINT32(nextResponseTime, OS_TIMER_PERIOD_REG_ADDR);
|
WRITE_UINT32((UINT32)nextResponseTime, OS_TIMER_PERIOD_REG_ADDR);
|
||||||
SysTickClockIrqClear();
|
SysTickClockIrqClear();
|
||||||
SysTickUnlock();
|
SysTickUnlock();
|
||||||
|
return nextResponseTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC UINT64 SysTickCycleGet(UINT32 *period)
|
STATIC UINT64 SysTickCycleGet(UINT32 *period)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
* Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
* are permitted provided that the following conditions are met:
|
* are permitted provided that the following conditions are met:
|
||||||
@@ -33,6 +33,7 @@
|
|||||||
#define _LOS_ARCH_ATOMIC_H
|
#define _LOS_ARCH_ATOMIC_H
|
||||||
|
|
||||||
#include "los_compiler.h"
|
#include "los_compiler.h"
|
||||||
|
#include "los_interrupt.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
@@ -40,73 +41,6 @@ extern "C" {
|
|||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
STATIC INLINE INT32 ArchAtomicRead(const Atomic *v)
|
|
||||||
{
|
|
||||||
INT32 val;
|
|
||||||
UINT32 intSave;
|
|
||||||
|
|
||||||
intSave = LOS_IntLock();
|
|
||||||
|
|
||||||
__asm__ __volatile__("ldrex %0, [%1]\n"
|
|
||||||
: "=&r"(val)
|
|
||||||
: "r"(v)
|
|
||||||
: "cc");
|
|
||||||
LOS_IntRestore(intSave);
|
|
||||||
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
|
|
||||||
STATIC INLINE VOID ArchAtomicSet(Atomic *v, INT32 setVal)
|
|
||||||
{
|
|
||||||
UINT32 status;
|
|
||||||
UINT32 intSave;
|
|
||||||
|
|
||||||
intSave = LOS_IntLock();
|
|
||||||
|
|
||||||
__asm__ __volatile__("1:ldrex %0, [%1]\n"
|
|
||||||
" strex %0, %2, [%1]\n"
|
|
||||||
" teq %0, #0\n"
|
|
||||||
" bne 1b"
|
|
||||||
: "=&r"(status)
|
|
||||||
: "r"(v), "r"(setVal)
|
|
||||||
: "cc");
|
|
||||||
LOS_IntRestore(intSave);
|
|
||||||
}
|
|
||||||
|
|
||||||
STATIC INLINE INT32 ArchAtomicAdd(Atomic *v, INT32 addVal)
|
|
||||||
{
|
|
||||||
INT32 val;
|
|
||||||
UINT32 status;
|
|
||||||
|
|
||||||
do {
|
|
||||||
__asm__ __volatile__("ldrex %1, [%2]\n"
|
|
||||||
"add %1, %1, %3\n"
|
|
||||||
"strex %0, %1, [%2]"
|
|
||||||
: "=&r"(status), "=&r"(val)
|
|
||||||
: "r"(v), "r"(addVal)
|
|
||||||
: "cc");
|
|
||||||
} while (__builtin_expect(status != 0, 0));
|
|
||||||
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
|
|
||||||
STATIC INLINE INT32 ArchAtomicSub(Atomic *v, INT32 subVal)
|
|
||||||
{
|
|
||||||
INT32 val;
|
|
||||||
UINT32 status;
|
|
||||||
|
|
||||||
do {
|
|
||||||
__asm__ __volatile__("ldrex %1, [%2]\n"
|
|
||||||
"sub %1, %1, %3\n"
|
|
||||||
"strex %0, %1, [%2]"
|
|
||||||
: "=&r"(status), "=&r"(val)
|
|
||||||
: "r"(v), "r"(subVal)
|
|
||||||
: "cc");
|
|
||||||
} while (__builtin_expect(status != 0, 0));
|
|
||||||
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
|
|
||||||
STATIC INLINE VOID ArchAtomicInc(Atomic *v)
|
STATIC INLINE VOID ArchAtomicInc(Atomic *v)
|
||||||
{
|
{
|
||||||
(VOID)ArchAtomicAdd(v, 1);
|
(VOID)ArchAtomicAdd(v, 1);
|
||||||
@@ -127,91 +61,6 @@ STATIC INLINE INT32 ArchAtomicDecRet(Atomic *v)
|
|||||||
return ArchAtomicSub(v, 1);
|
return ArchAtomicSub(v, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @ingroup los_arch_atomic
|
|
||||||
* @brief Atomic exchange for 32-bit variable.
|
|
||||||
*
|
|
||||||
* @par Description:
|
|
||||||
* This API is used to implement the atomic exchange for 32-bit variable
|
|
||||||
* and return the previous value of the atomic variable.
|
|
||||||
* @attention
|
|
||||||
* <ul>The pointer v must not be NULL.</ul>
|
|
||||||
*
|
|
||||||
* @param v [IN] The variable pointer.
|
|
||||||
* @param val [IN] The exchange value.
|
|
||||||
*
|
|
||||||
* @retval #INT32 The previous value of the atomic variable
|
|
||||||
* @par Dependency:
|
|
||||||
* <ul><li>los_arch_atomic.h: the header file that contains the API declaration.</li></ul>
|
|
||||||
* @see
|
|
||||||
*/
|
|
||||||
STATIC INLINE INT32 ArchAtomicXchg32bits(volatile INT32 *v, INT32 val)
|
|
||||||
{
|
|
||||||
INT32 prevVal = 0;
|
|
||||||
UINT32 status = 0;
|
|
||||||
|
|
||||||
do {
|
|
||||||
__asm__ __volatile__("ldrex %0, [%3]\n"
|
|
||||||
"strex %1, %4, [%3]"
|
|
||||||
: "=&r"(prevVal), "=&r"(status), "+m"(*v)
|
|
||||||
: "r"(v), "r"(val)
|
|
||||||
: "cc");
|
|
||||||
} while (__builtin_expect(status != 0, 0));
|
|
||||||
|
|
||||||
return prevVal;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ingroup los_arch_atomic
|
|
||||||
* @brief Atomic exchange for 32-bit variable with compare.
|
|
||||||
*
|
|
||||||
* @par Description:
|
|
||||||
* This API is used to implement the atomic exchange for 32-bit variable, if the value of variable is equal to oldVal.
|
|
||||||
* @attention
|
|
||||||
* <ul>The pointer v must not be NULL.</ul>
|
|
||||||
*
|
|
||||||
* @param v [IN] The variable pointer.
|
|
||||||
* @param val [IN] The new value.
|
|
||||||
* @param oldVal [IN] The old value.
|
|
||||||
*
|
|
||||||
* @retval TRUE The previous value of the atomic variable is not equal to oldVal.
|
|
||||||
* @retval FALSE The previous value of the atomic variable is equal to oldVal.
|
|
||||||
* @par Dependency:
|
|
||||||
* <ul><li>los_arch_atomic.h: the header file that contains the API declaration.</li></ul>
|
|
||||||
* @see
|
|
||||||
*/
|
|
||||||
STATIC INLINE BOOL ArchAtomicCmpXchg32bits(volatile INT32 *v, INT32 val, INT32 oldVal)
|
|
||||||
{
|
|
||||||
INT32 prevVal = 0;
|
|
||||||
UINT32 status = 0;
|
|
||||||
|
|
||||||
do {
|
|
||||||
__asm__ __volatile__("1: ldrex %0, %2\n"
|
|
||||||
" mov %1, #0\n"
|
|
||||||
" cmp %0, %3\n"
|
|
||||||
" bne 2f\n"
|
|
||||||
" strex %1, %4, %2\n"
|
|
||||||
"2:"
|
|
||||||
: "=&r"(prevVal), "=&r"(status), "+Q"(*v)
|
|
||||||
: "r"(oldVal), "r"(val)
|
|
||||||
: "cc");
|
|
||||||
} while (__builtin_expect(status != 0, 0));
|
|
||||||
|
|
||||||
return prevVal != oldVal;
|
|
||||||
}
|
|
||||||
|
|
||||||
STATIC INLINE INT64 ArchAtomic64Read(const Atomic64 *v)
|
|
||||||
{
|
|
||||||
INT64 val;
|
|
||||||
UINT32 intSave;
|
|
||||||
|
|
||||||
intSave = LOS_IntLock();
|
|
||||||
val = *v;
|
|
||||||
LOS_IntRestore(intSave);
|
|
||||||
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
|
|
||||||
STATIC INLINE VOID ArchAtomic64Set(Atomic64 *v, INT64 setVal)
|
STATIC INLINE VOID ArchAtomic64Set(Atomic64 *v, INT64 setVal)
|
||||||
{
|
{
|
||||||
UINT32 intSave;
|
UINT32 intSave;
|
||||||
|
|||||||
@@ -109,7 +109,8 @@ extern UINT32 _BootVectors[];
|
|||||||
*
|
*
|
||||||
* Value: 0x02000900
|
* Value: 0x02000900
|
||||||
*
|
*
|
||||||
* Solution: Ensure that the interrupt number is valid. The value range of the interrupt number applicable for a Cortex-A7 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
|
* Solution: Ensure that the interrupt number is valid.
|
||||||
|
* The value range of the interrupt number applicable for a Cortex-M3 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
|
||||||
*/
|
*/
|
||||||
#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
|
#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
|
||||||
|
|
||||||
@@ -159,7 +160,8 @@ extern UINT32 _BootVectors[];
|
|||||||
*
|
*
|
||||||
* Value: 0x02000905
|
* Value: 0x02000905
|
||||||
*
|
*
|
||||||
* Solution: Ensure that the interrupt priority is valid. The value range of the interrupt priority applicable for a Cortex-A7 platform is [0,15].
|
* Solution: Ensure that the interrupt priority is valid.
|
||||||
|
* The value range of the interrupt priority applicable for a Cortex-M3 platform is [0,15].
|
||||||
*/
|
*/
|
||||||
#define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05)
|
#define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05)
|
||||||
|
|
||||||
@@ -169,7 +171,8 @@ extern UINT32 _BootVectors[];
|
|||||||
*
|
*
|
||||||
* Value: 0x02000906
|
* Value: 0x02000906
|
||||||
*
|
*
|
||||||
* Solution: The interrupt creation mode can be only set to OS_HWI_MODE_COMM or OS_HWI_MODE_FAST of which the value can be 0 or 1.
|
* Solution: The interrupt creation mode can be only set to OS_HWI_MODE_COMM or
|
||||||
|
* OS_HWI_MODE_FAST of which the value can be 0 or 1.
|
||||||
*/
|
*/
|
||||||
#define OS_ERRNO_HWI_MODE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x06)
|
#define OS_ERRNO_HWI_MODE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x06)
|
||||||
|
|
||||||
@@ -342,25 +345,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
|
|||||||
*/
|
*/
|
||||||
extern VOID HalInterrupt(VOID);
|
extern VOID HalInterrupt(VOID);
|
||||||
|
|
||||||
/* *
|
|
||||||
* @ingroup los_arch_interrupt
|
|
||||||
* @brief: Get an interrupt number.
|
|
||||||
*
|
|
||||||
* @par Description:
|
|
||||||
* This API is used to get the current interrupt number.
|
|
||||||
*
|
|
||||||
* @attention:
|
|
||||||
* <ul><li>None.</li></ul>
|
|
||||||
*
|
|
||||||
* @param: None.
|
|
||||||
*
|
|
||||||
* @retval: Interrupt Indexes number.
|
|
||||||
* @par Dependency:
|
|
||||||
* <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
|
|
||||||
* @see None.
|
|
||||||
*/
|
|
||||||
extern UINT32 HalIntNumGet(VOID);
|
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_arch_interrupt
|
* @ingroup los_arch_interrupt
|
||||||
* @brief: Default vector handling function.
|
* @brief: Default vector handling function.
|
||||||
|
|||||||
@@ -0,0 +1,98 @@
|
|||||||
|
;
|
||||||
|
; 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.
|
||||||
|
;
|
||||||
|
|
||||||
|
EXPORT ArchAtomicRead
|
||||||
|
EXPORT ArchAtomicSet
|
||||||
|
EXPORT ArchAtomicAdd
|
||||||
|
EXPORT ArchAtomicSub
|
||||||
|
EXPORT ArchAtomicXchg32bits
|
||||||
|
EXPORT ArchAtomicCmpXchg32bits
|
||||||
|
|
||||||
|
PRESERVE8
|
||||||
|
AREA |.text|, CODE, READONLY
|
||||||
|
THUMB
|
||||||
|
|
||||||
|
|
||||||
|
EXPORT ArchAtomicRead
|
||||||
|
EXPORT ArchAtomicSet
|
||||||
|
EXPORT ArchAtomicAdd
|
||||||
|
EXPORT ArchAtomicSub
|
||||||
|
EXPORT ArchAtomicXchg32bits
|
||||||
|
EXPORT ArchAtomicCmpXchg32bits
|
||||||
|
|
||||||
|
PRESERVE8
|
||||||
|
AREA |.text|, CODE, READONLY
|
||||||
|
THUMB
|
||||||
|
|
||||||
|
ArchAtomicRead
|
||||||
|
ldrex r1, [r0]
|
||||||
|
mov r0, r1
|
||||||
|
bx lr
|
||||||
|
|
||||||
|
ArchAtomicSet
|
||||||
|
ldrex r2, [r0]
|
||||||
|
strex r3, r1, [r0]
|
||||||
|
teq r3, #0
|
||||||
|
bne ArchAtomicSet
|
||||||
|
bx lr
|
||||||
|
|
||||||
|
ArchAtomicAdd
|
||||||
|
ldrex r2, [r0]
|
||||||
|
add r2, r2, r1
|
||||||
|
strex r3, r2, [r0]
|
||||||
|
teq r3, #0
|
||||||
|
bne ArchAtomicAdd
|
||||||
|
mov r0, r2
|
||||||
|
bx lr
|
||||||
|
|
||||||
|
ArchAtomicSub
|
||||||
|
ldrex r2, [r0]
|
||||||
|
sub r2, r2, r1
|
||||||
|
strex r3, r2, [r0]
|
||||||
|
teq r3, #0
|
||||||
|
bne ArchAtomicSub
|
||||||
|
mov r0, r2
|
||||||
|
bx lr
|
||||||
|
|
||||||
|
ArchAtomicXchg32bits
|
||||||
|
ldrex r2, [r0]
|
||||||
|
strex r3, r1, [r0]
|
||||||
|
teq r3, #0
|
||||||
|
bne ArchAtomicXchg32bits
|
||||||
|
mov r0, r2
|
||||||
|
|
||||||
|
ArchAtomicCmpXchg32bits
|
||||||
|
ldrex r3, [r0]
|
||||||
|
cmp r3, r2
|
||||||
|
bne end
|
||||||
|
strex r4, r1, [r0]
|
||||||
|
teq r4, #0
|
||||||
|
bne ArchAtomicCmpXchg32bits
|
||||||
|
end
|
||||||
@@ -60,7 +60,7 @@ LITE_OS_SEC_TEXT_INIT VOID ArchInit(VOID)
|
|||||||
**************************************************************************** */
|
**************************************************************************** */
|
||||||
LITE_OS_SEC_TEXT_MINOR VOID ArchSysExit(VOID)
|
LITE_OS_SEC_TEXT_MINOR VOID ArchSysExit(VOID)
|
||||||
{
|
{
|
||||||
LOS_IntLock();
|
(VOID)LOS_IntLock();
|
||||||
while (1) {
|
while (1) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -76,17 +76,7 @@ LITE_OS_SEC_TEXT_MINOR VOID ArchSysExit(VOID)
|
|||||||
**************************************************************************** */
|
**************************************************************************** */
|
||||||
LITE_OS_SEC_TEXT_INIT VOID *ArchTskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack)
|
LITE_OS_SEC_TEXT_INIT VOID *ArchTskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack)
|
||||||
{
|
{
|
||||||
TaskContext *context = NULL;
|
TaskContext *context = (TaskContext *)((UINTPTR)topStack + stackSize - sizeof(TaskContext));
|
||||||
errno_t result;
|
|
||||||
|
|
||||||
/* initialize the task stack, write magic num to stack top */
|
|
||||||
result = memset_s(topStack, stackSize, (INT32)(OS_TASK_STACK_INIT & 0xFF), stackSize);
|
|
||||||
if (result != EOK) {
|
|
||||||
printf("memset_s is failed:%s[%d]\r\n", __FUNCTION__, __LINE__);
|
|
||||||
}
|
|
||||||
*((UINT32 *)(topStack)) = OS_TASK_MAGIC_WORD;
|
|
||||||
|
|
||||||
context = (TaskContext *)(((UINTPTR)topStack + stackSize) - sizeof(TaskContext));
|
|
||||||
|
|
||||||
#if ((defined(__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
|
#if ((defined(__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
|
||||||
(defined(__FPU_USED) && (__FPU_USED == 1U)))
|
(defined(__FPU_USED) && (__FPU_USED == 1U)))
|
||||||
|
|||||||
@@ -190,7 +190,7 @@ _hwiActiveCheck
|
|||||||
CMP R3, #0
|
CMP R3, #0
|
||||||
BEQ _hwiActiveCheckNext
|
BEQ _hwiActiveCheckNext
|
||||||
|
|
||||||
; exc occured in IRQ
|
; exc occurred in IRQ
|
||||||
ORR R0, R0, #FLAG_HWI_ACTIVE
|
ORR R0, R0, #FLAG_HWI_ACTIVE
|
||||||
RBIT R2, R3
|
RBIT R2, R3
|
||||||
CLZ R2, R2
|
CLZ R2, R2
|
||||||
@@ -228,19 +228,19 @@ _hwiActiveCheckNext
|
|||||||
AND R2, R2,R3
|
AND R2, R2,R3
|
||||||
CMP R2,#0
|
CMP R2,#0
|
||||||
BNE _ExcInMSP
|
BNE _ExcInMSP
|
||||||
; exc occured in Task or Init or exc
|
; exc occurred in Task or Init or exc
|
||||||
; reserved for register info from task stack
|
; reserved for register info from task stack
|
||||||
|
|
||||||
LDR R2, =g_taskScheduled
|
LDR R2, =g_taskScheduled
|
||||||
LDR R2, [R2]
|
LDR R2, [R2]
|
||||||
TST R2, #1 ; OS_FLG_BGD_ACTIVE
|
TST R2, #1 ; OS_FLG_BGD_ACTIVE
|
||||||
BEQ _ExcInMSP ; if exc occured in Init then branch
|
BEQ _ExcInMSP ; if exc occurred in Init then branch
|
||||||
|
|
||||||
|
|
||||||
CMP LR, #0xFFFFFFED ;auto push floating registers
|
CMP LR, #0xFFFFFFED ;auto push floating registers
|
||||||
BNE _NoFloatInPsp
|
BNE _NoFloatInPsp
|
||||||
|
|
||||||
; exc occured in Task
|
; exc occurred in Task
|
||||||
MOV R2, R13
|
MOV R2, R13
|
||||||
SUB R13, #96 ; add 8 Bytes reg(for STMFD)
|
SUB R13, #96 ; add 8 Bytes reg(for STMFD)
|
||||||
|
|
||||||
|
|||||||
@@ -39,15 +39,16 @@
|
|||||||
#include "los_sched.h"
|
#include "los_sched.h"
|
||||||
#include "los_memory.h"
|
#include "los_memory.h"
|
||||||
#include "los_membox.h"
|
#include "los_membox.h"
|
||||||
|
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
|
||||||
|
#include "los_cpup.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
/*lint -save -e40 -e522 -e533*/
|
|
||||||
UINT32 g_intCount = 0;
|
UINT32 g_intCount = 0;
|
||||||
|
|
||||||
/*lint -restore*/
|
|
||||||
#ifdef __ICCARM__
|
#ifdef __ICCARM__
|
||||||
#pragma location = ".data.vector"
|
#pragma location = ".data.vector"
|
||||||
#elif defined(__CC_ARM) || defined(__GNUC__)
|
#elif defined(__CC_ARM) || defined(__GNUC__)
|
||||||
#pragma data_alignment=LOSCFG_ARCH_HWI_VECTOR_ALIGN
|
#pragma data_alignment = LOSCFG_ARCH_HWI_VECTOR_ALIGN
|
||||||
LITE_OS_SEC_VEC
|
LITE_OS_SEC_VEC
|
||||||
#endif
|
#endif
|
||||||
/* *
|
/* *
|
||||||
@@ -56,6 +57,30 @@ LITE_OS_SEC_VEC
|
|||||||
*/
|
*/
|
||||||
STATIC HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT] = {0};
|
STATIC HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT] = {0};
|
||||||
|
|
||||||
|
#if (LOSCFG_DEBUG_TOOLS == 1)
|
||||||
|
STATIC UINT32 g_hwiFormCnt[OS_HWI_MAX_NUM] = {0};
|
||||||
|
STATIC CHAR *g_hwiFormName[OS_HWI_MAX_NUM] = {0};
|
||||||
|
|
||||||
|
UINT32 OsGetHwiFormCnt(UINT32 index)
|
||||||
|
{
|
||||||
|
return g_hwiFormCnt[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
CHAR *OsGetHwiFormName(UINT32 index)
|
||||||
|
{
|
||||||
|
return g_hwiFormName[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL OsGetHwiCreated(UINT32 index)
|
||||||
|
{
|
||||||
|
if (g_hwiForm[index] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
|
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -108,17 +133,85 @@ WEAK VOID SysTick_Handler(VOID)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ****************************************************************************
|
/* ****************************************************************************
|
||||||
Function : HalIntNumGet
|
Function : HwiNumGet
|
||||||
Description : Get an interrupt number
|
Description : Get an interrupt number
|
||||||
Input : None
|
Input : None
|
||||||
Output : None
|
Output : None
|
||||||
Return : Interrupt Indexes number
|
Return : Interrupt Indexes number
|
||||||
**************************************************************************** */
|
**************************************************************************** */
|
||||||
LITE_OS_SEC_TEXT_MINOR UINT32 HalIntNumGet(VOID)
|
STATIC UINT32 HwiNumGet(VOID)
|
||||||
{
|
{
|
||||||
return __get_IPSR();
|
return __get_IPSR();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
|
||||||
|
{
|
||||||
|
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||||
|
return OS_ERRNO_HWI_NUM_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
|
||||||
|
{
|
||||||
|
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||||
|
return OS_ERRNO_HWI_NUM_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
NVIC_DisableIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority)
|
||||||
|
{
|
||||||
|
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||||
|
return OS_ERRNO_HWI_NUM_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (priority > OS_HWI_PRIO_LOWEST) {
|
||||||
|
return OS_ERRNO_HWI_PRIO_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
NVIC_SetPriority((IRQn_Type)hwiNum, priority);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
|
||||||
|
{
|
||||||
|
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||||
|
return OS_ERRNO_HWI_NUM_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
|
||||||
|
{
|
||||||
|
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||||
|
return OS_ERRNO_HWI_NUM_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
HwiControllerOps g_archHwiOps = {
|
||||||
|
.enableIrq = HwiUnmask,
|
||||||
|
.disableIrq = HwiMask,
|
||||||
|
.setIrqPriority = HwiSetPriority,
|
||||||
|
.getCurIrqNum = HwiNumGet,
|
||||||
|
.triggerIrq = HwiPending,
|
||||||
|
.clearIrq = HwiClear,
|
||||||
|
};
|
||||||
|
|
||||||
inline UINT32 ArchIsIntActive(VOID)
|
inline UINT32 ArchIsIntActive(VOID)
|
||||||
{
|
{
|
||||||
return (g_intCount > 0);
|
return (g_intCount > 0);
|
||||||
@@ -130,21 +223,21 @@ inline UINT32 ArchIsIntActive(VOID)
|
|||||||
Output : None
|
Output : None
|
||||||
Return : None
|
Return : None
|
||||||
**************************************************************************** */
|
**************************************************************************** */
|
||||||
/*lint -e529*/
|
|
||||||
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
|
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
|
||||||
{
|
{
|
||||||
UINT32 irqNum = HalIntNumGet();
|
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet());
|
||||||
PRINT_ERR("%s irqnum:%d\n", __FUNCTION__, irqNum);
|
|
||||||
while (1) {}
|
while (1) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
WEAK VOID HalPreInterruptHandler(UINT32 arg)
|
WEAK VOID HalPreInterruptHandler(UINT32 arg)
|
||||||
{
|
{
|
||||||
|
(VOID)arg;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
WEAK VOID HalAftInterruptHandler(UINT32 arg)
|
WEAK VOID HalAftInterruptHandler(UINT32 arg)
|
||||||
{
|
{
|
||||||
|
(VOID)arg;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,9 +261,12 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
|
|||||||
g_intCount++;
|
g_intCount++;
|
||||||
LOS_IntRestore(intSave);
|
LOS_IntRestore(intSave);
|
||||||
|
|
||||||
hwiIndex = HalIntNumGet();
|
hwiIndex = HwiNumGet();
|
||||||
|
|
||||||
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
|
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
|
||||||
|
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
|
||||||
|
OsCpupIrqStart(hwiIndex);
|
||||||
|
#endif
|
||||||
|
|
||||||
HalPreInterruptHandler(hwiIndex);
|
HalPreInterruptHandler(hwiIndex);
|
||||||
|
|
||||||
@@ -184,8 +280,16 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if (LOSCFG_DEBUG_TOOLS == 1)
|
||||||
|
++g_hwiFormCnt[hwiIndex];
|
||||||
|
#endif
|
||||||
|
|
||||||
HalAftInterruptHandler(hwiIndex);
|
HalAftInterruptHandler(hwiIndex);
|
||||||
|
|
||||||
|
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
|
||||||
|
OsCpupIrqEnd(hwiIndex);
|
||||||
|
#endif
|
||||||
|
|
||||||
OsHookCall(LOS_HOOK_TYPE_ISR_EXIT, hwiIndex);
|
OsHookCall(LOS_HOOK_TYPE_ISR_EXIT, hwiIndex);
|
||||||
|
|
||||||
intSave = LOS_IntLock();
|
intSave = LOS_IntLock();
|
||||||
@@ -198,21 +302,22 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
|
|||||||
Description : create hardware interrupt
|
Description : create hardware interrupt
|
||||||
Input : hwiNum --- hwi num to create
|
Input : hwiNum --- hwi num to create
|
||||||
hwiPrio --- priority of the hwi
|
hwiPrio --- priority of the hwi
|
||||||
mode --- unused
|
hwiMode --- unused
|
||||||
handler --- hwi handler
|
hwiHandler --- hwi handler
|
||||||
arg --- param of the hwi handler
|
irqParam --- param of the hwi handler
|
||||||
Output : None
|
Output : None
|
||||||
Return : LOS_OK on success or error code on failure
|
Return : LOS_OK on success or error code on failure
|
||||||
**************************************************************************** */
|
**************************************************************************** */
|
||||||
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
||||||
HWI_PRIOR_T hwiPrio,
|
HWI_PRIOR_T hwiPrio,
|
||||||
HWI_MODE_T mode,
|
HWI_MODE_T hwiMode,
|
||||||
HWI_PROC_FUNC handler,
|
HWI_PROC_FUNC hwiHandler,
|
||||||
HWI_ARG_T arg)
|
HwiIrqParam *irqParam)
|
||||||
{
|
{
|
||||||
|
(VOID)hwiMode;
|
||||||
UINT32 intSave;
|
UINT32 intSave;
|
||||||
|
|
||||||
if (handler == NULL) {
|
if (hwiHandler == NULL) {
|
||||||
return OS_ERRNO_HWI_PROC_FUNC_NULL;
|
return OS_ERRNO_HWI_PROC_FUNC_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -230,12 +335,25 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
|||||||
|
|
||||||
intSave = LOS_IntLock();
|
intSave = LOS_IntLock();
|
||||||
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
|
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
|
||||||
OsSetVector(hwiNum, handler, arg);
|
if (irqParam != NULL) {
|
||||||
|
OsSetVector(hwiNum, hwiHandler, irqParam->pDevId);
|
||||||
|
} else {
|
||||||
|
OsSetVector(hwiNum, hwiHandler, NULL);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
OsSetVector(hwiNum, handler);
|
(VOID)irqParam;
|
||||||
|
OsSetVector(hwiNum, hwiHandler);
|
||||||
#endif
|
#endif
|
||||||
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
|
||||||
NVIC_SetPriority((IRQn_Type)hwiNum, hwiPrio);
|
#if (LOSCFG_DEBUG_TOOLS == 1)
|
||||||
|
if ((irqParam != NULL) && (irqParam->pName != NULL)) {
|
||||||
|
g_hwiFormName[hwiNum + OS_SYS_VECTOR_CNT] = (CHAR *)irqParam->pName;
|
||||||
|
}
|
||||||
|
g_hwiFormCnt[hwiNum + OS_SYS_VECTOR_CNT] = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
HwiUnmask((IRQn_Type)hwiNum);
|
||||||
|
HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
|
||||||
|
|
||||||
LOS_IntRestore(intSave);
|
LOS_IntRestore(intSave);
|
||||||
|
|
||||||
@@ -246,18 +364,20 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
|||||||
Function : ArchHwiDelete
|
Function : ArchHwiDelete
|
||||||
Description : Delete hardware interrupt
|
Description : Delete hardware interrupt
|
||||||
Input : hwiNum --- hwi num to delete
|
Input : hwiNum --- hwi num to delete
|
||||||
|
irqParam --- param of the hwi handler
|
||||||
Output : None
|
Output : None
|
||||||
Return : LOS_OK on success or error code on failure
|
Return : LOS_OK on success or error code on failure
|
||||||
**************************************************************************** */
|
**************************************************************************** */
|
||||||
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum)
|
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam)
|
||||||
{
|
{
|
||||||
|
(VOID)irqParam;
|
||||||
UINT32 intSave;
|
UINT32 intSave;
|
||||||
|
|
||||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
return OS_ERRNO_HWI_NUM_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
NVIC_DisableIRQ((IRQn_Type)hwiNum);
|
HwiMask((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
intSave = LOS_IntLock();
|
intSave = LOS_IntLock();
|
||||||
|
|
||||||
@@ -378,6 +498,7 @@ STATIC VOID OsExcRegInfo(const ExcInfo *excInfo)
|
|||||||
PRINTK("xPSR = 0x%x\n", excInfo->context->uwxPSR);
|
PRINTK("xPSR = 0x%x\n", excInfo->context->uwxPSR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if (LOSCFG_KERNEL_BACKTRACE == 1)
|
||||||
STATIC VOID OsExcBackTraceInfo(const ExcInfo *excInfo)
|
STATIC VOID OsExcBackTraceInfo(const ExcInfo *excInfo)
|
||||||
{
|
{
|
||||||
UINTPTR LR[LOSCFG_BACKTRACE_DEPTH] = {0};
|
UINTPTR LR[LOSCFG_BACKTRACE_DEPTH] = {0};
|
||||||
@@ -394,6 +515,7 @@ STATIC VOID OsExcBackTraceInfo(const ExcInfo *excInfo)
|
|||||||
}
|
}
|
||||||
PRINTK("----- backtrace end -----\n");
|
PRINTK("----- backtrace end -----\n");
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
STATIC VOID OsExcMemPoolCheckInfo(VOID)
|
STATIC VOID OsExcMemPoolCheckInfo(VOID)
|
||||||
{
|
{
|
||||||
@@ -443,7 +565,9 @@ STATIC VOID OsExcInfoDisplay(const ExcInfo *excInfo)
|
|||||||
OsExcTypeInfo(excInfo);
|
OsExcTypeInfo(excInfo);
|
||||||
OsExcCurTaskInfo(excInfo);
|
OsExcCurTaskInfo(excInfo);
|
||||||
OsExcRegInfo(excInfo);
|
OsExcRegInfo(excInfo);
|
||||||
|
#if (LOSCFG_KERNEL_BACKTRACE == 1)
|
||||||
OsExcBackTraceInfo(excInfo);
|
OsExcBackTraceInfo(excInfo);
|
||||||
|
#endif
|
||||||
OsGetAllTskInfo();
|
OsGetAllTskInfo();
|
||||||
OsExcNvicDump();
|
OsExcNvicDump();
|
||||||
OsExcMemPoolCheckInfo();
|
OsExcMemPoolCheckInfo();
|
||||||
@@ -498,19 +622,19 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
|
|||||||
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
|
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
|
||||||
UINT32 index;
|
UINT32 index;
|
||||||
g_hwiForm[0] = 0; /* [0] Top of Stack */
|
g_hwiForm[0] = 0; /* [0] Top of Stack */
|
||||||
g_hwiForm[1] = Reset_Handler; /* [1] reset */
|
g_hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */
|
||||||
for (index = 2; index < OS_VECTOR_CNT; index++) { /* 2: The starting position of the interrupt */
|
for (index = 2; index < OS_VECTOR_CNT; index++) { /* 2: The starting position of the interrupt */
|
||||||
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
|
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
|
||||||
}
|
}
|
||||||
/* Exception handler register */
|
/* Exception handler register */
|
||||||
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = HalExcNMI;
|
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
|
||||||
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = HalExcHardFault;
|
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
|
||||||
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = HalExcMemFault;
|
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
|
||||||
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcBusFault;
|
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
|
||||||
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcUsageFault;
|
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
|
||||||
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = HalExcSvcCall;
|
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcSvcCall;
|
||||||
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = HalPendSV;
|
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
|
||||||
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = SysTick_Handler;
|
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
|
||||||
|
|
||||||
/* Interrupt vector table location */
|
/* Interrupt vector table location */
|
||||||
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;
|
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;
|
||||||
@@ -521,7 +645,7 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
|
|||||||
|
|
||||||
/* Enable USGFAULT, BUSFAULT, MEMFAULT */
|
/* Enable USGFAULT, BUSFAULT, MEMFAULT */
|
||||||
*(volatile UINT32 *)OS_NVIC_SHCSR |= (USGFAULT | BUSFAULT | MEMFAULT);
|
*(volatile UINT32 *)OS_NVIC_SHCSR |= (USGFAULT | BUSFAULT | MEMFAULT);
|
||||||
|
|
||||||
/* Enable DIV 0 and unaligned exception */
|
/* Enable DIV 0 and unaligned exception */
|
||||||
#ifdef LOSCFG_ARCH_UNALIGNED_EXC
|
#ifdef LOSCFG_ARCH_UNALIGNED_EXC
|
||||||
*(volatile UINT32 *)OS_NVIC_CCR |= (DIV0FAULT | UNALIGNFAULT);
|
*(volatile UINT32 *)OS_NVIC_CCR |= (DIV0FAULT | UNALIGNFAULT);
|
||||||
|
|||||||
@@ -37,7 +37,7 @@
|
|||||||
#include "los_debug.h"
|
#include "los_debug.h"
|
||||||
|
|
||||||
STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler);
|
STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler);
|
||||||
STATIC VOID SysTickReload(UINT64 nextResponseTime);
|
STATIC UINT64 SysTickReload(UINT64 nextResponseTime);
|
||||||
STATIC UINT64 SysTickCycleGet(UINT32 *period);
|
STATIC UINT64 SysTickCycleGet(UINT32 *period);
|
||||||
STATIC VOID SysTickLock(VOID);
|
STATIC VOID SysTickLock(VOID);
|
||||||
STATIC VOID SysTickUnlock(VOID);
|
STATIC VOID SysTickUnlock(VOID);
|
||||||
@@ -45,6 +45,7 @@ STATIC VOID SysTickUnlock(VOID);
|
|||||||
STATIC ArchTickTimer g_archTickTimer = {
|
STATIC ArchTickTimer g_archTickTimer = {
|
||||||
.freq = 0,
|
.freq = 0,
|
||||||
.irqNum = SysTick_IRQn,
|
.irqNum = SysTick_IRQn,
|
||||||
|
.periodMax = LOSCFG_BASE_CORE_TICK_RESPONSE_MAX,
|
||||||
.init = SysTickStart,
|
.init = SysTickStart,
|
||||||
.getCycle = SysTickCycleGet,
|
.getCycle = SysTickCycleGet,
|
||||||
.reload = SysTickReload,
|
.reload = SysTickReload,
|
||||||
@@ -76,13 +77,19 @@ STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler)
|
|||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC VOID SysTickReload(UINT64 nextResponseTime)
|
STATIC UINT64 SysTickReload(UINT64 nextResponseTime)
|
||||||
{
|
{
|
||||||
|
if (nextResponseTime > g_archTickTimer.periodMax) {
|
||||||
|
nextResponseTime = g_archTickTimer.periodMax;
|
||||||
|
}
|
||||||
|
|
||||||
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
|
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
|
||||||
SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */
|
SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */
|
||||||
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
|
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
|
||||||
NVIC_ClearPendingIRQ(SysTick_IRQn);
|
NVIC_ClearPendingIRQ(SysTick_IRQn);
|
||||||
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
|
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
|
||||||
|
|
||||||
|
return nextResponseTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC UINT64 SysTickCycleGet(UINT32 *period)
|
STATIC UINT64 SysTickCycleGet(UINT32 *period)
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ kernel_module(module_name) {
|
|||||||
"los_interrupt.c",
|
"los_interrupt.c",
|
||||||
"los_timer.c",
|
"los_timer.c",
|
||||||
]
|
]
|
||||||
|
configs += [ "$LITEOSTOPDIR:warn_config" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
config("public") {
|
config("public") {
|
||||||
|
|||||||
Executable → Regular
+24
-31
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
* Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
* are permitted provided that the following conditions are met:
|
* are permitted provided that the following conditions are met:
|
||||||
@@ -33,6 +33,7 @@
|
|||||||
#define _LOS_ARCH_ATOMIC_H
|
#define _LOS_ARCH_ATOMIC_H
|
||||||
|
|
||||||
#include "los_compiler.h"
|
#include "los_compiler.h"
|
||||||
|
#include "los_interrupt.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
@@ -43,15 +44,11 @@ extern "C" {
|
|||||||
STATIC INLINE INT32 ArchAtomicRead(const Atomic *v)
|
STATIC INLINE INT32 ArchAtomicRead(const Atomic *v)
|
||||||
{
|
{
|
||||||
INT32 val;
|
INT32 val;
|
||||||
UINT32 intSave;
|
|
||||||
|
|
||||||
intSave = LOS_IntLock();
|
__asm__ __volatile__("ldrex %0, [%1]\n"
|
||||||
|
|
||||||
__asm__ __volatile__("ldrex %0, [%1]\n"
|
|
||||||
: "=&r"(val)
|
: "=&r"(val)
|
||||||
: "r"(v)
|
: "r"(v)
|
||||||
: "cc");
|
: "cc");
|
||||||
LOS_IntRestore(intSave);
|
|
||||||
|
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
@@ -59,18 +56,14 @@ STATIC INLINE INT32 ArchAtomicRead(const Atomic *v)
|
|||||||
STATIC INLINE VOID ArchAtomicSet(Atomic *v, INT32 setVal)
|
STATIC INLINE VOID ArchAtomicSet(Atomic *v, INT32 setVal)
|
||||||
{
|
{
|
||||||
UINT32 status;
|
UINT32 status;
|
||||||
UINT32 intSave;
|
|
||||||
|
|
||||||
intSave = LOS_IntLock();
|
do {
|
||||||
|
__asm__ __volatile__("ldrex %0, [%1]\n"
|
||||||
__asm__ __volatile__("1:ldrex %0, [%1]\n"
|
"strex %0, %2, [%1]\n"
|
||||||
" strex %0, %2, [%1]\n"
|
: "=&r"(status)
|
||||||
" teq %0, #0\n"
|
: "r"(v), "r"(setVal)
|
||||||
" bne 1b"
|
: "cc");
|
||||||
: "=&r"(status)
|
} while (__builtin_expect(status != 0, 0));
|
||||||
: "r"(v), "r"(setVal)
|
|
||||||
: "cc");
|
|
||||||
LOS_IntRestore(intSave);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC INLINE INT32 ArchAtomicAdd(Atomic *v, INT32 addVal)
|
STATIC INLINE INT32 ArchAtomicAdd(Atomic *v, INT32 addVal)
|
||||||
@@ -79,9 +72,9 @@ STATIC INLINE INT32 ArchAtomicAdd(Atomic *v, INT32 addVal)
|
|||||||
UINT32 status;
|
UINT32 status;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
__asm__ __volatile__("ldrex %1, [%2]\n"
|
__asm__ __volatile__("ldrex %1, [%2]\n"
|
||||||
"add %1, %1, %3\n"
|
"add %1, %1, %3\n"
|
||||||
"strex %0, %1, [%2]"
|
"strex %0, %1, [%2]"
|
||||||
: "=&r"(status), "=&r"(val)
|
: "=&r"(status), "=&r"(val)
|
||||||
: "r"(v), "r"(addVal)
|
: "r"(v), "r"(addVal)
|
||||||
: "cc");
|
: "cc");
|
||||||
@@ -96,9 +89,9 @@ STATIC INLINE INT32 ArchAtomicSub(Atomic *v, INT32 subVal)
|
|||||||
UINT32 status;
|
UINT32 status;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
__asm__ __volatile__("ldrex %1, [%2]\n"
|
__asm__ __volatile__("ldrex %1, [%2]\n"
|
||||||
"sub %1, %1, %3\n"
|
"sub %1, %1, %3\n"
|
||||||
"strex %0, %1, [%2]"
|
"strex %0, %1, [%2]"
|
||||||
: "=&r"(status), "=&r"(val)
|
: "=&r"(status), "=&r"(val)
|
||||||
: "r"(v), "r"(subVal)
|
: "r"(v), "r"(subVal)
|
||||||
: "cc");
|
: "cc");
|
||||||
@@ -151,8 +144,8 @@ STATIC INLINE INT32 ArchAtomicXchg32bits(volatile INT32 *v, INT32 val)
|
|||||||
UINT32 status = 0;
|
UINT32 status = 0;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
__asm__ __volatile__("ldrex %0, [%3]\n"
|
__asm__ __volatile__("ldrex %0, [%3]\n"
|
||||||
"strex %1, %4, [%3]"
|
"strex %1, %4, [%3]"
|
||||||
: "=&r"(prevVal), "=&r"(status), "+m"(*v)
|
: "=&r"(prevVal), "=&r"(status), "+m"(*v)
|
||||||
: "r"(v), "r"(val)
|
: "r"(v), "r"(val)
|
||||||
: "cc");
|
: "cc");
|
||||||
@@ -186,12 +179,12 @@ STATIC INLINE BOOL ArchAtomicCmpXchg32bits(volatile INT32 *v, INT32 val, INT32 o
|
|||||||
UINT32 status = 0;
|
UINT32 status = 0;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
__asm__ __volatile__("1: ldrex %0, %2\n"
|
__asm__ __volatile__("ldrex %0, %2\n"
|
||||||
" mov %1, #0\n"
|
"mov %1, #0\n"
|
||||||
" cmp %0, %3\n"
|
"cmp %0, %3\n"
|
||||||
" bne 2f\n"
|
"bne 1f\n"
|
||||||
" strex %1, %4, %2\n"
|
"strex %1, %4, %2\n"
|
||||||
"2:"
|
"1:"
|
||||||
: "=&r"(prevVal), "=&r"(status), "+Q"(*v)
|
: "=&r"(prevVal), "=&r"(status), "+Q"(*v)
|
||||||
: "r"(oldVal), "r"(val)
|
: "r"(oldVal), "r"(val)
|
||||||
: "cc");
|
: "cc");
|
||||||
|
|||||||
Executable → Regular
Executable → Regular
+6
-22
@@ -109,7 +109,8 @@ extern UINT32 _BootVectors[];
|
|||||||
*
|
*
|
||||||
* Value: 0x02000900
|
* Value: 0x02000900
|
||||||
*
|
*
|
||||||
* Solution: Ensure that the interrupt number is valid. The value range of the interrupt number applicable for a Cortex-A7 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
|
* Solution: Ensure that the interrupt number is valid.
|
||||||
|
* The value range of the interrupt number applicable for a Cortex-M33 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
|
||||||
*/
|
*/
|
||||||
#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
|
#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
|
||||||
|
|
||||||
@@ -159,7 +160,8 @@ extern UINT32 _BootVectors[];
|
|||||||
*
|
*
|
||||||
* Value: 0x02000905
|
* Value: 0x02000905
|
||||||
*
|
*
|
||||||
* Solution: Ensure that the interrupt priority is valid. The value range of the interrupt priority applicable for a Cortex-A7 platform is [0,15].
|
* Solution: Ensure that the interrupt priority is valid.
|
||||||
|
* The value range of the interrupt priority applicable for a Cortex-M33 platform is [0,15].
|
||||||
*/
|
*/
|
||||||
#define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05)
|
#define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05)
|
||||||
|
|
||||||
@@ -169,7 +171,8 @@ extern UINT32 _BootVectors[];
|
|||||||
*
|
*
|
||||||
* Value: 0x02000906
|
* Value: 0x02000906
|
||||||
*
|
*
|
||||||
* Solution: The interrupt creation mode can be only set to OS_HWI_MODE_COMM or OS_HWI_MODE_FAST of which the value can be 0 or 1.
|
* Solution: The interrupt creation mode can be only set to OS_HWI_MODE_COMM or
|
||||||
|
* OS_HWI_MODE_FAST of which the value can be 0 or 1.
|
||||||
*/
|
*/
|
||||||
#define OS_ERRNO_HWI_MODE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x06)
|
#define OS_ERRNO_HWI_MODE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x06)
|
||||||
|
|
||||||
@@ -342,25 +345,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
|
|||||||
*/
|
*/
|
||||||
extern VOID HalInterrupt(VOID);
|
extern VOID HalInterrupt(VOID);
|
||||||
|
|
||||||
/* *
|
|
||||||
* @ingroup los_arch_interrupt
|
|
||||||
* @brief: Get an interrupt number.
|
|
||||||
*
|
|
||||||
* @par Description:
|
|
||||||
* This API is used to get the current interrupt number.
|
|
||||||
*
|
|
||||||
* @attention:
|
|
||||||
* <ul><li>None.</li></ul>
|
|
||||||
*
|
|
||||||
* @param: None.
|
|
||||||
*
|
|
||||||
* @retval: Interrupt Indexes number.
|
|
||||||
* @par Dependency:
|
|
||||||
* <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
|
|
||||||
* @see None.
|
|
||||||
*/
|
|
||||||
extern UINT32 HalIntNumGet(VOID);
|
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_arch_interrupt
|
* @ingroup los_arch_interrupt
|
||||||
* @brief: Default vector handling function.
|
* @brief: Default vector handling function.
|
||||||
|
|||||||
Executable → Regular
+17
-12
@@ -59,7 +59,7 @@ LITE_OS_SEC_TEXT_INIT VOID ArchInit(VOID)
|
|||||||
**************************************************************************** */
|
**************************************************************************** */
|
||||||
LITE_OS_SEC_TEXT_MINOR VOID ArchSysExit(VOID)
|
LITE_OS_SEC_TEXT_MINOR VOID ArchSysExit(VOID)
|
||||||
{
|
{
|
||||||
LOS_IntLock();
|
(VOID)LOS_IntLock();
|
||||||
while (1) {
|
while (1) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -75,17 +75,7 @@ LITE_OS_SEC_TEXT_MINOR VOID ArchSysExit(VOID)
|
|||||||
**************************************************************************** */
|
**************************************************************************** */
|
||||||
LITE_OS_SEC_TEXT_INIT VOID *ArchTskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack)
|
LITE_OS_SEC_TEXT_INIT VOID *ArchTskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack)
|
||||||
{
|
{
|
||||||
TaskContext *context = NULL;
|
TaskContext *context = (TaskContext *)((UINTPTR)topStack + stackSize - sizeof(TaskContext));
|
||||||
errno_t result;
|
|
||||||
|
|
||||||
/* initialize the task stack, write magic num to stack top */
|
|
||||||
result = memset_s(topStack, stackSize, (INT32)(OS_TASK_STACK_INIT & 0xFF), stackSize);
|
|
||||||
if (result != EOK) {
|
|
||||||
printf("memset_s is failed:%s[%d]\r\n", __FUNCTION__, __LINE__);
|
|
||||||
}
|
|
||||||
*((UINT32 *)(topStack)) = OS_TASK_MAGIC_WORD;
|
|
||||||
|
|
||||||
context = (TaskContext *)(((UINTPTR)topStack + stackSize) - sizeof(TaskContext));
|
|
||||||
|
|
||||||
#if ((defined(__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
|
#if ((defined(__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
|
||||||
(defined(__FPU_USED) && (__FPU_USED == 1U)))
|
(defined(__FPU_USED) && (__FPU_USED == 1U)))
|
||||||
@@ -146,6 +136,21 @@ LITE_OS_SEC_TEXT_INIT VOID *ArchTskStackInit(UINT32 taskID, UINT32 stackSize, VO
|
|||||||
return (VOID *)context;
|
return (VOID *)context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if (LOSCFG_KERNEL_SIGNAL == 1)
|
||||||
|
VOID *ArchSignalContextInit(VOID *stackPointer, VOID *stackTop, UINTPTR sigHandler, UINT32 param)
|
||||||
|
{
|
||||||
|
UNUSED(stackTop);
|
||||||
|
TaskContext *context = (TaskContext *)((UINTPTR)stackPointer - sizeof(TaskContext));
|
||||||
|
(VOID)memset_s((VOID *)context, sizeof(TaskContext), 0, sizeof(TaskContext));
|
||||||
|
|
||||||
|
context->uwR0 = param;
|
||||||
|
context->uwPC = sigHandler;
|
||||||
|
context->uwxPSR = 0x01000000L; /* Thumb flag, always set 1 */
|
||||||
|
|
||||||
|
return (VOID *)context;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
LITE_OS_SEC_TEXT_INIT UINT32 ArchStartSchedule(VOID)
|
LITE_OS_SEC_TEXT_INIT UINT32 ArchStartSchedule(VOID)
|
||||||
{
|
{
|
||||||
(VOID)LOS_IntLock();
|
(VOID)LOS_IntLock();
|
||||||
|
|||||||
Executable → Regular
+15
-9
@@ -47,6 +47,15 @@
|
|||||||
.section .text
|
.section .text
|
||||||
.thumb
|
.thumb
|
||||||
|
|
||||||
|
.macro SIGNAL_CONTEXT_RESTORE
|
||||||
|
push {r12, lr}
|
||||||
|
blx OsSignalTaskContextRestore
|
||||||
|
pop {r12, lr}
|
||||||
|
cmp r0, #0
|
||||||
|
mov r1, r0
|
||||||
|
bne SignalContextRestore
|
||||||
|
.endm
|
||||||
|
|
||||||
.type HalStartToRun, %function
|
.type HalStartToRun, %function
|
||||||
.global HalStartToRun
|
.global HalStartToRun
|
||||||
HalStartToRun:
|
HalStartToRun:
|
||||||
@@ -90,10 +99,8 @@ __DisabledFPU:
|
|||||||
MOV lr, r5
|
MOV lr, r5
|
||||||
cpsie I
|
cpsie I
|
||||||
BX r6
|
BX r6
|
||||||
|
|
||||||
.fnend
|
.fnend
|
||||||
|
|
||||||
|
|
||||||
.type ArchIntLock, %function
|
.type ArchIntLock, %function
|
||||||
.global ArchIntLock
|
.global ArchIntLock
|
||||||
ArchIntLock:
|
ArchIntLock:
|
||||||
@@ -140,9 +147,6 @@ ArchTaskSchedule:
|
|||||||
bx lr
|
bx lr
|
||||||
.fnend
|
.fnend
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.type HalPendSV, %function
|
.type HalPendSV, %function
|
||||||
.global HalPendSV
|
.global HalPendSV
|
||||||
HalPendSV:
|
HalPendSV:
|
||||||
@@ -153,6 +157,8 @@ HalPendSV:
|
|||||||
cpsid I
|
cpsid I
|
||||||
|
|
||||||
HalTaskSwitch:
|
HalTaskSwitch:
|
||||||
|
SIGNAL_CONTEXT_RESTORE
|
||||||
|
|
||||||
push {r12, lr}
|
push {r12, lr}
|
||||||
blx OsSchedTaskSwitch
|
blx OsSchedTaskSwitch
|
||||||
pop {r12, lr}
|
pop {r12, lr}
|
||||||
@@ -182,9 +188,11 @@ __DisabledFPU1:
|
|||||||
|
|
||||||
ldr r0, [r5, #4]
|
ldr r0, [r5, #4]
|
||||||
str r0, [r5]
|
str r0, [r5]
|
||||||
|
|
||||||
ldr r1, [r0]
|
ldr r1, [r0]
|
||||||
|
|
||||||
|
SignalContextRestore:
|
||||||
|
ldr.w r3, =OS_FPU_CPACR
|
||||||
|
ldr r3, [r3]
|
||||||
and r3, r3, #OS_FPU_CPACR_ENABLE
|
and r3, r3, #OS_FPU_CPACR_ENABLE
|
||||||
cmp r3, #OS_FPU_CPACR_ENABLE
|
cmp r3, #OS_FPU_CPACR_ENABLE
|
||||||
bne __DisabledFPU2
|
bne __DisabledFPU2
|
||||||
@@ -193,9 +201,7 @@ __DisabledFPU1:
|
|||||||
__DisabledFPU2:
|
__DisabledFPU2:
|
||||||
ldmfd r1!, {r4-r12}
|
ldmfd r1!, {r4-r12}
|
||||||
msr psp, r1
|
msr psp, r1
|
||||||
|
|
||||||
msr PRIMASK, r12
|
msr PRIMASK, r12
|
||||||
|
|
||||||
|
|
||||||
bx lr
|
bx lr
|
||||||
|
|
||||||
.fnend
|
.fnend
|
||||||
|
|||||||
Executable → Regular
+4
-4
@@ -263,7 +263,7 @@ _hwiActiveCheck:
|
|||||||
CMP R3, #0
|
CMP R3, #0
|
||||||
BEQ _hwiActiveCheckNext
|
BEQ _hwiActiveCheckNext
|
||||||
|
|
||||||
// exc occured in IRQ
|
// exc occurred in IRQ
|
||||||
ORR R0, R0, #FLAG_HWI_ACTIVE
|
ORR R0, R0, #FLAG_HWI_ACTIVE
|
||||||
RBIT R2, R3
|
RBIT R2, R3
|
||||||
CLZ R2, R2
|
CLZ R2, R2
|
||||||
@@ -316,19 +316,19 @@ _hwiActiveCheckNext:
|
|||||||
AND R2, R2,R3
|
AND R2, R2,R3
|
||||||
CMP R2,#0
|
CMP R2,#0
|
||||||
BNE _ExcInMSP
|
BNE _ExcInMSP
|
||||||
// exc occured in Task or Init or exc
|
// exc occurred in Task or Init or exc
|
||||||
// reserved for register info from task stack
|
// reserved for register info from task stack
|
||||||
|
|
||||||
LDR R2, =g_taskScheduled
|
LDR R2, =g_taskScheduled
|
||||||
LDR R2, [R2]
|
LDR R2, [R2]
|
||||||
TST R2, #1 // OS_FLG_BGD_ACTIVE
|
TST R2, #1 // OS_FLG_BGD_ACTIVE
|
||||||
BEQ _ExcInMSP // if exc occured in Init then branch
|
BEQ _ExcInMSP // if exc occurred in Init then branch
|
||||||
|
|
||||||
|
|
||||||
CMP LR, #0xFFFFFFED //auto push floating registers
|
CMP LR, #0xFFFFFFED //auto push floating registers
|
||||||
BNE _NoFloatInPsp
|
BNE _NoFloatInPsp
|
||||||
|
|
||||||
// exc occured in Task
|
// exc occurred in Task
|
||||||
MOV R2, R13
|
MOV R2, R13
|
||||||
SUB R13, #96 // add 8 Bytes reg(for STMFD)
|
SUB R13, #96 // add 8 Bytes reg(for STMFD)
|
||||||
|
|
||||||
|
|||||||
Executable → Regular
+156
-31
@@ -39,11 +39,13 @@
|
|||||||
#include "los_sched.h"
|
#include "los_sched.h"
|
||||||
#include "los_memory.h"
|
#include "los_memory.h"
|
||||||
#include "los_membox.h"
|
#include "los_membox.h"
|
||||||
|
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
|
||||||
|
#include "los_cpup.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
/*lint -save -e40 -e522 -e533*/
|
#define DEF_HANDLER_START_INDEX 2
|
||||||
UINT32 g_intCount = 0;
|
UINT32 g_intCount = 0;
|
||||||
|
|
||||||
/*lint -restore*/
|
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_hwi
|
||||||
@@ -51,6 +53,30 @@ UINT32 g_intCount = 0;
|
|||||||
*/
|
*/
|
||||||
STATIC HWI_PROC_FUNC __attribute__((aligned(LOSCFG_ARCH_HWI_VECTOR_ALIGN))) g_hwiForm[OS_VECTOR_CNT] = {0};
|
STATIC HWI_PROC_FUNC __attribute__((aligned(LOSCFG_ARCH_HWI_VECTOR_ALIGN))) g_hwiForm[OS_VECTOR_CNT] = {0};
|
||||||
|
|
||||||
|
#if (LOSCFG_DEBUG_TOOLS == 1)
|
||||||
|
STATIC UINT32 g_hwiFormCnt[OS_HWI_MAX_NUM] = {0};
|
||||||
|
STATIC CHAR *g_hwiFormName[OS_HWI_MAX_NUM] = {0};
|
||||||
|
|
||||||
|
UINT32 OsGetHwiFormCnt(UINT32 index)
|
||||||
|
{
|
||||||
|
return g_hwiFormCnt[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
CHAR *OsGetHwiFormName(UINT32 index)
|
||||||
|
{
|
||||||
|
return g_hwiFormName[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL OsGetHwiCreated(UINT32 index)
|
||||||
|
{
|
||||||
|
if (g_hwiForm[index] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
|
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -98,17 +124,85 @@ VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* ****************************************************************************
|
/* ****************************************************************************
|
||||||
Function : HalIntNumGet
|
Function : HwiNumGet
|
||||||
Description : Get an interrupt number
|
Description : Get an interrupt number
|
||||||
Input : None
|
Input : None
|
||||||
Output : None
|
Output : None
|
||||||
Return : Interrupt Indexes number
|
Return : Interrupt Indexes number
|
||||||
**************************************************************************** */
|
**************************************************************************** */
|
||||||
LITE_OS_SEC_TEXT_MINOR UINT32 HalIntNumGet(VOID)
|
STATIC UINT32 HwiNumGet(VOID)
|
||||||
{
|
{
|
||||||
return __get_IPSR();
|
return __get_IPSR();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
|
||||||
|
{
|
||||||
|
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||||
|
return OS_ERRNO_HWI_NUM_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
|
||||||
|
{
|
||||||
|
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||||
|
return OS_ERRNO_HWI_NUM_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
NVIC_DisableIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority)
|
||||||
|
{
|
||||||
|
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||||
|
return OS_ERRNO_HWI_NUM_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (priority > OS_HWI_PRIO_LOWEST) {
|
||||||
|
return OS_ERRNO_HWI_PRIO_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
NVIC_SetPriority((IRQn_Type)hwiNum, priority);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
|
||||||
|
{
|
||||||
|
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||||
|
return OS_ERRNO_HWI_NUM_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
|
||||||
|
{
|
||||||
|
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||||
|
return OS_ERRNO_HWI_NUM_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
HwiControllerOps g_archHwiOps = {
|
||||||
|
.enableIrq = HwiUnmask,
|
||||||
|
.disableIrq = HwiMask,
|
||||||
|
.setIrqPriority = HwiSetPriority,
|
||||||
|
.getCurIrqNum = HwiNumGet,
|
||||||
|
.triggerIrq = HwiPending,
|
||||||
|
.clearIrq = HwiClear,
|
||||||
|
};
|
||||||
|
|
||||||
inline UINT32 ArchIsIntActive(VOID)
|
inline UINT32 ArchIsIntActive(VOID)
|
||||||
{
|
{
|
||||||
return (g_intCount > 0);
|
return (g_intCount > 0);
|
||||||
@@ -120,21 +214,21 @@ inline UINT32 ArchIsIntActive(VOID)
|
|||||||
Output : None
|
Output : None
|
||||||
Return : None
|
Return : None
|
||||||
**************************************************************************** */
|
**************************************************************************** */
|
||||||
/*lint -e529*/
|
|
||||||
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
|
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
|
||||||
{
|
{
|
||||||
UINT32 irqNum = HalIntNumGet();
|
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet());
|
||||||
PRINT_ERR("%s irqnum:%d\n", __FUNCTION__, irqNum);
|
|
||||||
while (1) {}
|
while (1) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
WEAK VOID HalPreInterruptHandler(UINT32 arg)
|
WEAK VOID HalPreInterruptHandler(UINT32 arg)
|
||||||
{
|
{
|
||||||
|
(VOID)arg;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
WEAK VOID HalAftInterruptHandler(UINT32 arg)
|
WEAK VOID HalAftInterruptHandler(UINT32 arg)
|
||||||
{
|
{
|
||||||
|
(VOID)arg;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,9 +252,12 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
|
|||||||
g_intCount++;
|
g_intCount++;
|
||||||
LOS_IntRestore(intSave);
|
LOS_IntRestore(intSave);
|
||||||
|
|
||||||
hwiIndex = HalIntNumGet();
|
hwiIndex = HwiNumGet();
|
||||||
|
|
||||||
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
|
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
|
||||||
|
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
|
||||||
|
OsCpupIrqStart(hwiIndex);
|
||||||
|
#endif
|
||||||
|
|
||||||
HalPreInterruptHandler(hwiIndex);
|
HalPreInterruptHandler(hwiIndex);
|
||||||
|
|
||||||
@@ -174,8 +271,16 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if (LOSCFG_DEBUG_TOOLS == 1)
|
||||||
|
++g_hwiFormCnt[hwiIndex];
|
||||||
|
#endif
|
||||||
|
|
||||||
HalAftInterruptHandler(hwiIndex);
|
HalAftInterruptHandler(hwiIndex);
|
||||||
|
|
||||||
|
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
|
||||||
|
OsCpupIrqEnd(hwiIndex);
|
||||||
|
#endif
|
||||||
|
|
||||||
OsHookCall(LOS_HOOK_TYPE_ISR_EXIT, hwiIndex);
|
OsHookCall(LOS_HOOK_TYPE_ISR_EXIT, hwiIndex);
|
||||||
|
|
||||||
intSave = LOS_IntLock();
|
intSave = LOS_IntLock();
|
||||||
@@ -188,21 +293,22 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
|
|||||||
Description : create hardware interrupt
|
Description : create hardware interrupt
|
||||||
Input : hwiNum --- hwi num to create
|
Input : hwiNum --- hwi num to create
|
||||||
hwiPrio --- priority of the hwi
|
hwiPrio --- priority of the hwi
|
||||||
mode --- unused
|
hwiMode --- unused
|
||||||
handler --- hwi handler
|
hwiHandler --- hwi handler
|
||||||
arg --- param of the hwi handler
|
irqParam --- param of the hwi handler
|
||||||
Output : None
|
Output : None
|
||||||
Return : LOS_OK on success or error code on failure
|
Return : LOS_OK on success or error code on failure
|
||||||
**************************************************************************** */
|
**************************************************************************** */
|
||||||
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
||||||
HWI_PRIOR_T hwiPrio,
|
HWI_PRIOR_T hwiPrio,
|
||||||
HWI_MODE_T mode,
|
HWI_MODE_T hwiMode,
|
||||||
HWI_PROC_FUNC handler,
|
HWI_PROC_FUNC hwiHandler,
|
||||||
HWI_ARG_T arg)
|
HwiIrqParam *irqParam)
|
||||||
{
|
{
|
||||||
|
(VOID)hwiMode;
|
||||||
UINT32 intSave;
|
UINT32 intSave;
|
||||||
|
|
||||||
if (handler == NULL) {
|
if (hwiHandler == NULL) {
|
||||||
return OS_ERRNO_HWI_PROC_FUNC_NULL;
|
return OS_ERRNO_HWI_PROC_FUNC_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -220,12 +326,25 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
|||||||
|
|
||||||
intSave = LOS_IntLock();
|
intSave = LOS_IntLock();
|
||||||
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
|
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
|
||||||
OsSetVector(hwiNum, handler, arg);
|
if (irqParam != NULL) {
|
||||||
|
OsSetVector(hwiNum, hwiHandler, irqParam->pDevId);
|
||||||
|
} else {
|
||||||
|
OsSetVector(hwiNum, hwiHandler, NULL);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
OsSetVector(hwiNum, handler);
|
(VOID)irqParam;
|
||||||
|
OsSetVector(hwiNum, hwiHandler);
|
||||||
#endif
|
#endif
|
||||||
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
|
||||||
NVIC_SetPriority((IRQn_Type)hwiNum, hwiPrio);
|
#if (LOSCFG_DEBUG_TOOLS == 1)
|
||||||
|
if ((irqParam != NULL) && (irqParam->pName != NULL)) {
|
||||||
|
g_hwiFormName[hwiNum + OS_SYS_VECTOR_CNT] = (CHAR *)irqParam->pName;
|
||||||
|
}
|
||||||
|
g_hwiFormCnt[hwiNum + OS_SYS_VECTOR_CNT] = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
HwiUnmask((IRQn_Type)hwiNum);
|
||||||
|
HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
|
||||||
|
|
||||||
LOS_IntRestore(intSave);
|
LOS_IntRestore(intSave);
|
||||||
|
|
||||||
@@ -236,18 +355,20 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
|||||||
Function : ArchHwiDelete
|
Function : ArchHwiDelete
|
||||||
Description : Delete hardware interrupt
|
Description : Delete hardware interrupt
|
||||||
Input : hwiNum --- hwi num to delete
|
Input : hwiNum --- hwi num to delete
|
||||||
|
irqParam --- param of the hwi handler
|
||||||
Output : None
|
Output : None
|
||||||
Return : LOS_OK on success or error code on failure
|
Return : LOS_OK on success or error code on failure
|
||||||
**************************************************************************** */
|
**************************************************************************** */
|
||||||
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum)
|
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam)
|
||||||
{
|
{
|
||||||
|
(VOID)irqParam;
|
||||||
UINT32 intSave;
|
UINT32 intSave;
|
||||||
|
|
||||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
return OS_ERRNO_HWI_NUM_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
NVIC_DisableIRQ((IRQn_Type)hwiNum);
|
HwiMask((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
intSave = LOS_IntLock();
|
intSave = LOS_IntLock();
|
||||||
|
|
||||||
@@ -368,6 +489,7 @@ STATIC VOID OsExcRegInfo(const ExcInfo *excInfo)
|
|||||||
PRINTK("xPSR = 0x%x\n", excInfo->context->uwxPSR);
|
PRINTK("xPSR = 0x%x\n", excInfo->context->uwxPSR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if (LOSCFG_KERNEL_BACKTRACE == 1)
|
||||||
STATIC VOID OsExcBackTraceInfo(const ExcInfo *excInfo)
|
STATIC VOID OsExcBackTraceInfo(const ExcInfo *excInfo)
|
||||||
{
|
{
|
||||||
UINTPTR LR[LOSCFG_BACKTRACE_DEPTH] = {0};
|
UINTPTR LR[LOSCFG_BACKTRACE_DEPTH] = {0};
|
||||||
@@ -384,6 +506,7 @@ STATIC VOID OsExcBackTraceInfo(const ExcInfo *excInfo)
|
|||||||
}
|
}
|
||||||
PRINTK("----- backtrace end -----\n");
|
PRINTK("----- backtrace end -----\n");
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
STATIC VOID OsExcMemPoolCheckInfo(VOID)
|
STATIC VOID OsExcMemPoolCheckInfo(VOID)
|
||||||
{
|
{
|
||||||
@@ -433,7 +556,9 @@ STATIC VOID OsExcInfoDisplay(const ExcInfo *excInfo)
|
|||||||
OsExcTypeInfo(excInfo);
|
OsExcTypeInfo(excInfo);
|
||||||
OsExcCurTaskInfo(excInfo);
|
OsExcCurTaskInfo(excInfo);
|
||||||
OsExcRegInfo(excInfo);
|
OsExcRegInfo(excInfo);
|
||||||
|
#if (LOSCFG_KERNEL_BACKTRACE == 1)
|
||||||
OsExcBackTraceInfo(excInfo);
|
OsExcBackTraceInfo(excInfo);
|
||||||
|
#endif
|
||||||
OsGetAllTskInfo();
|
OsGetAllTskInfo();
|
||||||
OsExcNvicDump();
|
OsExcNvicDump();
|
||||||
OsExcMemPoolCheckInfo();
|
OsExcMemPoolCheckInfo();
|
||||||
@@ -489,18 +614,18 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
|
|||||||
UINT32 index;
|
UINT32 index;
|
||||||
g_hwiForm[0] = 0; /* [0] Top of Stack */
|
g_hwiForm[0] = 0; /* [0] Top of Stack */
|
||||||
g_hwiForm[1] = 0; /* [1] reset */
|
g_hwiForm[1] = 0; /* [1] reset */
|
||||||
for (index = 2; index < OS_VECTOR_CNT; index++) {
|
for (index = DEF_HANDLER_START_INDEX; index < OS_VECTOR_CNT; index++) {
|
||||||
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
|
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
|
||||||
}
|
}
|
||||||
/* Exception handler register */
|
/* Exception handler register */
|
||||||
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = HalExcNMI;
|
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
|
||||||
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = HalExcHardFault;
|
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
|
||||||
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = HalExcMemFault;
|
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
|
||||||
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcBusFault;
|
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
|
||||||
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcUsageFault;
|
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
|
||||||
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = HalSVCHandler;
|
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
|
||||||
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = HalPendSV;
|
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
|
||||||
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = OsTickHandler;
|
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)OsTickHandler;
|
||||||
|
|
||||||
/* Interrupt vector table location */
|
/* Interrupt vector table location */
|
||||||
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;
|
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;
|
||||||
@@ -511,7 +636,7 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
|
|||||||
|
|
||||||
/* Enable USGFAULT, BUSFAULT, MEMFAULT */
|
/* Enable USGFAULT, BUSFAULT, MEMFAULT */
|
||||||
*(volatile UINT32 *)OS_NVIC_SHCSR |= (USGFAULT | BUSFAULT | MEMFAULT);
|
*(volatile UINT32 *)OS_NVIC_SHCSR |= (USGFAULT | BUSFAULT | MEMFAULT);
|
||||||
|
|
||||||
/* Enable DIV 0 and unaligned exception */
|
/* Enable DIV 0 and unaligned exception */
|
||||||
#ifdef LOSCFG_ARCH_UNALIGNED_EXC
|
#ifdef LOSCFG_ARCH_UNALIGNED_EXC
|
||||||
*(volatile UINT32 *)OS_NVIC_CCR |= (DIV0FAULT | UNALIGNFAULT);
|
*(volatile UINT32 *)OS_NVIC_CCR |= (DIV0FAULT | UNALIGNFAULT);
|
||||||
|
|||||||
Executable → Regular
+8
-2
@@ -36,7 +36,7 @@
|
|||||||
#include "los_debug.h"
|
#include "los_debug.h"
|
||||||
|
|
||||||
STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler);
|
STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler);
|
||||||
STATIC VOID SysTickReload(UINT64 nextResponseTime);
|
STATIC UINT64 SysTickReload(UINT64 nextResponseTime);
|
||||||
STATIC UINT64 SysTickCycleGet(UINT32 *period);
|
STATIC UINT64 SysTickCycleGet(UINT32 *period);
|
||||||
STATIC VOID SysTickLock(VOID);
|
STATIC VOID SysTickLock(VOID);
|
||||||
STATIC VOID SysTickUnlock(VOID);
|
STATIC VOID SysTickUnlock(VOID);
|
||||||
@@ -44,6 +44,7 @@ STATIC VOID SysTickUnlock(VOID);
|
|||||||
STATIC ArchTickTimer g_archTickTimer = {
|
STATIC ArchTickTimer g_archTickTimer = {
|
||||||
.freq = 0,
|
.freq = 0,
|
||||||
.irqNum = SysTick_IRQn,
|
.irqNum = SysTick_IRQn,
|
||||||
|
.periodMax = LOSCFG_BASE_CORE_TICK_RESPONSE_MAX,
|
||||||
.init = SysTickStart,
|
.init = SysTickStart,
|
||||||
.getCycle = SysTickCycleGet,
|
.getCycle = SysTickCycleGet,
|
||||||
.reload = SysTickReload,
|
.reload = SysTickReload,
|
||||||
@@ -75,13 +76,18 @@ STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler)
|
|||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC VOID SysTickReload(UINT64 nextResponseTime)
|
STATIC UINT64 SysTickReload(UINT64 nextResponseTime)
|
||||||
{
|
{
|
||||||
|
if (nextResponseTime > g_archTickTimer.periodMax) {
|
||||||
|
nextResponseTime = g_archTickTimer.periodMax;
|
||||||
|
}
|
||||||
|
|
||||||
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
|
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
|
||||||
SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */
|
SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */
|
||||||
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
|
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
|
||||||
NVIC_ClearPendingIRQ(SysTick_IRQn);
|
NVIC_ClearPendingIRQ(SysTick_IRQn);
|
||||||
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
|
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
|
||||||
|
return nextResponseTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC UINT64 SysTickCycleGet(UINT32 *period)
|
STATIC UINT64 SysTickCycleGet(UINT32 *period)
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ kernel_module(module_name) {
|
|||||||
"non_secure/los_timer.c",
|
"non_secure/los_timer.c",
|
||||||
"non_secure/los_trustzone.c",
|
"non_secure/los_trustzone.c",
|
||||||
]
|
]
|
||||||
|
configs += [ "$LITEOSTOPDIR:warn_config" ]
|
||||||
|
|
||||||
include_dirs = [
|
include_dirs = [
|
||||||
"non_secure",
|
"non_secure",
|
||||||
|
|||||||
Executable → Regular
+24
-31
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
* Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
* are permitted provided that the following conditions are met:
|
* are permitted provided that the following conditions are met:
|
||||||
@@ -33,6 +33,7 @@
|
|||||||
#define _LOS_ARCH_ATOMIC_H
|
#define _LOS_ARCH_ATOMIC_H
|
||||||
|
|
||||||
#include "los_compiler.h"
|
#include "los_compiler.h"
|
||||||
|
#include "los_interrupt.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
@@ -43,15 +44,11 @@ extern "C" {
|
|||||||
STATIC INLINE INT32 ArchAtomicRead(const Atomic *v)
|
STATIC INLINE INT32 ArchAtomicRead(const Atomic *v)
|
||||||
{
|
{
|
||||||
INT32 val;
|
INT32 val;
|
||||||
UINT32 intSave;
|
|
||||||
|
|
||||||
intSave = LOS_IntLock();
|
__asm__ __volatile__("ldrex %0, [%1]\n"
|
||||||
|
|
||||||
__asm__ __volatile__("ldrex %0, [%1]\n"
|
|
||||||
: "=&r"(val)
|
: "=&r"(val)
|
||||||
: "r"(v)
|
: "r"(v)
|
||||||
: "cc");
|
: "cc");
|
||||||
LOS_IntRestore(intSave);
|
|
||||||
|
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
@@ -59,18 +56,14 @@ STATIC INLINE INT32 ArchAtomicRead(const Atomic *v)
|
|||||||
STATIC INLINE VOID ArchAtomicSet(Atomic *v, INT32 setVal)
|
STATIC INLINE VOID ArchAtomicSet(Atomic *v, INT32 setVal)
|
||||||
{
|
{
|
||||||
UINT32 status;
|
UINT32 status;
|
||||||
UINT32 intSave;
|
|
||||||
|
|
||||||
intSave = LOS_IntLock();
|
do {
|
||||||
|
__asm__ __volatile__("ldrex %0, [%1]\n"
|
||||||
__asm__ __volatile__("1:ldrex %0, [%1]\n"
|
"strex %0, %2, [%1]\n"
|
||||||
" strex %0, %2, [%1]\n"
|
: "=&r"(status)
|
||||||
" teq %0, #0\n"
|
: "r"(v), "r"(setVal)
|
||||||
" bne 1b"
|
: "cc");
|
||||||
: "=&r"(status)
|
} while (__builtin_expect(status != 0, 0));
|
||||||
: "r"(v), "r"(setVal)
|
|
||||||
: "cc");
|
|
||||||
LOS_IntRestore(intSave);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC INLINE INT32 ArchAtomicAdd(Atomic *v, INT32 addVal)
|
STATIC INLINE INT32 ArchAtomicAdd(Atomic *v, INT32 addVal)
|
||||||
@@ -79,9 +72,9 @@ STATIC INLINE INT32 ArchAtomicAdd(Atomic *v, INT32 addVal)
|
|||||||
UINT32 status;
|
UINT32 status;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
__asm__ __volatile__("ldrex %1, [%2]\n"
|
__asm__ __volatile__("ldrex %1, [%2]\n"
|
||||||
"add %1, %1, %3\n"
|
"add %1, %1, %3\n"
|
||||||
"strex %0, %1, [%2]"
|
"strex %0, %1, [%2]"
|
||||||
: "=&r"(status), "=&r"(val)
|
: "=&r"(status), "=&r"(val)
|
||||||
: "r"(v), "r"(addVal)
|
: "r"(v), "r"(addVal)
|
||||||
: "cc");
|
: "cc");
|
||||||
@@ -96,9 +89,9 @@ STATIC INLINE INT32 ArchAtomicSub(Atomic *v, INT32 subVal)
|
|||||||
UINT32 status;
|
UINT32 status;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
__asm__ __volatile__("ldrex %1, [%2]\n"
|
__asm__ __volatile__("ldrex %1, [%2]\n"
|
||||||
"sub %1, %1, %3\n"
|
"sub %1, %1, %3\n"
|
||||||
"strex %0, %1, [%2]"
|
"strex %0, %1, [%2]"
|
||||||
: "=&r"(status), "=&r"(val)
|
: "=&r"(status), "=&r"(val)
|
||||||
: "r"(v), "r"(subVal)
|
: "r"(v), "r"(subVal)
|
||||||
: "cc");
|
: "cc");
|
||||||
@@ -151,8 +144,8 @@ STATIC INLINE INT32 ArchAtomicXchg32bits(volatile INT32 *v, INT32 val)
|
|||||||
UINT32 status = 0;
|
UINT32 status = 0;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
__asm__ __volatile__("ldrex %0, [%3]\n"
|
__asm__ __volatile__("ldrex %0, [%3]\n"
|
||||||
"strex %1, %4, [%3]"
|
"strex %1, %4, [%3]"
|
||||||
: "=&r"(prevVal), "=&r"(status), "+m"(*v)
|
: "=&r"(prevVal), "=&r"(status), "+m"(*v)
|
||||||
: "r"(v), "r"(val)
|
: "r"(v), "r"(val)
|
||||||
: "cc");
|
: "cc");
|
||||||
@@ -186,12 +179,12 @@ STATIC INLINE BOOL ArchAtomicCmpXchg32bits(volatile INT32 *v, INT32 val, INT32 o
|
|||||||
UINT32 status = 0;
|
UINT32 status = 0;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
__asm__ __volatile__("1: ldrex %0, %2\n"
|
__asm__ __volatile__("ldrex %0, %2\n"
|
||||||
" mov %1, #0\n"
|
"mov %1, #0\n"
|
||||||
" cmp %0, %3\n"
|
"cmp %0, %3\n"
|
||||||
" bne 2f\n"
|
"bne 1f\n"
|
||||||
" strex %1, %4, %2\n"
|
"strex %1, %4, %2\n"
|
||||||
"2:"
|
"1:"
|
||||||
: "=&r"(prevVal), "=&r"(status), "+Q"(*v)
|
: "=&r"(prevVal), "=&r"(status), "+Q"(*v)
|
||||||
: "r"(oldVal), "r"(val)
|
: "r"(oldVal), "r"(val)
|
||||||
: "cc");
|
: "cc");
|
||||||
|
|||||||
Executable → Regular
Executable → Regular
+6
-22
@@ -109,7 +109,8 @@ extern UINT32 _BootVectors[];
|
|||||||
*
|
*
|
||||||
* Value: 0x02000900
|
* Value: 0x02000900
|
||||||
*
|
*
|
||||||
* Solution: Ensure that the interrupt number is valid. The value range of the interrupt number applicable for a Cortex-A7 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
|
* Solution: Ensure that the interrupt number is valid.
|
||||||
|
* The value range of the interrupt number applicable for a Cortex-M33 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
|
||||||
*/
|
*/
|
||||||
#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
|
#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
|
||||||
|
|
||||||
@@ -159,7 +160,8 @@ extern UINT32 _BootVectors[];
|
|||||||
*
|
*
|
||||||
* Value: 0x02000905
|
* Value: 0x02000905
|
||||||
*
|
*
|
||||||
* Solution: Ensure that the interrupt priority is valid. The value range of the interrupt priority applicable for a Cortex-A7 platform is [0,15].
|
* Solution: Ensure that the interrupt priority is valid.
|
||||||
|
* The value range of the interrupt priority applicable for a Cortex-M33 platform is [0,15].
|
||||||
*/
|
*/
|
||||||
#define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05)
|
#define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05)
|
||||||
|
|
||||||
@@ -169,7 +171,8 @@ extern UINT32 _BootVectors[];
|
|||||||
*
|
*
|
||||||
* Value: 0x02000906
|
* Value: 0x02000906
|
||||||
*
|
*
|
||||||
* Solution: The interrupt creation mode can be only set to OS_HWI_MODE_COMM or OS_HWI_MODE_FAST of which the value can be 0 or 1.
|
* Solution: The interrupt creation mode can be only set to OS_HWI_MODE_COMM or
|
||||||
|
* OS_HWI_MODE_FAST of which the value can be 0 or 1.
|
||||||
*/
|
*/
|
||||||
#define OS_ERRNO_HWI_MODE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x06)
|
#define OS_ERRNO_HWI_MODE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x06)
|
||||||
|
|
||||||
@@ -342,25 +345,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
|
|||||||
*/
|
*/
|
||||||
extern VOID HalInterrupt(VOID);
|
extern VOID HalInterrupt(VOID);
|
||||||
|
|
||||||
/* *
|
|
||||||
* @ingroup los_arch_interrupt
|
|
||||||
* @brief: Get an interrupt number.
|
|
||||||
*
|
|
||||||
* @par Description:
|
|
||||||
* This API is used to get the current interrupt number.
|
|
||||||
*
|
|
||||||
* @attention:
|
|
||||||
* <ul><li>None.</li></ul>
|
|
||||||
*
|
|
||||||
* @param: None.
|
|
||||||
*
|
|
||||||
* @retval: Interrupt Indexes number.
|
|
||||||
* @par Dependency:
|
|
||||||
* <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
|
|
||||||
* @see None.
|
|
||||||
*/
|
|
||||||
extern UINT32 HalIntNumGet(VOID);
|
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_arch_interrupt
|
* @ingroup los_arch_interrupt
|
||||||
* @brief: Default vector handling function.
|
* @brief: Default vector handling function.
|
||||||
|
|||||||
Executable → Regular
+16
-12
@@ -59,7 +59,7 @@ LITE_OS_SEC_TEXT_INIT VOID ArchInit(VOID)
|
|||||||
**************************************************************************** */
|
**************************************************************************** */
|
||||||
LITE_OS_SEC_TEXT_MINOR VOID ArchSysExit(VOID)
|
LITE_OS_SEC_TEXT_MINOR VOID ArchSysExit(VOID)
|
||||||
{
|
{
|
||||||
LOS_IntLock();
|
(VOID)LOS_IntLock();
|
||||||
while (1) {
|
while (1) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -75,17 +75,7 @@ LITE_OS_SEC_TEXT_MINOR VOID ArchSysExit(VOID)
|
|||||||
**************************************************************************** */
|
**************************************************************************** */
|
||||||
LITE_OS_SEC_TEXT_INIT VOID *ArchTskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack)
|
LITE_OS_SEC_TEXT_INIT VOID *ArchTskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack)
|
||||||
{
|
{
|
||||||
TaskContext *context = NULL;
|
TaskContext *context = (TaskContext *)((UINTPTR)topStack + stackSize - sizeof(TaskContext));
|
||||||
errno_t result;
|
|
||||||
|
|
||||||
/* initialize the task stack, write magic num to stack top */
|
|
||||||
result = memset_s(topStack, stackSize, (INT32)(OS_TASK_STACK_INIT & 0xFF), stackSize);
|
|
||||||
if (result != EOK) {
|
|
||||||
printf("memset_s is failed:%s[%d]\r\n", __FUNCTION__, __LINE__);
|
|
||||||
}
|
|
||||||
*((UINT32 *)(topStack)) = OS_TASK_MAGIC_WORD;
|
|
||||||
|
|
||||||
context = (TaskContext *)(((UINTPTR)topStack + stackSize) - sizeof(TaskContext));
|
|
||||||
|
|
||||||
#if ((defined(__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
|
#if ((defined(__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
|
||||||
(defined(__FPU_USED) && (__FPU_USED == 1U)))
|
(defined(__FPU_USED) && (__FPU_USED == 1U)))
|
||||||
@@ -150,6 +140,20 @@ LITE_OS_SEC_TEXT_INIT VOID *ArchTskStackInit(UINT32 taskID, UINT32 stackSize, VO
|
|||||||
return (VOID *)context;
|
return (VOID *)context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VOID *ArchSignalContextInit(VOID *stackPointer, VOID *stackTop, UINTPTR sigHandler, UINT32 param)
|
||||||
|
{
|
||||||
|
TaskContext *context = (TaskContext *)((UINTPTR)stackPointer - sizeof(TaskContext));
|
||||||
|
(VOID)memset_s((VOID *)context, sizeof(TaskContext), 0, sizeof(TaskContext));
|
||||||
|
|
||||||
|
context->uwR0 = param;
|
||||||
|
context->uwPC = sigHandler;
|
||||||
|
context->stackLimit = (UINT32)stackTop;
|
||||||
|
context->excReturn = 0xFFFFFFBC;
|
||||||
|
context->uwxPSR = 0x01000000L; /* Thumb flag, always set 1 */
|
||||||
|
|
||||||
|
return (VOID *)context;
|
||||||
|
}
|
||||||
|
|
||||||
LITE_OS_SEC_TEXT_INIT UINT32 ArchStartSchedule(VOID)
|
LITE_OS_SEC_TEXT_INIT UINT32 ArchStartSchedule(VOID)
|
||||||
{
|
{
|
||||||
(VOID)LOS_IntLock();
|
(VOID)LOS_IntLock();
|
||||||
|
|||||||
@@ -45,6 +45,15 @@
|
|||||||
.section .text
|
.section .text
|
||||||
.thumb
|
.thumb
|
||||||
|
|
||||||
|
.macro SIGNAL_CONTEXT_RESTORE
|
||||||
|
PUSH {R12, LR}
|
||||||
|
BLX OsSignalTaskContextRestore
|
||||||
|
POP {R12, LR}
|
||||||
|
CMP R0, #0
|
||||||
|
MOV R1, R0
|
||||||
|
BNE SignalContextRestore
|
||||||
|
.endm
|
||||||
|
|
||||||
.type HalStartFirstTask, %function
|
.type HalStartFirstTask, %function
|
||||||
.global HalStartFirstTask
|
.global HalStartFirstTask
|
||||||
HalStartFirstTask:
|
HalStartFirstTask:
|
||||||
@@ -132,6 +141,8 @@ HalPendSV:
|
|||||||
cpsid I
|
cpsid I
|
||||||
|
|
||||||
HalTaskSwitch:
|
HalTaskSwitch:
|
||||||
|
SIGNAL_CONTEXT_RESTORE
|
||||||
|
|
||||||
push {r12, lr}
|
push {r12, lr}
|
||||||
blx OsSchedTaskSwitch
|
blx OsSchedTaskSwitch
|
||||||
pop {r12, lr}
|
pop {r12, lr}
|
||||||
@@ -175,8 +186,9 @@ __DisabledFPU2:
|
|||||||
|
|
||||||
LDR R0, [R5, #4]
|
LDR R0, [R5, #4]
|
||||||
STR R0, [R5]
|
STR R0, [R5]
|
||||||
|
|
||||||
LDR R1, [R0]
|
LDR R1, [R0]
|
||||||
|
|
||||||
|
SignalContextRestore:
|
||||||
LDMIA R1!, {R0, R2-R3} /* Restore secureContext, PSPLIM and LR from the current task stack. */
|
LDMIA R1!, {R0, R2-R3} /* Restore secureContext, PSPLIM and LR from the current task stack. */
|
||||||
MSR PSPLIM, R2
|
MSR PSPLIM, R2
|
||||||
MOV LR, R3
|
MOV LR, R3
|
||||||
@@ -205,7 +217,7 @@ __DisabledFPU3:
|
|||||||
.fnend
|
.fnend
|
||||||
|
|
||||||
.type HalSVCStartSchedule, %function
|
.type HalSVCStartSchedule, %function
|
||||||
.global HalSVCStartSchedule
|
.global HalSVCStartSchedule
|
||||||
HalSVCStartSchedule:
|
HalSVCStartSchedule:
|
||||||
.fnstart
|
.fnstart
|
||||||
.cantunwind
|
.cantunwind
|
||||||
@@ -219,7 +231,7 @@ HalSVCStartSchedule:
|
|||||||
.fnend
|
.fnend
|
||||||
|
|
||||||
.type HalSVCSecureContextAlloc, %function
|
.type HalSVCSecureContextAlloc, %function
|
||||||
.global HalSVCSecureContextAlloc
|
.global HalSVCSecureContextAlloc
|
||||||
HalSVCSecureContextAlloc:
|
HalSVCSecureContextAlloc:
|
||||||
.fnstart
|
.fnstart
|
||||||
.cantunwind
|
.cantunwind
|
||||||
@@ -228,7 +240,7 @@ HalSVCSecureContextAlloc:
|
|||||||
.fnend
|
.fnend
|
||||||
|
|
||||||
.type HalSVCSecureContextFree, %function
|
.type HalSVCSecureContextFree, %function
|
||||||
.global HalSVCSecureContextFree
|
.global HalSVCSecureContextFree
|
||||||
HalSVCSecureContextFree:
|
HalSVCSecureContextFree:
|
||||||
.fnstart
|
.fnstart
|
||||||
.cantunwind
|
.cantunwind
|
||||||
@@ -237,7 +249,7 @@ HalSVCSecureContextFree:
|
|||||||
.fnend
|
.fnend
|
||||||
|
|
||||||
.type HalSVCHandler, %function
|
.type HalSVCHandler, %function
|
||||||
.global HalSVCHandler
|
.global HalSVCHandler
|
||||||
HalSVCHandler:
|
HalSVCHandler:
|
||||||
.fnstart
|
.fnstart
|
||||||
.cantunwind
|
.cantunwind
|
||||||
|
|||||||
Executable → Regular
+4
-4
@@ -247,7 +247,7 @@ _hwiActiveCheck:
|
|||||||
CMP R3, #0
|
CMP R3, #0
|
||||||
BEQ _hwiActiveCheckNext
|
BEQ _hwiActiveCheckNext
|
||||||
|
|
||||||
// exc occured in IRQ
|
// exc occurred in IRQ
|
||||||
ORR R0, R0, #FLAG_HWI_ACTIVE
|
ORR R0, R0, #FLAG_HWI_ACTIVE
|
||||||
RBIT R2, R3
|
RBIT R2, R3
|
||||||
CLZ R2, R2
|
CLZ R2, R2
|
||||||
@@ -300,19 +300,19 @@ _hwiActiveCheckNext:
|
|||||||
AND R2, R2,R3
|
AND R2, R2,R3
|
||||||
CMP R2,#0
|
CMP R2,#0
|
||||||
BNE _ExcInMSP
|
BNE _ExcInMSP
|
||||||
// exc occured in Task or Init or exc
|
// exc occurred in Task or Init or exc
|
||||||
// reserved for register info from task stack
|
// reserved for register info from task stack
|
||||||
|
|
||||||
LDR R2, =g_taskScheduled
|
LDR R2, =g_taskScheduled
|
||||||
LDR R2, [R2]
|
LDR R2, [R2]
|
||||||
TST R2, #1 // OS_FLG_BGD_ACTIVE
|
TST R2, #1 // OS_FLG_BGD_ACTIVE
|
||||||
BEQ _ExcInMSP // if exc occured in Init then branch
|
BEQ _ExcInMSP // if exc occurred in Init then branch
|
||||||
|
|
||||||
|
|
||||||
CMP LR, #0xFFFFFFED //auto push floating registers
|
CMP LR, #0xFFFFFFED //auto push floating registers
|
||||||
BNE _NoFloatInPsp
|
BNE _NoFloatInPsp
|
||||||
|
|
||||||
// exc occured in Task
|
// exc occurred in Task
|
||||||
MOV R2, R13
|
MOV R2, R13
|
||||||
SUB R13, #96 // add 8 Bytes reg(for STMFD)
|
SUB R13, #96 // add 8 Bytes reg(for STMFD)
|
||||||
|
|
||||||
|
|||||||
Executable → Regular
+156
-31
@@ -39,18 +39,43 @@
|
|||||||
#include "los_sched.h"
|
#include "los_sched.h"
|
||||||
#include "los_memory.h"
|
#include "los_memory.h"
|
||||||
#include "los_membox.h"
|
#include "los_membox.h"
|
||||||
|
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
|
||||||
|
#include "los_cpup.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
/*lint -save -e40 -e522 -e533*/
|
#define DEF_HANDLER_START_INDEX 2
|
||||||
UINT32 g_intCount = 0;
|
UINT32 g_intCount = 0;
|
||||||
|
|
||||||
/*lint -restore*/
|
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_hwi
|
||||||
* Hardware interrupt form mapping handling function array.
|
* Hardware interrupt form mapping handling function array.
|
||||||
*/
|
*/
|
||||||
STATIC HWI_PROC_FUNC __attribute__((aligned(LOSCFG_ARCH_HWI_VECTOR_ALIGN))) g_hwiForm[OS_VECTOR_CNT] = {0};
|
STATIC HWI_PROC_FUNC __attribute__((aligned(LOSCFG_ARCH_HWI_VECTOR_ALIGN))) g_hwiForm[OS_VECTOR_CNT] = {0};
|
||||||
|
|
||||||
|
#if (LOSCFG_DEBUG_TOOLS == 1)
|
||||||
|
STATIC UINT32 g_hwiFormCnt[OS_HWI_MAX_NUM] = {0};
|
||||||
|
STATIC CHAR *g_hwiFormName[OS_HWI_MAX_NUM] = {0};
|
||||||
|
|
||||||
|
UINT32 OsGetHwiFormCnt(UINT32 index)
|
||||||
|
{
|
||||||
|
return g_hwiFormCnt[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
CHAR *OsGetHwiFormName(UINT32 index)
|
||||||
|
{
|
||||||
|
return g_hwiFormName[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL OsGetHwiCreated(UINT32 index)
|
||||||
|
{
|
||||||
|
if (g_hwiForm[index] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
|
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -98,17 +123,85 @@ VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* ****************************************************************************
|
/* ****************************************************************************
|
||||||
Function : HalIntNumGet
|
Function : HwiNumGet
|
||||||
Description : Get an interrupt number
|
Description : Get an interrupt number
|
||||||
Input : None
|
Input : None
|
||||||
Output : None
|
Output : None
|
||||||
Return : Interrupt Indexes number
|
Return : Interrupt Indexes number
|
||||||
**************************************************************************** */
|
**************************************************************************** */
|
||||||
LITE_OS_SEC_TEXT_MINOR UINT32 HalIntNumGet(VOID)
|
STATIC UINT32 HwiNumGet(VOID)
|
||||||
{
|
{
|
||||||
return __get_IPSR();
|
return __get_IPSR();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
|
||||||
|
{
|
||||||
|
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||||
|
return OS_ERRNO_HWI_NUM_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
|
||||||
|
{
|
||||||
|
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||||
|
return OS_ERRNO_HWI_NUM_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
NVIC_DisableIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority)
|
||||||
|
{
|
||||||
|
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||||
|
return OS_ERRNO_HWI_NUM_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (priority > OS_HWI_PRIO_LOWEST) {
|
||||||
|
return OS_ERRNO_HWI_PRIO_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
NVIC_SetPriority((IRQn_Type)hwiNum, priority);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
|
||||||
|
{
|
||||||
|
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||||
|
return OS_ERRNO_HWI_NUM_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
|
||||||
|
{
|
||||||
|
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||||
|
return OS_ERRNO_HWI_NUM_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
HwiControllerOps g_archHwiOps = {
|
||||||
|
.enableIrq = HwiUnmask,
|
||||||
|
.disableIrq = HwiMask,
|
||||||
|
.setIrqPriority = HwiSetPriority,
|
||||||
|
.getCurIrqNum = HwiNumGet,
|
||||||
|
.triggerIrq = HwiPending,
|
||||||
|
.clearIrq = HwiClear,
|
||||||
|
};
|
||||||
|
|
||||||
inline UINT32 ArchIsIntActive(VOID)
|
inline UINT32 ArchIsIntActive(VOID)
|
||||||
{
|
{
|
||||||
return (g_intCount > 0);
|
return (g_intCount > 0);
|
||||||
@@ -123,18 +216,19 @@ inline UINT32 ArchIsIntActive(VOID)
|
|||||||
/*lint -e529*/
|
/*lint -e529*/
|
||||||
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
|
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
|
||||||
{
|
{
|
||||||
UINT32 irqNum = HalIntNumGet();
|
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet());
|
||||||
PRINT_ERR("%s irqnum:%d\n", __FUNCTION__, irqNum);
|
|
||||||
while (1) {}
|
while (1) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
WEAK VOID HalPreInterruptHandler(UINT32 arg)
|
WEAK VOID HalPreInterruptHandler(UINT32 arg)
|
||||||
{
|
{
|
||||||
|
(VOID)arg;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
WEAK VOID HalAftInterruptHandler(UINT32 arg)
|
WEAK VOID HalAftInterruptHandler(UINT32 arg)
|
||||||
{
|
{
|
||||||
|
(VOID)arg;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,9 +252,12 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
|
|||||||
g_intCount++;
|
g_intCount++;
|
||||||
LOS_IntRestore(intSave);
|
LOS_IntRestore(intSave);
|
||||||
|
|
||||||
hwiIndex = HalIntNumGet();
|
hwiIndex = HwiNumGet();
|
||||||
|
|
||||||
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
|
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
|
||||||
|
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
|
||||||
|
OsCpupIrqStart(hwiIndex);
|
||||||
|
#endif
|
||||||
|
|
||||||
HalPreInterruptHandler(hwiIndex);
|
HalPreInterruptHandler(hwiIndex);
|
||||||
|
|
||||||
@@ -174,8 +271,16 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if (LOSCFG_DEBUG_TOOLS == 1)
|
||||||
|
++g_hwiFormCnt[hwiIndex];
|
||||||
|
#endif
|
||||||
|
|
||||||
HalAftInterruptHandler(hwiIndex);
|
HalAftInterruptHandler(hwiIndex);
|
||||||
|
|
||||||
|
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
|
||||||
|
OsCpupIrqEnd(hwiIndex);
|
||||||
|
#endif
|
||||||
|
|
||||||
OsHookCall(LOS_HOOK_TYPE_ISR_EXIT, hwiIndex);
|
OsHookCall(LOS_HOOK_TYPE_ISR_EXIT, hwiIndex);
|
||||||
|
|
||||||
intSave = LOS_IntLock();
|
intSave = LOS_IntLock();
|
||||||
@@ -188,21 +293,22 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
|
|||||||
Description : create hardware interrupt
|
Description : create hardware interrupt
|
||||||
Input : hwiNum --- hwi num to create
|
Input : hwiNum --- hwi num to create
|
||||||
hwiPrio --- priority of the hwi
|
hwiPrio --- priority of the hwi
|
||||||
mode --- unused
|
hwiMode --- unused
|
||||||
handler --- hwi handler
|
hwiHandler --- hwi handler
|
||||||
arg --- param of the hwi handler
|
irqParam --- param of the hwi handler
|
||||||
Output : None
|
Output : None
|
||||||
Return : LOS_OK on success or error code on failure
|
Return : LOS_OK on success or error code on failure
|
||||||
**************************************************************************** */
|
**************************************************************************** */
|
||||||
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
||||||
HWI_PRIOR_T hwiPrio,
|
HWI_PRIOR_T hwiPrio,
|
||||||
HWI_MODE_T mode,
|
HWI_MODE_T hwiMode,
|
||||||
HWI_PROC_FUNC handler,
|
HWI_PROC_FUNC hwiHandler,
|
||||||
HWI_ARG_T arg)
|
HwiIrqParam *irqParam)
|
||||||
{
|
{
|
||||||
|
(VOID)hwiMode;
|
||||||
UINT32 intSave;
|
UINT32 intSave;
|
||||||
|
|
||||||
if (handler == NULL) {
|
if (hwiHandler == NULL) {
|
||||||
return OS_ERRNO_HWI_PROC_FUNC_NULL;
|
return OS_ERRNO_HWI_PROC_FUNC_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -220,12 +326,25 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
|||||||
|
|
||||||
intSave = LOS_IntLock();
|
intSave = LOS_IntLock();
|
||||||
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
|
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
|
||||||
OsSetVector(hwiNum, handler, arg);
|
if (irqParam != NULL) {
|
||||||
|
OsSetVector(hwiNum, hwiHandler, irqParam->pDevId);
|
||||||
|
} else {
|
||||||
|
OsSetVector(hwiNum, hwiHandler, NULL);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
OsSetVector(hwiNum, handler);
|
(VOID)irqParam;
|
||||||
|
OsSetVector(hwiNum, hwiHandler);
|
||||||
#endif
|
#endif
|
||||||
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
|
||||||
NVIC_SetPriority((IRQn_Type)hwiNum, hwiPrio);
|
#if (LOSCFG_DEBUG_TOOLS == 1)
|
||||||
|
if ((irqParam != NULL) && (irqParam->pName != NULL)) {
|
||||||
|
g_hwiFormName[hwiNum + OS_SYS_VECTOR_CNT] = (CHAR *)irqParam->pName;
|
||||||
|
}
|
||||||
|
g_hwiFormCnt[hwiNum + OS_SYS_VECTOR_CNT] = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
HwiUnmask((IRQn_Type)hwiNum);
|
||||||
|
HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
|
||||||
|
|
||||||
LOS_IntRestore(intSave);
|
LOS_IntRestore(intSave);
|
||||||
|
|
||||||
@@ -236,11 +355,13 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
|||||||
Function : ArchHwiDelete
|
Function : ArchHwiDelete
|
||||||
Description : Delete hardware interrupt
|
Description : Delete hardware interrupt
|
||||||
Input : hwiNum --- hwi num to delete
|
Input : hwiNum --- hwi num to delete
|
||||||
|
irqParam --- param of the hwi handler
|
||||||
Output : None
|
Output : None
|
||||||
Return : LOS_OK on success or error code on failure
|
Return : LOS_OK on success or error code on failure
|
||||||
**************************************************************************** */
|
**************************************************************************** */
|
||||||
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum)
|
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam)
|
||||||
{
|
{
|
||||||
|
(VOID)irqParam;
|
||||||
UINT32 intSave;
|
UINT32 intSave;
|
||||||
|
|
||||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||||
@@ -368,6 +489,7 @@ STATIC VOID OsExcRegInfo(const ExcInfo *excInfo)
|
|||||||
PRINTK("xPSR = 0x%x\n", excInfo->context->uwxPSR);
|
PRINTK("xPSR = 0x%x\n", excInfo->context->uwxPSR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if (LOSCFG_KERNEL_BACKTRACE == 1)
|
||||||
STATIC VOID OsExcBackTraceInfo(const ExcInfo *excInfo)
|
STATIC VOID OsExcBackTraceInfo(const ExcInfo *excInfo)
|
||||||
{
|
{
|
||||||
UINTPTR LR[LOSCFG_BACKTRACE_DEPTH] = {0};
|
UINTPTR LR[LOSCFG_BACKTRACE_DEPTH] = {0};
|
||||||
@@ -384,6 +506,7 @@ STATIC VOID OsExcBackTraceInfo(const ExcInfo *excInfo)
|
|||||||
}
|
}
|
||||||
PRINTK("----- backtrace end -----\n");
|
PRINTK("----- backtrace end -----\n");
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
STATIC VOID OsExcMemPoolCheckInfo(VOID)
|
STATIC VOID OsExcMemPoolCheckInfo(VOID)
|
||||||
{
|
{
|
||||||
@@ -433,7 +556,9 @@ STATIC VOID OsExcInfoDisplay(const ExcInfo *excInfo)
|
|||||||
OsExcTypeInfo(excInfo);
|
OsExcTypeInfo(excInfo);
|
||||||
OsExcCurTaskInfo(excInfo);
|
OsExcCurTaskInfo(excInfo);
|
||||||
OsExcRegInfo(excInfo);
|
OsExcRegInfo(excInfo);
|
||||||
|
#if (LOSCFG_KERNEL_BACKTRACE == 1)
|
||||||
OsExcBackTraceInfo(excInfo);
|
OsExcBackTraceInfo(excInfo);
|
||||||
|
#endif
|
||||||
OsGetAllTskInfo();
|
OsGetAllTskInfo();
|
||||||
OsExcNvicDump();
|
OsExcNvicDump();
|
||||||
OsExcMemPoolCheckInfo();
|
OsExcMemPoolCheckInfo();
|
||||||
@@ -487,20 +612,20 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
|
|||||||
{
|
{
|
||||||
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
|
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
|
||||||
UINT32 index;
|
UINT32 index;
|
||||||
g_hwiForm[0] = 0; /* [0] Top of Stack */
|
g_hwiForm[0] = 0; /* [0] Top of Stack */
|
||||||
g_hwiForm[1] = 0; /* [1] reset */
|
g_hwiForm[1] = 0; /* [1] reset */
|
||||||
for (index = 2; index < OS_VECTOR_CNT; index++) {
|
for (index = DEF_HANDLER_START_INDEX; index < OS_VECTOR_CNT; index++) {
|
||||||
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
|
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
|
||||||
}
|
}
|
||||||
/* Exception handler register */
|
/* Exception handler register */
|
||||||
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = HalExcNMI;
|
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
|
||||||
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = HalExcHardFault;
|
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
|
||||||
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = HalExcMemFault;
|
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
|
||||||
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcBusFault;
|
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
|
||||||
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcUsageFault;
|
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
|
||||||
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = HalSVCHandler;
|
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
|
||||||
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = HalPendSV;
|
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
|
||||||
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = OsTickHandler;
|
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)OsTickHandler;
|
||||||
|
|
||||||
/* Interrupt vector table location */
|
/* Interrupt vector table location */
|
||||||
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;
|
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;
|
||||||
@@ -511,7 +636,7 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
|
|||||||
|
|
||||||
/* Enable USGFAULT, BUSFAULT, MEMFAULT */
|
/* Enable USGFAULT, BUSFAULT, MEMFAULT */
|
||||||
*(volatile UINT32 *)OS_NVIC_SHCSR |= (USGFAULT | BUSFAULT | MEMFAULT);
|
*(volatile UINT32 *)OS_NVIC_SHCSR |= (USGFAULT | BUSFAULT | MEMFAULT);
|
||||||
|
|
||||||
/* Enable DIV 0 and unaligned exception */
|
/* Enable DIV 0 and unaligned exception */
|
||||||
#ifdef LOSCFG_ARCH_UNALIGNED_EXC
|
#ifdef LOSCFG_ARCH_UNALIGNED_EXC
|
||||||
*(volatile UINT32 *)OS_NVIC_CCR |= (DIV0FAULT | UNALIGNFAULT);
|
*(volatile UINT32 *)OS_NVIC_CCR |= (DIV0FAULT | UNALIGNFAULT);
|
||||||
|
|||||||
Executable → Regular
+9
-3
@@ -35,7 +35,7 @@
|
|||||||
#include "los_arch_interrupt.h"
|
#include "los_arch_interrupt.h"
|
||||||
|
|
||||||
STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler);
|
STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler);
|
||||||
STATIC VOID SysTickReload(UINT64 nextResponseTime);
|
STATIC UINT64 SysTickReload(UINT64 nextResponseTime);
|
||||||
STATIC UINT64 SysTickCycleGet(UINT32 *period);
|
STATIC UINT64 SysTickCycleGet(UINT32 *period);
|
||||||
STATIC VOID SysTickLock(VOID);
|
STATIC VOID SysTickLock(VOID);
|
||||||
STATIC VOID SysTickUnlock(VOID);
|
STATIC VOID SysTickUnlock(VOID);
|
||||||
@@ -43,6 +43,7 @@ STATIC VOID SysTickUnlock(VOID);
|
|||||||
STATIC ArchTickTimer g_archTickTimer = {
|
STATIC ArchTickTimer g_archTickTimer = {
|
||||||
.freq = 0,
|
.freq = 0,
|
||||||
.irqNum = SysTick_IRQn,
|
.irqNum = SysTick_IRQn,
|
||||||
|
.periodMax = LOSCFG_BASE_CORE_TICK_RESPONSE_MAX,
|
||||||
.init = SysTickStart,
|
.init = SysTickStart,
|
||||||
.getCycle = SysTickCycleGet,
|
.getCycle = SysTickCycleGet,
|
||||||
.reload = SysTickReload,
|
.reload = SysTickReload,
|
||||||
@@ -74,18 +75,23 @@ STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler)
|
|||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC VOID SysTickReload(UINT64 nextResponseTime)
|
STATIC UINT64 SysTickReload(UINT64 nextResponseTime)
|
||||||
{
|
{
|
||||||
|
if (nextResponseTime > g_archTickTimer.periodMax) {
|
||||||
|
nextResponseTime = g_archTickTimer.periodMax;
|
||||||
|
}
|
||||||
|
|
||||||
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
|
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
|
||||||
SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */
|
SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */
|
||||||
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
|
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
|
||||||
NVIC_ClearPendingIRQ(SysTick_IRQn);
|
NVIC_ClearPendingIRQ(SysTick_IRQn);
|
||||||
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
|
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
|
||||||
|
return nextResponseTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC UINT64 SysTickCycleGet(UINT32 *period)
|
STATIC UINT64 SysTickCycleGet(UINT32 *period)
|
||||||
{
|
{
|
||||||
UINT32 hwCycle = 0;
|
UINT32 hwCycle = 0;
|
||||||
UINT32 intSave = LOS_IntLock();
|
UINT32 intSave = LOS_IntLock();
|
||||||
UINT32 val = SysTick->VAL;
|
UINT32 val = SysTick->VAL;
|
||||||
*period = SysTick->LOAD;
|
*period = SysTick->LOAD;
|
||||||
|
|||||||
Executable → Regular
+1
@@ -51,6 +51,7 @@ VOID HalSecureSVCHandler(UINT32 svcID, UINTPTR arg)
|
|||||||
HalSecureContextLoad(g_secureContext);
|
HalSecureContextLoad(g_secureContext);
|
||||||
break;
|
break;
|
||||||
case OS_SVC_FREE_SECURE_CONTEXT:
|
case OS_SVC_FREE_SECURE_CONTEXT:
|
||||||
|
LOS_ASSERT(g_secureContext != NULL);
|
||||||
HalSecureContextFree(g_secureContext);
|
HalSecureContextFree(g_secureContext);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|||||||
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
@@ -0,0 +1,37 @@
|
|||||||
|
# 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("//kernel/liteos_m/liteos.gni")
|
||||||
|
|
||||||
|
module_group("iar") {
|
||||||
|
if (defined(LOSCFG_SECURE_TRUSTZONE)) {
|
||||||
|
modules = [ "TZ" ]
|
||||||
|
} else {
|
||||||
|
modules = [ "NTZ" ]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
# 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("//kernel/liteos_m/liteos.gni")
|
||||||
|
|
||||||
|
module_name = "arch"
|
||||||
|
kernel_module(module_name) {
|
||||||
|
sources = [
|
||||||
|
"los_context.c",
|
||||||
|
"los_dispatch.S",
|
||||||
|
"los_exc.S",
|
||||||
|
"los_interrupt.c",
|
||||||
|
"los_timer.c",
|
||||||
|
]
|
||||||
|
configs += [ "$LITEOSTOPDIR:warn_config" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
config("public") {
|
||||||
|
include_dirs = [ "." ]
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
* Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
* are permitted provided that the following conditions are met:
|
* are permitted provided that the following conditions are met:
|
||||||
@@ -33,6 +33,7 @@
|
|||||||
#define _LOS_ARCH_ATOMIC_H
|
#define _LOS_ARCH_ATOMIC_H
|
||||||
|
|
||||||
#include "los_compiler.h"
|
#include "los_compiler.h"
|
||||||
|
#include "los_interrupt.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
@@ -43,15 +44,11 @@ extern "C" {
|
|||||||
STATIC INLINE INT32 ArchAtomicRead(const Atomic *v)
|
STATIC INLINE INT32 ArchAtomicRead(const Atomic *v)
|
||||||
{
|
{
|
||||||
INT32 val;
|
INT32 val;
|
||||||
UINT32 intSave;
|
|
||||||
|
|
||||||
intSave = LOS_IntLock();
|
asm volatile("ldrex %0, [%1]\n"
|
||||||
|
: "=&r"(val)
|
||||||
__asm__ __volatile__("ldrex %0, [%1]\n"
|
: "r"(v)
|
||||||
: "=&r"(val)
|
: "cc");
|
||||||
: "r"(v)
|
|
||||||
: "cc");
|
|
||||||
LOS_IntRestore(intSave);
|
|
||||||
|
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
@@ -59,18 +56,14 @@ STATIC INLINE INT32 ArchAtomicRead(const Atomic *v)
|
|||||||
STATIC INLINE VOID ArchAtomicSet(Atomic *v, INT32 setVal)
|
STATIC INLINE VOID ArchAtomicSet(Atomic *v, INT32 setVal)
|
||||||
{
|
{
|
||||||
UINT32 status;
|
UINT32 status;
|
||||||
UINT32 intSave;
|
|
||||||
|
|
||||||
intSave = LOS_IntLock();
|
do {
|
||||||
|
asm volatile("ldrex %0, [%1]\n"
|
||||||
__asm__ __volatile__("1:ldrex %0, [%1]\n"
|
"strex %0, %2, [%1]\n"
|
||||||
" strex %0, %2, [%1]\n"
|
: "=&r"(status)
|
||||||
" teq %0, #0\n"
|
: "r"(v), "r"(setVal)
|
||||||
" bne 1b"
|
: "cc");
|
||||||
: "=&r"(status)
|
} while (status != 0);
|
||||||
: "r"(v), "r"(setVal)
|
|
||||||
: "cc");
|
|
||||||
LOS_IntRestore(intSave);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC INLINE INT32 ArchAtomicAdd(Atomic *v, INT32 addVal)
|
STATIC INLINE INT32 ArchAtomicAdd(Atomic *v, INT32 addVal)
|
||||||
@@ -79,13 +72,13 @@ STATIC INLINE INT32 ArchAtomicAdd(Atomic *v, INT32 addVal)
|
|||||||
UINT32 status;
|
UINT32 status;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
__asm__ __volatile__("ldrex %1, [%2]\n"
|
asm volatile("ldrex %1, [%2]\n"
|
||||||
"add %1, %1, %3\n"
|
"add %1, %1, %3\n"
|
||||||
"strex %0, %1, [%2]"
|
"strex %0, %1, [%2]"
|
||||||
: "=&r"(status), "=&r"(val)
|
: "=&r"(status), "=&r"(val)
|
||||||
: "r"(v), "r"(addVal)
|
: "r"(v), "r"(addVal)
|
||||||
: "cc");
|
: "cc");
|
||||||
} while (__builtin_expect(status != 0, 0));
|
} while (status != 0);
|
||||||
|
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
@@ -96,13 +89,13 @@ STATIC INLINE INT32 ArchAtomicSub(Atomic *v, INT32 subVal)
|
|||||||
UINT32 status;
|
UINT32 status;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
__asm__ __volatile__("ldrex %1, [%2]\n"
|
asm volatile("ldrex %1, [%2]\n"
|
||||||
"sub %1, %1, %3\n"
|
"sub %1, %1, %3\n"
|
||||||
"strex %0, %1, [%2]"
|
"strex %0, %1, [%2]"
|
||||||
: "=&r"(status), "=&r"(val)
|
: "=&r"(status), "=&r"(val)
|
||||||
: "r"(v), "r"(subVal)
|
: "r"(v), "r"(subVal)
|
||||||
: "cc");
|
: "cc");
|
||||||
} while (__builtin_expect(status != 0, 0));
|
} while (status != 0);
|
||||||
|
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
@@ -151,12 +144,12 @@ STATIC INLINE INT32 ArchAtomicXchg32bits(volatile INT32 *v, INT32 val)
|
|||||||
UINT32 status = 0;
|
UINT32 status = 0;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
__asm__ __volatile__("ldrex %0, [%3]\n"
|
asm volatile("ldrex %0, [%2]\n"
|
||||||
"strex %1, %4, [%3]"
|
"strex %1, %3, [%2]"
|
||||||
: "=&r"(prevVal), "=&r"(status), "+m"(*v)
|
: "=&r"(prevVal), "=&r"(status)
|
||||||
: "r"(v), "r"(val)
|
: "r"(v), "r"(val)
|
||||||
: "cc");
|
: "cc");
|
||||||
} while (__builtin_expect(status != 0, 0));
|
} while (status != 0);
|
||||||
|
|
||||||
return prevVal;
|
return prevVal;
|
||||||
}
|
}
|
||||||
@@ -186,16 +179,16 @@ STATIC INLINE BOOL ArchAtomicCmpXchg32bits(volatile INT32 *v, INT32 val, INT32 o
|
|||||||
UINT32 status = 0;
|
UINT32 status = 0;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
__asm__ __volatile__("1: ldrex %0, %2\n"
|
asm volatile("ldrex %0, [%2]\n"
|
||||||
" mov %1, #0\n"
|
"mov %1, #0\n"
|
||||||
" cmp %0, %3\n"
|
"cmp %0, %3\n"
|
||||||
" bne 2f\n"
|
"bne 1f\n"
|
||||||
" strex %1, %4, %2\n"
|
"strex %1, %4, [%2]\n"
|
||||||
"2:"
|
"1:"
|
||||||
: "=&r"(prevVal), "=&r"(status), "+Q"(*v)
|
: "=&r"(prevVal), "=&r"(status)
|
||||||
: "r"(oldVal), "r"(val)
|
: "r"(v), "r"(oldVal), "r"(val)
|
||||||
: "cc");
|
: "cc");
|
||||||
} while (__builtin_expect(status != 0, 0));
|
} while (status != 0);
|
||||||
|
|
||||||
return prevVal != oldVal;
|
return prevVal != oldVal;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,7 +109,8 @@ extern UINT32 _BootVectors[];
|
|||||||
*
|
*
|
||||||
* Value: 0x02000900
|
* Value: 0x02000900
|
||||||
*
|
*
|
||||||
* Solution: Ensure that the interrupt number is valid. The value range of the interrupt number applicable for a Cortex-A7 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
|
* Solution: Ensure that the interrupt number is valid.
|
||||||
|
* The value range of the interrupt number applicable for a Cortex-M33 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
|
||||||
*/
|
*/
|
||||||
#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
|
#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
|
||||||
|
|
||||||
@@ -159,7 +160,8 @@ extern UINT32 _BootVectors[];
|
|||||||
*
|
*
|
||||||
* Value: 0x02000905
|
* Value: 0x02000905
|
||||||
*
|
*
|
||||||
* Solution: Ensure that the interrupt priority is valid. The value range of the interrupt priority applicable for a Cortex-A7 platform is [0,15].
|
* Solution: Ensure that the interrupt priority is valid.
|
||||||
|
* The value range of the interrupt priority applicable for a Cortex-M33 platform is [0,15].
|
||||||
*/
|
*/
|
||||||
#define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05)
|
#define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05)
|
||||||
|
|
||||||
@@ -169,7 +171,8 @@ extern UINT32 _BootVectors[];
|
|||||||
*
|
*
|
||||||
* Value: 0x02000906
|
* Value: 0x02000906
|
||||||
*
|
*
|
||||||
* Solution: The interrupt creation mode can be only set to OS_HWI_MODE_COMM or OS_HWI_MODE_FAST of which the value can be 0 or 1.
|
* Solution: The interrupt creation mode can be only set to OS_HWI_MODE_COMM or
|
||||||
|
* OS_HWI_MODE_FAST of which the value can be 0 or 1.
|
||||||
*/
|
*/
|
||||||
#define OS_ERRNO_HWI_MODE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x06)
|
#define OS_ERRNO_HWI_MODE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x06)
|
||||||
|
|
||||||
@@ -342,25 +345,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
|
|||||||
*/
|
*/
|
||||||
extern VOID HalInterrupt(VOID);
|
extern VOID HalInterrupt(VOID);
|
||||||
|
|
||||||
/* *
|
|
||||||
* @ingroup los_hwi
|
|
||||||
* @brief: Get an interrupt number.
|
|
||||||
*
|
|
||||||
* @par Description:
|
|
||||||
* This API is used to get the current interrupt number.
|
|
||||||
*
|
|
||||||
* @attention:
|
|
||||||
* <ul><li>None.</li></ul>
|
|
||||||
*
|
|
||||||
* @param: None.
|
|
||||||
*
|
|
||||||
* @retval: Interrupt Indexes number.
|
|
||||||
* @par Dependency:
|
|
||||||
* <ul><li>los_hwi.h: the header file that contains the API declaration.</li></ul>
|
|
||||||
* @see None.
|
|
||||||
*/
|
|
||||||
extern UINT32 HalIntNumGet(VOID);
|
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_hwi
|
||||||
* @brief: Default vector handling function.
|
* @brief: Default vector handling function.
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ LITE_OS_SEC_TEXT_INIT VOID ArchInit(VOID)
|
|||||||
**************************************************************************** */
|
**************************************************************************** */
|
||||||
LITE_OS_SEC_TEXT_MINOR VOID ArchSysExit(VOID)
|
LITE_OS_SEC_TEXT_MINOR VOID ArchSysExit(VOID)
|
||||||
{
|
{
|
||||||
LOS_IntLock();
|
(VOID)LOS_IntLock();
|
||||||
while (1) {
|
while (1) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -75,17 +75,7 @@ LITE_OS_SEC_TEXT_MINOR VOID ArchSysExit(VOID)
|
|||||||
**************************************************************************** */
|
**************************************************************************** */
|
||||||
LITE_OS_SEC_TEXT_INIT VOID *ArchTskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack)
|
LITE_OS_SEC_TEXT_INIT VOID *ArchTskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack)
|
||||||
{
|
{
|
||||||
TaskContext *context = NULL;
|
TaskContext *context = (TaskContext *)((UINTPTR)topStack + stackSize - sizeof(TaskContext));
|
||||||
errno_t result;
|
|
||||||
|
|
||||||
/* initialize the task stack, write magic num to stack top */
|
|
||||||
result = memset_s(topStack, stackSize, (INT32)(OS_TASK_STACK_INIT & 0xFF), stackSize);
|
|
||||||
if (result != EOK) {
|
|
||||||
printf("memset_s is failed:%s[%d]\r\n", __FUNCTION__, __LINE__);
|
|
||||||
}
|
|
||||||
*((UINT32 *)(topStack)) = OS_TASK_MAGIC_WORD;
|
|
||||||
|
|
||||||
context = (TaskContext *)(((UINTPTR)topStack + stackSize) - sizeof(TaskContext));
|
|
||||||
|
|
||||||
#if ((defined(__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
|
#if ((defined(__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
|
||||||
(defined(__FPU_USED) && (__FPU_USED == 1U)))
|
(defined(__FPU_USED) && (__FPU_USED == 1U)))
|
||||||
@@ -146,6 +136,19 @@ LITE_OS_SEC_TEXT_INIT VOID *ArchTskStackInit(UINT32 taskID, UINT32 stackSize, VO
|
|||||||
return (VOID *)context;
|
return (VOID *)context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VOID *ArchSignalContextInit(VOID *stackPointer, VOID *stackTop, UINTPTR sigHandler, UINT32 param)
|
||||||
|
{
|
||||||
|
UNUSED(stackTop);
|
||||||
|
TaskContext *context = (TaskContext *)((UINTPTR)stackPointer - sizeof(TaskContext));
|
||||||
|
(VOID)memset_s((VOID *)context, sizeof(TaskContext), 0, sizeof(TaskContext));
|
||||||
|
|
||||||
|
context->uwR0 = param;
|
||||||
|
context->uwPC = sigHandler;
|
||||||
|
context->uwxPSR = 0x01000000L; /* Thumb flag, always set 1 */
|
||||||
|
|
||||||
|
return (VOID *)context;
|
||||||
|
}
|
||||||
|
|
||||||
LITE_OS_SEC_TEXT_INIT UINT32 ArchStartSchedule(VOID)
|
LITE_OS_SEC_TEXT_INIT UINT32 ArchStartSchedule(VOID)
|
||||||
{
|
{
|
||||||
(VOID)LOS_IntLock();
|
(VOID)LOS_IntLock();
|
||||||
|
|||||||
@@ -38,6 +38,7 @@
|
|||||||
EXPORT ArchTaskSchedule
|
EXPORT ArchTaskSchedule
|
||||||
EXPORT HalPendSV
|
EXPORT HalPendSV
|
||||||
IMPORT OsSchedTaskSwitch
|
IMPORT OsSchedTaskSwitch
|
||||||
|
IMPORT OsSignalTaskContextRestore
|
||||||
IMPORT g_losTask
|
IMPORT g_losTask
|
||||||
|
|
||||||
OS_FPU_CPACR EQU 0xE000ED88
|
OS_FPU_CPACR EQU 0xE000ED88
|
||||||
@@ -52,6 +53,15 @@ OS_TASK_STATUS_RUNNING EQU 0x0010
|
|||||||
THUMB
|
THUMB
|
||||||
REQUIRE8
|
REQUIRE8
|
||||||
|
|
||||||
|
MACRO SIGNAL_CONTEXT_RESTORE
|
||||||
|
PUSH {R12, LR}
|
||||||
|
BLX OsSignalTaskContextRestore
|
||||||
|
POP {R12, LR}
|
||||||
|
CMP R0, #0
|
||||||
|
MOV R1, R0
|
||||||
|
BNE SignalContextRestore
|
||||||
|
ENDM
|
||||||
|
|
||||||
HalStartToRun
|
HalStartToRun
|
||||||
LDR R4, =OS_NVIC_SYSPRI2
|
LDR R4, =OS_NVIC_SYSPRI2
|
||||||
LDR R5, =OS_NVIC_PENDSV_PRI
|
LDR R5, =OS_NVIC_PENDSV_PRI
|
||||||
@@ -145,8 +155,11 @@ __DisabledFPU1
|
|||||||
|
|
||||||
LDR R0, [R5, #4]
|
LDR R0, [R5, #4]
|
||||||
STR R0, [R5]
|
STR R0, [R5]
|
||||||
|
|
||||||
LDR R1, [R0]
|
LDR R1, [R0]
|
||||||
|
|
||||||
|
SignalContextRestore
|
||||||
|
LDR.W R3, =OS_FPU_CPACR
|
||||||
|
LDR R3, [R3]
|
||||||
AND R3, R3, #OS_FPU_CPACR_ENABLE
|
AND R3, R3, #OS_FPU_CPACR_ENABLE
|
||||||
CMP R3, #OS_FPU_CPACR_ENABLE
|
CMP R3, #OS_FPU_CPACR_ENABLE
|
||||||
BNE __DisabledFPU2
|
BNE __DisabledFPU2
|
||||||
|
|||||||
@@ -56,8 +56,8 @@ FLAG_ADDR_VALID EQU 0x10000
|
|||||||
FLAG_HWI_ACTIVE EQU 0x20000
|
FLAG_HWI_ACTIVE EQU 0x20000
|
||||||
FLAG_NO_FLOAT EQU 0x10000000
|
FLAG_NO_FLOAT EQU 0x10000000
|
||||||
|
|
||||||
OS_NVIC_FSR EQU 0xE000ED28 ;include BusFault/MemFault/UsageFault State Regeister
|
OS_NVIC_FSR EQU 0xE000ED28 ;include BusFault/MemFault/UsageFault State Register
|
||||||
OS_NVIC_HFSR EQU 0xE000ED2C ;HardFault State Regeister
|
OS_NVIC_HFSR EQU 0xE000ED2C ;HardFault State Register
|
||||||
OS_NVIC_BFAR EQU 0xE000ED38
|
OS_NVIC_BFAR EQU 0xE000ED38
|
||||||
OS_NVIC_MMAR EQU 0xE000ED34
|
OS_NVIC_MMAR EQU 0xE000ED34
|
||||||
OS_NVIC_ACT_BASE EQU 0xE000E300
|
OS_NVIC_ACT_BASE EQU 0xE000E300
|
||||||
@@ -190,7 +190,7 @@ _hwiActiveCheck
|
|||||||
CMP R3, #0
|
CMP R3, #0
|
||||||
BEQ _hwiActiveCheckNext
|
BEQ _hwiActiveCheckNext
|
||||||
|
|
||||||
; exc occured in IRQ
|
; exc occurred in IRQ
|
||||||
ORR R0, R0, #FLAG_HWI_ACTIVE
|
ORR R0, R0, #FLAG_HWI_ACTIVE
|
||||||
RBIT R2, R3
|
RBIT R2, R3
|
||||||
CLZ R2, R2
|
CLZ R2, R2
|
||||||
@@ -228,19 +228,19 @@ _hwiActiveCheckNext
|
|||||||
AND R2, R2,R3
|
AND R2, R2,R3
|
||||||
CMP R2,#0
|
CMP R2,#0
|
||||||
BNE _ExcInMSP
|
BNE _ExcInMSP
|
||||||
; exc occured in Task or Init or exc
|
; exc occurred in Task or Init or exc
|
||||||
; reserved for register info from task stack
|
; reserved for register info from task stack
|
||||||
|
|
||||||
LDR R2, =g_taskScheduled
|
LDR R2, =g_taskScheduled
|
||||||
LDR R2, [R2]
|
LDR R2, [R2]
|
||||||
TST R2, #1 ; OS_FLG_BGD_ACTIVE
|
TST R2, #1 ; OS_FLG_BGD_ACTIVE
|
||||||
BEQ _ExcInMSP ; if exc occured in Init then branch
|
BEQ _ExcInMSP ; if exc occurred in Init then branch
|
||||||
|
|
||||||
|
|
||||||
CMP LR, #0xFFFFFFED ;auto push floating registers
|
CMP LR, #0xFFFFFFED ;auto push floating registers
|
||||||
BNE _NoFloatInPsp
|
BNE _NoFloatInPsp
|
||||||
|
|
||||||
; exc occured in Task
|
; exc occurred in Task
|
||||||
MOV R2, R13
|
MOV R2, R13
|
||||||
SUB R13, #96 ; add 8 Bytes reg(for STMFD)
|
SUB R13, #96 ; add 8 Bytes reg(for STMFD)
|
||||||
|
|
||||||
|
|||||||
@@ -40,19 +40,46 @@
|
|||||||
#include "los_sched.h"
|
#include "los_sched.h"
|
||||||
#include "los_memory.h"
|
#include "los_memory.h"
|
||||||
#include "los_membox.h"
|
#include "los_membox.h"
|
||||||
|
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
|
||||||
|
#include "los_cpup.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
/*lint -save -e40 -e522 -e533*/
|
/*lint -save -e40 -e522 -e533*/
|
||||||
UINT32 g_intCount = 0;
|
UINT32 g_intCount = 0;
|
||||||
|
|
||||||
/*lint -restore*/
|
/*lint -restore*/
|
||||||
#pragma location = ".data.vector"
|
#pragma location = ".data.vector"
|
||||||
#pragma data_alignment=LOSCFG_ARCH_HWI_VECTOR_ALIGN
|
#pragma data_alignment = LOSCFG_ARCH_HWI_VECTOR_ALIGN
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_hwi
|
||||||
* hardware interrupt form mapping handling function array.
|
* hardware interrupt form mapping handling function array.
|
||||||
*/
|
*/
|
||||||
STATIC HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT] = {0};
|
STATIC HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT] = {0};
|
||||||
|
|
||||||
|
#if (LOSCFG_DEBUG_TOOLS == 1)
|
||||||
|
STATIC UINT32 g_hwiFormCnt[OS_HWI_MAX_NUM] = {0};
|
||||||
|
STATIC CHAR *g_hwiFormName[OS_HWI_MAX_NUM] = {0};
|
||||||
|
|
||||||
|
UINT32 OsGetHwiFormCnt(UINT32 index)
|
||||||
|
{
|
||||||
|
return g_hwiFormCnt[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
CHAR *OsGetHwiFormName(UINT32 index)
|
||||||
|
{
|
||||||
|
return g_hwiFormName[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL OsGetHwiCreated(UINT32 index)
|
||||||
|
{
|
||||||
|
if (g_hwiForm[index] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
|
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -105,17 +132,85 @@ WEAK VOID SysTick_Handler(VOID)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ****************************************************************************
|
/* ****************************************************************************
|
||||||
Function : HalIntNumGet
|
Function : HwiNumGet
|
||||||
Description : Get an interrupt number
|
Description : Get an interrupt number
|
||||||
Input : None
|
Input : None
|
||||||
Output : None
|
Output : None
|
||||||
Return : Interrupt Indexes number
|
Return : Interrupt Indexes number
|
||||||
**************************************************************************** */
|
**************************************************************************** */
|
||||||
LITE_OS_SEC_TEXT_MINOR UINT32 HalIntNumGet(VOID)
|
STATIC UINT32 HwiNumGet(VOID)
|
||||||
{
|
{
|
||||||
return __get_IPSR();
|
return __get_IPSR();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
|
||||||
|
{
|
||||||
|
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||||
|
return OS_ERRNO_HWI_NUM_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
|
||||||
|
{
|
||||||
|
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||||
|
return OS_ERRNO_HWI_NUM_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
NVIC_DisableIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority)
|
||||||
|
{
|
||||||
|
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||||
|
return OS_ERRNO_HWI_NUM_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (priority > OS_HWI_PRIO_LOWEST) {
|
||||||
|
return OS_ERRNO_HWI_PRIO_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
NVIC_SetPriority((IRQn_Type)hwiNum, priority);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
|
||||||
|
{
|
||||||
|
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||||
|
return OS_ERRNO_HWI_NUM_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
|
||||||
|
{
|
||||||
|
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||||
|
return OS_ERRNO_HWI_NUM_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
HwiControllerOps g_archHwiOps = {
|
||||||
|
.enableIrq = HwiUnmask,
|
||||||
|
.disableIrq = HwiMask,
|
||||||
|
.setIrqPriority = HwiSetPriority,
|
||||||
|
.getCurIrqNum = HwiNumGet,
|
||||||
|
.triggerIrq = HwiPending,
|
||||||
|
.clearIrq = HwiClear,
|
||||||
|
};
|
||||||
|
|
||||||
inline UINT32 ArchIsIntActive(VOID)
|
inline UINT32 ArchIsIntActive(VOID)
|
||||||
{
|
{
|
||||||
return (g_intCount > 0);
|
return (g_intCount > 0);
|
||||||
@@ -130,18 +225,19 @@ inline UINT32 ArchIsIntActive(VOID)
|
|||||||
/*lint -e529*/
|
/*lint -e529*/
|
||||||
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
|
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
|
||||||
{
|
{
|
||||||
UINT32 irqNum = HalIntNumGet();
|
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet());
|
||||||
PRINT_ERR("%s irqnum:%d\n", __FUNCTION__, irqNum);
|
|
||||||
while (1) {}
|
while (1) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
WEAK VOID HalPreInterruptHandler(UINT32 arg)
|
WEAK VOID HalPreInterruptHandler(UINT32 arg)
|
||||||
{
|
{
|
||||||
|
(VOID)arg;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
WEAK VOID HalAftInterruptHandler(UINT32 arg)
|
WEAK VOID HalAftInterruptHandler(UINT32 arg)
|
||||||
{
|
{
|
||||||
|
(VOID)arg;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,9 +263,12 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
|
|||||||
|
|
||||||
LOS_IntRestore(intSave);
|
LOS_IntRestore(intSave);
|
||||||
|
|
||||||
hwiIndex = HalIntNumGet();
|
hwiIndex = HwiNumGet();
|
||||||
|
|
||||||
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
|
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
|
||||||
|
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
|
||||||
|
OsCpupIrqStart(hwiIndex);
|
||||||
|
#endif
|
||||||
|
|
||||||
HalPreInterruptHandler(hwiIndex);
|
HalPreInterruptHandler(hwiIndex);
|
||||||
|
|
||||||
@@ -183,8 +282,16 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if (LOSCFG_DEBUG_TOOLS == 1)
|
||||||
|
++g_hwiFormCnt[hwiIndex];
|
||||||
|
#endif
|
||||||
|
|
||||||
HalAftInterruptHandler(hwiIndex);
|
HalAftInterruptHandler(hwiIndex);
|
||||||
|
|
||||||
|
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
|
||||||
|
OsCpupIrqEnd(hwiIndex);
|
||||||
|
#endif
|
||||||
|
|
||||||
OsHookCall(LOS_HOOK_TYPE_ISR_EXIT, hwiIndex);
|
OsHookCall(LOS_HOOK_TYPE_ISR_EXIT, hwiIndex);
|
||||||
|
|
||||||
intSave = LOS_IntLock();
|
intSave = LOS_IntLock();
|
||||||
@@ -197,21 +304,22 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
|
|||||||
Description : create hardware interrupt
|
Description : create hardware interrupt
|
||||||
Input : hwiNum --- hwi num to create
|
Input : hwiNum --- hwi num to create
|
||||||
hwiPrio --- priority of the hwi
|
hwiPrio --- priority of the hwi
|
||||||
mode --- unused
|
hwiMode --- unused
|
||||||
handler --- hwi handler
|
hwiHandler --- hwi handler
|
||||||
arg --- param of the hwi handler
|
irqParam --- param of the hwi handler
|
||||||
Output : None
|
Output : None
|
||||||
Return : LOS_OK on success or error code on failure
|
Return : LOS_OK on success or error code on failure
|
||||||
**************************************************************************** */
|
**************************************************************************** */
|
||||||
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
||||||
HWI_PRIOR_T hwiPrio,
|
HWI_PRIOR_T hwiPrio,
|
||||||
HWI_MODE_T mode,
|
HWI_MODE_T hwiMode,
|
||||||
HWI_PROC_FUNC handler,
|
HWI_PROC_FUNC hwiHandler,
|
||||||
HWI_ARG_T arg)
|
HwiIrqParam *irqParam)
|
||||||
{
|
{
|
||||||
|
(VOID)hwiMode;
|
||||||
UINTPTR intSave;
|
UINTPTR intSave;
|
||||||
|
|
||||||
if (handler == NULL) {
|
if (hwiHandler == NULL) {
|
||||||
return OS_ERRNO_HWI_PROC_FUNC_NULL;
|
return OS_ERRNO_HWI_PROC_FUNC_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -229,12 +337,25 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
|||||||
|
|
||||||
intSave = LOS_IntLock();
|
intSave = LOS_IntLock();
|
||||||
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
|
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
|
||||||
OsSetVector(hwiNum, handler, arg);
|
if (irqParam != NULL) {
|
||||||
|
OsSetVector(hwiNum, hwiHandler, irqParam->pDevId);
|
||||||
|
} else {
|
||||||
|
OsSetVector(hwiNum, hwiHandler, NULL);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
OsSetVector(hwiNum, handler);
|
(VOID)irqParam;
|
||||||
|
OsSetVector(hwiNum, hwiHandler);
|
||||||
#endif
|
#endif
|
||||||
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
|
||||||
NVIC_SetPriority((IRQn_Type)hwiNum, hwiPrio);
|
#if (LOSCFG_DEBUG_TOOLS == 1)
|
||||||
|
if ((irqParam != NULL) && (irqParam->pName != NULL)) {
|
||||||
|
g_hwiFormName[hwiNum + OS_SYS_VECTOR_CNT] = (CHAR *)irqParam->pName;
|
||||||
|
}
|
||||||
|
g_hwiFormCnt[hwiNum + OS_SYS_VECTOR_CNT] = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
HwiUnmask((IRQn_Type)hwiNum);
|
||||||
|
HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
|
||||||
|
|
||||||
LOS_IntRestore(intSave);
|
LOS_IntRestore(intSave);
|
||||||
|
|
||||||
@@ -245,11 +366,13 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
|||||||
Function : ArchHwiDelete
|
Function : ArchHwiDelete
|
||||||
Description : Delete hardware interrupt
|
Description : Delete hardware interrupt
|
||||||
Input : hwiNum --- hwi num to delete
|
Input : hwiNum --- hwi num to delete
|
||||||
|
irqParam --- param of the hwi handler
|
||||||
Output : None
|
Output : None
|
||||||
Return : LOS_OK on success or error code on failure
|
Return : LOS_OK on success or error code on failure
|
||||||
**************************************************************************** */
|
**************************************************************************** */
|
||||||
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum)
|
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam)
|
||||||
{
|
{
|
||||||
|
(VOID)irqParam;
|
||||||
UINT32 intSave;
|
UINT32 intSave;
|
||||||
|
|
||||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||||
@@ -376,6 +499,7 @@ STATIC VOID OsExcRegInfo(const ExcInfo *excInfo)
|
|||||||
PRINTK("xPSR = 0x%x\n", excInfo->context->uwxPSR);
|
PRINTK("xPSR = 0x%x\n", excInfo->context->uwxPSR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if (LOSCFG_KERNEL_BACKTRACE == 1)
|
||||||
STATIC VOID OsExcBackTraceInfo(const ExcInfo *excInfo)
|
STATIC VOID OsExcBackTraceInfo(const ExcInfo *excInfo)
|
||||||
{
|
{
|
||||||
UINTPTR LR[LOSCFG_BACKTRACE_DEPTH] = {0};
|
UINTPTR LR[LOSCFG_BACKTRACE_DEPTH] = {0};
|
||||||
@@ -392,6 +516,7 @@ STATIC VOID OsExcBackTraceInfo(const ExcInfo *excInfo)
|
|||||||
}
|
}
|
||||||
PRINTK("----- backtrace end -----\n");
|
PRINTK("----- backtrace end -----\n");
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
STATIC VOID OsExcMemPoolCheckInfo(VOID)
|
STATIC VOID OsExcMemPoolCheckInfo(VOID)
|
||||||
{
|
{
|
||||||
@@ -441,7 +566,9 @@ STATIC VOID OsExcInfoDisplay(const ExcInfo *excInfo)
|
|||||||
OsExcTypeInfo(excInfo);
|
OsExcTypeInfo(excInfo);
|
||||||
OsExcCurTaskInfo(excInfo);
|
OsExcCurTaskInfo(excInfo);
|
||||||
OsExcRegInfo(excInfo);
|
OsExcRegInfo(excInfo);
|
||||||
|
#if (LOSCFG_KERNEL_BACKTRACE == 1)
|
||||||
OsExcBackTraceInfo(excInfo);
|
OsExcBackTraceInfo(excInfo);
|
||||||
|
#endif
|
||||||
OsGetAllTskInfo();
|
OsGetAllTskInfo();
|
||||||
OsExcNvicDump();
|
OsExcNvicDump();
|
||||||
OsExcMemPoolCheckInfo();
|
OsExcMemPoolCheckInfo();
|
||||||
@@ -496,19 +623,19 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
|
|||||||
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
|
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
|
||||||
UINT32 index;
|
UINT32 index;
|
||||||
g_hwiForm[0] = 0; /* [0] Top of Stack */
|
g_hwiForm[0] = 0; /* [0] Top of Stack */
|
||||||
g_hwiForm[1] = Reset_Handler; /* [1] reset */
|
g_hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */
|
||||||
for (index = 2; index < OS_VECTOR_CNT; index++) { /* 2: The starting position of the interrupt */
|
for (index = 2; index < OS_VECTOR_CNT; index++) { /* 2: The starting position of the interrupt */
|
||||||
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
|
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
|
||||||
}
|
}
|
||||||
/* Exception handler register */
|
/* Exception handler register */
|
||||||
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = HalExcNMI;
|
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
|
||||||
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = HalExcHardFault;
|
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
|
||||||
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = HalExcMemFault;
|
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
|
||||||
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcBusFault;
|
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
|
||||||
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcUsageFault;
|
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
|
||||||
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = HalSVCHandler;
|
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
|
||||||
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = HalPendSV;
|
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
|
||||||
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = SysTick_Handler;
|
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
|
||||||
|
|
||||||
/* Interrupt vector table location */
|
/* Interrupt vector table location */
|
||||||
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;
|
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
#include "los_debug.h"
|
#include "los_debug.h"
|
||||||
|
|
||||||
STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler);
|
STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler);
|
||||||
STATIC VOID SysTickReload(UINT64 nextResponseTime);
|
STATIC UINT64 SysTickReload(UINT64 nextResponseTime);
|
||||||
STATIC UINT64 SysTickCycleGet(UINT32 *period);
|
STATIC UINT64 SysTickCycleGet(UINT32 *period);
|
||||||
STATIC VOID SysTickLock(VOID);
|
STATIC VOID SysTickLock(VOID);
|
||||||
STATIC VOID SysTickUnlock(VOID);
|
STATIC VOID SysTickUnlock(VOID);
|
||||||
@@ -44,6 +44,7 @@ STATIC VOID SysTickUnlock(VOID);
|
|||||||
STATIC ArchTickTimer g_archTickTimer = {
|
STATIC ArchTickTimer g_archTickTimer = {
|
||||||
.freq = 0,
|
.freq = 0,
|
||||||
.irqNum = SysTick_IRQn,
|
.irqNum = SysTick_IRQn,
|
||||||
|
.periodMax = LOSCFG_BASE_CORE_TICK_RESPONSE_MAX,
|
||||||
.init = SysTickStart,
|
.init = SysTickStart,
|
||||||
.getCycle = SysTickCycleGet,
|
.getCycle = SysTickCycleGet,
|
||||||
.reload = SysTickReload,
|
.reload = SysTickReload,
|
||||||
@@ -75,13 +76,17 @@ STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler)
|
|||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC VOID SysTickReload(UINT64 nextResponseTime)
|
STATIC UINT64 SysTickReload(UINT64 nextResponseTime)
|
||||||
{
|
{
|
||||||
|
if (nextResponseTime > g_archTickTimer.periodMax) {
|
||||||
|
nextResponseTime = g_archTickTimer.periodMax;
|
||||||
|
}
|
||||||
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
|
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
|
||||||
SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */
|
SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */
|
||||||
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
|
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
|
||||||
NVIC_ClearPendingIRQ(SysTick_IRQn);
|
NVIC_ClearPendingIRQ(SysTick_IRQn);
|
||||||
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
|
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
|
||||||
|
return nextResponseTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC UINT64 SysTickCycleGet(UINT32 *period)
|
STATIC UINT64 SysTickCycleGet(UINT32 *period)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
* Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
* are permitted provided that the following conditions are met:
|
* are permitted provided that the following conditions are met:
|
||||||
@@ -33,6 +33,7 @@
|
|||||||
#define _LOS_ARCH_ATOMIC_H
|
#define _LOS_ARCH_ATOMIC_H
|
||||||
|
|
||||||
#include "los_compiler.h"
|
#include "los_compiler.h"
|
||||||
|
#include "los_interrupt.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
@@ -43,15 +44,11 @@ extern "C" {
|
|||||||
STATIC INLINE INT32 ArchAtomicRead(const Atomic *v)
|
STATIC INLINE INT32 ArchAtomicRead(const Atomic *v)
|
||||||
{
|
{
|
||||||
INT32 val;
|
INT32 val;
|
||||||
UINT32 intSave;
|
|
||||||
|
|
||||||
intSave = LOS_IntLock();
|
asm volatile("ldrex %0, [%1]\n"
|
||||||
|
: "=&r"(val)
|
||||||
__asm__ __volatile__("ldrex %0, [%1]\n"
|
: "r"(v)
|
||||||
: "=&r"(val)
|
: "cc");
|
||||||
: "r"(v)
|
|
||||||
: "cc");
|
|
||||||
LOS_IntRestore(intSave);
|
|
||||||
|
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
@@ -59,18 +56,14 @@ STATIC INLINE INT32 ArchAtomicRead(const Atomic *v)
|
|||||||
STATIC INLINE VOID ArchAtomicSet(Atomic *v, INT32 setVal)
|
STATIC INLINE VOID ArchAtomicSet(Atomic *v, INT32 setVal)
|
||||||
{
|
{
|
||||||
UINT32 status;
|
UINT32 status;
|
||||||
UINT32 intSave;
|
|
||||||
|
|
||||||
intSave = LOS_IntLock();
|
do {
|
||||||
|
asm volatile("ldrex %0, [%1]\n"
|
||||||
__asm__ __volatile__("1:ldrex %0, [%1]\n"
|
"strex %0, %2, [%1]\n"
|
||||||
" strex %0, %2, [%1]\n"
|
: "=&r"(status)
|
||||||
" teq %0, #0\n"
|
: "r"(v), "r"(setVal)
|
||||||
" bne 1b"
|
: "cc");
|
||||||
: "=&r"(status)
|
} while (status != 0);
|
||||||
: "r"(v), "r"(setVal)
|
|
||||||
: "cc");
|
|
||||||
LOS_IntRestore(intSave);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC INLINE INT32 ArchAtomicAdd(Atomic *v, INT32 addVal)
|
STATIC INLINE INT32 ArchAtomicAdd(Atomic *v, INT32 addVal)
|
||||||
@@ -79,13 +72,13 @@ STATIC INLINE INT32 ArchAtomicAdd(Atomic *v, INT32 addVal)
|
|||||||
UINT32 status;
|
UINT32 status;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
__asm__ __volatile__("ldrex %1, [%2]\n"
|
asm volatile("ldrex %1, [%2]\n"
|
||||||
"add %1, %1, %3\n"
|
"add %1, %1, %3\n"
|
||||||
"strex %0, %1, [%2]"
|
"strex %0, %1, [%2]"
|
||||||
: "=&r"(status), "=&r"(val)
|
: "=&r"(status), "=&r"(val)
|
||||||
: "r"(v), "r"(addVal)
|
: "r"(v), "r"(addVal)
|
||||||
: "cc");
|
: "cc");
|
||||||
} while (__builtin_expect(status != 0, 0));
|
} while (status != 0);
|
||||||
|
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
@@ -96,13 +89,13 @@ STATIC INLINE INT32 ArchAtomicSub(Atomic *v, INT32 subVal)
|
|||||||
UINT32 status;
|
UINT32 status;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
__asm__ __volatile__("ldrex %1, [%2]\n"
|
asm volatile("ldrex %1, [%2]\n"
|
||||||
"sub %1, %1, %3\n"
|
"sub %1, %1, %3\n"
|
||||||
"strex %0, %1, [%2]"
|
"strex %0, %1, [%2]"
|
||||||
: "=&r"(status), "=&r"(val)
|
: "=&r"(status), "=&r"(val)
|
||||||
: "r"(v), "r"(subVal)
|
: "r"(v), "r"(subVal)
|
||||||
: "cc");
|
: "cc");
|
||||||
} while (__builtin_expect(status != 0, 0));
|
} while (status != 0);
|
||||||
|
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
@@ -151,12 +144,12 @@ STATIC INLINE INT32 ArchAtomicXchg32bits(volatile INT32 *v, INT32 val)
|
|||||||
UINT32 status = 0;
|
UINT32 status = 0;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
__asm__ __volatile__("ldrex %0, [%3]\n"
|
asm volatile("ldrex %0, [%2]\n"
|
||||||
"strex %1, %4, [%3]"
|
"strex %1, %3, [%2]"
|
||||||
: "=&r"(prevVal), "=&r"(status), "+m"(*v)
|
: "=&r"(prevVal), "=&r"(status)
|
||||||
: "r"(v), "r"(val)
|
: "r"(v), "r"(val)
|
||||||
: "cc");
|
: "cc");
|
||||||
} while (__builtin_expect(status != 0, 0));
|
} while (status != 0);
|
||||||
|
|
||||||
return prevVal;
|
return prevVal;
|
||||||
}
|
}
|
||||||
@@ -186,16 +179,16 @@ STATIC INLINE BOOL ArchAtomicCmpXchg32bits(volatile INT32 *v, INT32 val, INT32 o
|
|||||||
UINT32 status = 0;
|
UINT32 status = 0;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
__asm__ __volatile__("1: ldrex %0, %2\n"
|
asm volatile("ldrex %0, [%2]\n"
|
||||||
" mov %1, #0\n"
|
"mov %1, #0\n"
|
||||||
" cmp %0, %3\n"
|
"cmp %0, %3\n"
|
||||||
" bne 2f\n"
|
"bne 1f\n"
|
||||||
" strex %1, %4, %2\n"
|
"strex %1, %4, [%2]\n"
|
||||||
"2:"
|
"1:"
|
||||||
: "=&r"(prevVal), "=&r"(status), "+Q"(*v)
|
: "=&r"(prevVal), "=&r"(status)
|
||||||
: "r"(oldVal), "r"(val)
|
: "r"(v), "r"(oldVal), "r"(val)
|
||||||
: "cc");
|
: "cc");
|
||||||
} while (__builtin_expect(status != 0, 0));
|
} while (status != 0);
|
||||||
|
|
||||||
return prevVal != oldVal;
|
return prevVal != oldVal;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,7 +109,8 @@ extern UINT32 _BootVectors[];
|
|||||||
*
|
*
|
||||||
* Value: 0x02000900
|
* Value: 0x02000900
|
||||||
*
|
*
|
||||||
* Solution: Ensure that the interrupt number is valid. The value range of the interrupt number applicable for a Cortex-A7 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
|
* Solution: Ensure that the interrupt number is valid.
|
||||||
|
* The value range of the interrupt number applicable for a Cortex-M33 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
|
||||||
*/
|
*/
|
||||||
#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
|
#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
|
||||||
|
|
||||||
@@ -159,7 +160,8 @@ extern UINT32 _BootVectors[];
|
|||||||
*
|
*
|
||||||
* Value: 0x02000905
|
* Value: 0x02000905
|
||||||
*
|
*
|
||||||
* Solution: Ensure that the interrupt priority is valid. The value range of the interrupt priority applicable for a Cortex-A7 platform is [0,15].
|
* Solution: Ensure that the interrupt priority is valid.
|
||||||
|
* The value range of the interrupt priority applicable for a Cortex-M33 platform is [0,15].
|
||||||
*/
|
*/
|
||||||
#define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05)
|
#define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05)
|
||||||
|
|
||||||
@@ -169,7 +171,8 @@ extern UINT32 _BootVectors[];
|
|||||||
*
|
*
|
||||||
* Value: 0x02000906
|
* Value: 0x02000906
|
||||||
*
|
*
|
||||||
* Solution: The interrupt creation mode can be only set to OS_HWI_MODE_COMM or OS_HWI_MODE_FAST of which the value can be 0 or 1.
|
* Solution: The interrupt creation mode can be only set to OS_HWI_MODE_COMM or
|
||||||
|
* OS_HWI_MODE_FAST of which the value can be 0 or 1.
|
||||||
*/
|
*/
|
||||||
#define OS_ERRNO_HWI_MODE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x06)
|
#define OS_ERRNO_HWI_MODE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x06)
|
||||||
|
|
||||||
@@ -342,25 +345,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
|
|||||||
*/
|
*/
|
||||||
extern VOID HalInterrupt(VOID);
|
extern VOID HalInterrupt(VOID);
|
||||||
|
|
||||||
/* *
|
|
||||||
* @ingroup los_hwi
|
|
||||||
* @brief: Get an interrupt number.
|
|
||||||
*
|
|
||||||
* @par Description:
|
|
||||||
* This API is used to get the current interrupt number.
|
|
||||||
*
|
|
||||||
* @attention:
|
|
||||||
* <ul><li>None.</li></ul>
|
|
||||||
*
|
|
||||||
* @param: None.
|
|
||||||
*
|
|
||||||
* @retval: Interrupt Indexes number.
|
|
||||||
* @par Dependency:
|
|
||||||
* <ul><li>los_hwi.h: the header file that contains the API declaration.</li></ul>
|
|
||||||
* @see None.
|
|
||||||
*/
|
|
||||||
extern UINT32 HalIntNumGet(VOID);
|
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_hwi
|
||||||
* @brief: Default vector handling function.
|
* @brief: Default vector handling function.
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ LITE_OS_SEC_TEXT_INIT VOID ArchInit(VOID)
|
|||||||
**************************************************************************** */
|
**************************************************************************** */
|
||||||
LITE_OS_SEC_TEXT_MINOR VOID ArchSysExit(VOID)
|
LITE_OS_SEC_TEXT_MINOR VOID ArchSysExit(VOID)
|
||||||
{
|
{
|
||||||
LOS_IntLock();
|
(VOID)LOS_IntLock();
|
||||||
while (1) {
|
while (1) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -75,17 +75,7 @@ LITE_OS_SEC_TEXT_MINOR VOID ArchSysExit(VOID)
|
|||||||
**************************************************************************** */
|
**************************************************************************** */
|
||||||
LITE_OS_SEC_TEXT_INIT VOID *ArchTskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack)
|
LITE_OS_SEC_TEXT_INIT VOID *ArchTskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack)
|
||||||
{
|
{
|
||||||
TaskContext *context = NULL;
|
TaskContext *context = (TaskContext *)((UINTPTR)topStack + stackSize - sizeof(TaskContext));
|
||||||
errno_t result;
|
|
||||||
|
|
||||||
/* initialize the task stack, write magic num to stack top */
|
|
||||||
result = memset_s(topStack, stackSize, (INT32)(OS_TASK_STACK_INIT & 0xFF), stackSize);
|
|
||||||
if (result != EOK) {
|
|
||||||
printf("memset_s is failed:%s[%d]\r\n", __FUNCTION__, __LINE__);
|
|
||||||
}
|
|
||||||
*((UINT32 *)(topStack)) = OS_TASK_MAGIC_WORD;
|
|
||||||
|
|
||||||
context = (TaskContext *)(((UINTPTR)topStack + stackSize) - sizeof(TaskContext));
|
|
||||||
|
|
||||||
#if ((defined(__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
|
#if ((defined(__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
|
||||||
(defined(__FPU_USED) && (__FPU_USED == 1U)))
|
(defined(__FPU_USED) && (__FPU_USED == 1U)))
|
||||||
@@ -150,6 +140,20 @@ LITE_OS_SEC_TEXT_INIT VOID *ArchTskStackInit(UINT32 taskID, UINT32 stackSize, VO
|
|||||||
return (VOID *)context;
|
return (VOID *)context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VOID *ArchSignalContextInit(VOID *stackPointer, VOID *stackTop, UINTPTR sigHandler, UINT32 param)
|
||||||
|
{
|
||||||
|
TaskContext *context = (TaskContext *)((UINTPTR)stackPointer - sizeof(TaskContext));
|
||||||
|
(VOID)memset_s((VOID *)context, sizeof(TaskContext), 0, sizeof(TaskContext));
|
||||||
|
|
||||||
|
context->uwR0 = param;
|
||||||
|
context->uwPC = sigHandler;
|
||||||
|
context->stackLimit = (UINT32)stackTop;
|
||||||
|
context->excReturn = 0xFFFFFFBC;
|
||||||
|
context->uwxPSR = 0x01000000L; /* Thumb flag, always set 1 */
|
||||||
|
|
||||||
|
return (VOID *)context;
|
||||||
|
}
|
||||||
|
|
||||||
LITE_OS_SEC_TEXT_INIT UINT32 ArchStartSchedule(VOID)
|
LITE_OS_SEC_TEXT_INIT UINT32 ArchStartSchedule(VOID)
|
||||||
{
|
{
|
||||||
(VOID)LOS_IntLock();
|
(VOID)LOS_IntLock();
|
||||||
|
|||||||
@@ -41,7 +41,7 @@
|
|||||||
EXPORT HalSVCStartSchedule
|
EXPORT HalSVCStartSchedule
|
||||||
EXPORT HalSVCSecureContextAlloc
|
EXPORT HalSVCSecureContextAlloc
|
||||||
EXPORT HalSVCSecureContextFree
|
EXPORT HalSVCSecureContextFree
|
||||||
|
IMPORT OsSignalTaskContextRestore
|
||||||
IMPORT OsSchedTaskSwitch
|
IMPORT OsSchedTaskSwitch
|
||||||
IMPORT g_losTask
|
IMPORT g_losTask
|
||||||
|
|
||||||
@@ -62,6 +62,15 @@ OS_TASK_STATUS_RUNNING EQU 0x0010
|
|||||||
THUMB
|
THUMB
|
||||||
REQUIRE8
|
REQUIRE8
|
||||||
|
|
||||||
|
MACRO SIGNAL_CONTEXT_RESTORE
|
||||||
|
PUSH {R12, LR}
|
||||||
|
BLX OsSignalTaskContextRestore
|
||||||
|
POP {R12, LR}
|
||||||
|
CMP R0, #0
|
||||||
|
MOV R1, R0
|
||||||
|
BNE SignalContextRestore
|
||||||
|
ENDM
|
||||||
|
|
||||||
HalStartFirstTask
|
HalStartFirstTask
|
||||||
MOV R0, #2
|
MOV R0, #2
|
||||||
MSR CONTROL, R0
|
MSR CONTROL, R0
|
||||||
@@ -118,6 +127,8 @@ HalPendSV
|
|||||||
CPSID I
|
CPSID I
|
||||||
|
|
||||||
HalTaskSwitch
|
HalTaskSwitch
|
||||||
|
SIGNAL_CONTEXT_RESTORE
|
||||||
|
|
||||||
PUSH {R12, LR}
|
PUSH {R12, LR}
|
||||||
BLX OsSchedTaskSwitch
|
BLX OsSchedTaskSwitch
|
||||||
POP {R12, LR}
|
POP {R12, LR}
|
||||||
@@ -161,8 +172,9 @@ __DisabledFPU2
|
|||||||
|
|
||||||
LDR R0, [R5, #4]
|
LDR R0, [R5, #4]
|
||||||
STR R0, [R5]
|
STR R0, [R5]
|
||||||
|
|
||||||
LDR R1, [R0]
|
LDR R1, [R0]
|
||||||
|
|
||||||
|
SignalContextRestore
|
||||||
LDMIA R1!, {R0, R2-R3} /* Restore secureContext, PSPLIM and LR from the current task stack. */
|
LDMIA R1!, {R0, R2-R3} /* Restore secureContext, PSPLIM and LR from the current task stack. */
|
||||||
MSR PSPLIM, R2
|
MSR PSPLIM, R2
|
||||||
MOV LR, R3
|
MOV LR, R3
|
||||||
|
|||||||
@@ -55,8 +55,8 @@ FLAG_ADDR_VALID EQU 0x10000
|
|||||||
FLAG_HWI_ACTIVE EQU 0x20000
|
FLAG_HWI_ACTIVE EQU 0x20000
|
||||||
FLAG_NO_FLOAT EQU 0x10000000
|
FLAG_NO_FLOAT EQU 0x10000000
|
||||||
|
|
||||||
OS_NVIC_FSR EQU 0xE000ED28 ;include BusFault/MemFault/UsageFault State Regeister
|
OS_NVIC_FSR EQU 0xE000ED28 ;include BusFault/MemFault/UsageFault State Register
|
||||||
OS_NVIC_HFSR EQU 0xE000ED2C ;HardFault State Regeister
|
OS_NVIC_HFSR EQU 0xE000ED2C ;HardFault State Register
|
||||||
OS_NVIC_BFAR EQU 0xE000ED38
|
OS_NVIC_BFAR EQU 0xE000ED38
|
||||||
OS_NVIC_MMAR EQU 0xE000ED34
|
OS_NVIC_MMAR EQU 0xE000ED34
|
||||||
OS_NVIC_ACT_BASE EQU 0xE000E300
|
OS_NVIC_ACT_BASE EQU 0xE000E300
|
||||||
@@ -179,7 +179,7 @@ _hwiActiveCheck
|
|||||||
CMP R3, #0
|
CMP R3, #0
|
||||||
BEQ _hwiActiveCheckNext
|
BEQ _hwiActiveCheckNext
|
||||||
|
|
||||||
; exc occured in IRQ
|
; exc occurred in IRQ
|
||||||
ORR R0, R0, #FLAG_HWI_ACTIVE
|
ORR R0, R0, #FLAG_HWI_ACTIVE
|
||||||
RBIT R2, R3
|
RBIT R2, R3
|
||||||
CLZ R2, R2
|
CLZ R2, R2
|
||||||
@@ -217,19 +217,19 @@ _hwiActiveCheckNext
|
|||||||
AND R2, R2,R3
|
AND R2, R2,R3
|
||||||
CMP R2,#0
|
CMP R2,#0
|
||||||
BNE _ExcInMSP
|
BNE _ExcInMSP
|
||||||
; exc occured in Task or Init or exc
|
; exc occurred in Task or Init or exc
|
||||||
; reserved for register info from task stack
|
; reserved for register info from task stack
|
||||||
|
|
||||||
LDR R2, =g_taskScheduled
|
LDR R2, =g_taskScheduled
|
||||||
LDR R2, [R2]
|
LDR R2, [R2]
|
||||||
TST R2, #1 ; OS_FLG_BGD_ACTIVE
|
TST R2, #1 ; OS_FLG_BGD_ACTIVE
|
||||||
BEQ _ExcInMSP ; if exc occured in Init then branch
|
BEQ _ExcInMSP ; if exc occurred in Init then branch
|
||||||
|
|
||||||
|
|
||||||
CMP LR, #0xFFFFFFED ;auto push floating registers
|
CMP LR, #0xFFFFFFED ;auto push floating registers
|
||||||
BNE _NoFloatInPsp
|
BNE _NoFloatInPsp
|
||||||
|
|
||||||
; exc occured in Task
|
; exc occurred in Task
|
||||||
MOV R2, R13
|
MOV R2, R13
|
||||||
SUB R13, #96 ; add 8 Bytes reg(for STMFD)
|
SUB R13, #96 ; add 8 Bytes reg(for STMFD)
|
||||||
|
|
||||||
|
|||||||
@@ -40,19 +40,46 @@
|
|||||||
#include "los_sched.h"
|
#include "los_sched.h"
|
||||||
#include "los_memory.h"
|
#include "los_memory.h"
|
||||||
#include "los_membox.h"
|
#include "los_membox.h"
|
||||||
|
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
|
||||||
|
#include "los_cpup.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
/*lint -save -e40 -e522 -e533*/
|
/*lint -save -e40 -e522 -e533*/
|
||||||
UINT32 g_intCount = 0;
|
UINT32 g_intCount = 0;
|
||||||
|
|
||||||
/*lint -restore*/
|
/*lint -restore*/
|
||||||
#pragma location = ".data.vector"
|
#pragma location = ".data.vector"
|
||||||
#pragma data_alignment=LOSCFG_ARCH_HWI_VECTOR_ALIGN
|
#pragma data_alignment = LOSCFG_ARCH_HWI_VECTOR_ALIGN
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_hwi
|
||||||
* hardware interrupt form mapping handling function array.
|
* hardware interrupt form mapping handling function array.
|
||||||
*/
|
*/
|
||||||
STATIC HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT] = {0};
|
STATIC HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT] = {0};
|
||||||
|
|
||||||
|
#if (LOSCFG_DEBUG_TOOLS == 1)
|
||||||
|
STATIC UINT32 g_hwiFormCnt[OS_HWI_MAX_NUM] = {0};
|
||||||
|
STATIC CHAR *g_hwiFormName[OS_HWI_MAX_NUM] = {0};
|
||||||
|
|
||||||
|
UINT32 OsGetHwiFormCnt(UINT32 index)
|
||||||
|
{
|
||||||
|
return g_hwiFormCnt[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
CHAR *OsGetHwiFormName(UINT32 index)
|
||||||
|
{
|
||||||
|
return g_hwiFormName[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL OsGetHwiCreated(UINT32 index)
|
||||||
|
{
|
||||||
|
if (g_hwiForm[index] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
|
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -105,17 +132,85 @@ WEAK VOID SysTick_Handler(VOID)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ****************************************************************************
|
/* ****************************************************************************
|
||||||
Function : HalIntNumGet
|
Function : HwiNumGet
|
||||||
Description : Get an interrupt number
|
Description : Get an interrupt number
|
||||||
Input : None
|
Input : None
|
||||||
Output : None
|
Output : None
|
||||||
Return : Interrupt Indexes number
|
Return : Interrupt Indexes number
|
||||||
**************************************************************************** */
|
**************************************************************************** */
|
||||||
LITE_OS_SEC_TEXT_MINOR UINT32 HalIntNumGet(VOID)
|
STATIC UINT32 HwiNumGet(VOID)
|
||||||
{
|
{
|
||||||
return __get_IPSR();
|
return __get_IPSR();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
|
||||||
|
{
|
||||||
|
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||||
|
return OS_ERRNO_HWI_NUM_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
|
||||||
|
{
|
||||||
|
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||||
|
return OS_ERRNO_HWI_NUM_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
NVIC_DisableIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority)
|
||||||
|
{
|
||||||
|
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||||
|
return OS_ERRNO_HWI_NUM_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (priority > OS_HWI_PRIO_LOWEST) {
|
||||||
|
return OS_ERRNO_HWI_PRIO_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
NVIC_SetPriority((IRQn_Type)hwiNum, priority);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
|
||||||
|
{
|
||||||
|
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||||
|
return OS_ERRNO_HWI_NUM_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
|
||||||
|
{
|
||||||
|
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||||
|
return OS_ERRNO_HWI_NUM_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
HwiControllerOps g_archHwiOps = {
|
||||||
|
.enableIrq = HwiUnmask,
|
||||||
|
.disableIrq = HwiMask,
|
||||||
|
.setIrqPriority = HwiSetPriority,
|
||||||
|
.getCurIrqNum = HwiNumGet,
|
||||||
|
.triggerIrq = HwiPending,
|
||||||
|
.clearIrq = HwiClear,
|
||||||
|
};
|
||||||
|
|
||||||
inline UINT32 ArchIsIntActive(VOID)
|
inline UINT32 ArchIsIntActive(VOID)
|
||||||
{
|
{
|
||||||
return (g_intCount > 0);
|
return (g_intCount > 0);
|
||||||
@@ -130,18 +225,19 @@ inline UINT32 ArchIsIntActive(VOID)
|
|||||||
/*lint -e529*/
|
/*lint -e529*/
|
||||||
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
|
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
|
||||||
{
|
{
|
||||||
UINT32 irqNum = HalIntNumGet();
|
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet());
|
||||||
PRINT_ERR("%s irqnum:%d\n", __FUNCTION__, irqNum);
|
|
||||||
while (1) {}
|
while (1) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
WEAK VOID HalPreInterruptHandler(UINT32 arg)
|
WEAK VOID HalPreInterruptHandler(UINT32 arg)
|
||||||
{
|
{
|
||||||
|
(VOID)arg;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
WEAK VOID HalAftInterruptHandler(UINT32 arg)
|
WEAK VOID HalAftInterruptHandler(UINT32 arg)
|
||||||
{
|
{
|
||||||
|
(VOID)arg;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,9 +263,12 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
|
|||||||
|
|
||||||
LOS_IntRestore(intSave);
|
LOS_IntRestore(intSave);
|
||||||
|
|
||||||
hwiIndex = HalIntNumGet();
|
hwiIndex = HwiNumGet();
|
||||||
|
|
||||||
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
|
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
|
||||||
|
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
|
||||||
|
OsCpupIrqStart(hwiIndex);
|
||||||
|
#endif
|
||||||
|
|
||||||
HalPreInterruptHandler(hwiIndex);
|
HalPreInterruptHandler(hwiIndex);
|
||||||
|
|
||||||
@@ -183,8 +282,16 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if (LOSCFG_DEBUG_TOOLS == 1)
|
||||||
|
++g_hwiFormCnt[hwiIndex];
|
||||||
|
#endif
|
||||||
|
|
||||||
HalAftInterruptHandler(hwiIndex);
|
HalAftInterruptHandler(hwiIndex);
|
||||||
|
|
||||||
|
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
|
||||||
|
OsCpupIrqEnd(hwiIndex);
|
||||||
|
#endif
|
||||||
|
|
||||||
OsHookCall(LOS_HOOK_TYPE_ISR_EXIT, hwiIndex);
|
OsHookCall(LOS_HOOK_TYPE_ISR_EXIT, hwiIndex);
|
||||||
|
|
||||||
intSave = LOS_IntLock();
|
intSave = LOS_IntLock();
|
||||||
@@ -197,21 +304,22 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
|
|||||||
Description : create hardware interrupt
|
Description : create hardware interrupt
|
||||||
Input : hwiNum --- hwi num to create
|
Input : hwiNum --- hwi num to create
|
||||||
hwiPrio --- priority of the hwi
|
hwiPrio --- priority of the hwi
|
||||||
mode --- unused
|
hwiMode --- unused
|
||||||
handler --- hwi handler
|
hwiHandler --- hwi handler
|
||||||
arg --- param of the hwi handler
|
irqParam --- param of the hwi handler
|
||||||
Output : None
|
Output : None
|
||||||
Return : LOS_OK on success or error code on failure
|
Return : LOS_OK on success or error code on failure
|
||||||
**************************************************************************** */
|
**************************************************************************** */
|
||||||
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
||||||
HWI_PRIOR_T hwiPrio,
|
HWI_PRIOR_T hwiPrio,
|
||||||
HWI_MODE_T mode,
|
HWI_MODE_T hwiMode,
|
||||||
HWI_PROC_FUNC handler,
|
HWI_PROC_FUNC hwiHandler,
|
||||||
HWI_ARG_T arg)
|
HwiIrqParam *irqParam)
|
||||||
{
|
{
|
||||||
|
(VOID)hwiMode;
|
||||||
UINTPTR intSave;
|
UINTPTR intSave;
|
||||||
|
|
||||||
if (handler == NULL) {
|
if (hwiHandler == NULL) {
|
||||||
return OS_ERRNO_HWI_PROC_FUNC_NULL;
|
return OS_ERRNO_HWI_PROC_FUNC_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -229,12 +337,25 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
|||||||
|
|
||||||
intSave = LOS_IntLock();
|
intSave = LOS_IntLock();
|
||||||
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
|
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
|
||||||
OsSetVector(hwiNum, handler, arg);
|
if (irqParam != NULL) {
|
||||||
|
OsSetVector(hwiNum, hwiHandler, irqParam->pDevId);
|
||||||
|
} else {
|
||||||
|
OsSetVector(hwiNum, hwiHandler, NULL);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
OsSetVector(hwiNum, handler);
|
(VOID)irqParam;
|
||||||
|
OsSetVector(hwiNum, hwiHandler);
|
||||||
#endif
|
#endif
|
||||||
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
|
||||||
NVIC_SetPriority((IRQn_Type)hwiNum, hwiPrio);
|
#if (LOSCFG_DEBUG_TOOLS == 1)
|
||||||
|
if ((irqParam != NULL) && (irqParam->pName != NULL)) {
|
||||||
|
g_hwiFormName[hwiNum + OS_SYS_VECTOR_CNT] = (CHAR *)irqParam->pName;
|
||||||
|
}
|
||||||
|
g_hwiFormCnt[hwiNum + OS_SYS_VECTOR_CNT] = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
HwiUnmask((IRQn_Type)hwiNum);
|
||||||
|
HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
|
||||||
|
|
||||||
LOS_IntRestore(intSave);
|
LOS_IntRestore(intSave);
|
||||||
|
|
||||||
@@ -245,11 +366,13 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
|||||||
Function : ArchHwiDelete
|
Function : ArchHwiDelete
|
||||||
Description : Delete hardware interrupt
|
Description : Delete hardware interrupt
|
||||||
Input : hwiNum --- hwi num to delete
|
Input : hwiNum --- hwi num to delete
|
||||||
|
irqParam --- param of the hwi handler
|
||||||
Output : None
|
Output : None
|
||||||
Return : LOS_OK on success or error code on failure
|
Return : LOS_OK on success or error code on failure
|
||||||
**************************************************************************** */
|
**************************************************************************** */
|
||||||
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum)
|
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam)
|
||||||
{
|
{
|
||||||
|
(VOID)irqParam;
|
||||||
UINT32 intSave;
|
UINT32 intSave;
|
||||||
|
|
||||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||||
@@ -376,6 +499,7 @@ STATIC VOID OsExcRegInfo(const ExcInfo *excInfo)
|
|||||||
PRINTK("xPSR = 0x%x\n", excInfo->context->uwxPSR);
|
PRINTK("xPSR = 0x%x\n", excInfo->context->uwxPSR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if (LOSCFG_KERNEL_BACKTRACE == 1)
|
||||||
STATIC VOID OsExcBackTraceInfo(const ExcInfo *excInfo)
|
STATIC VOID OsExcBackTraceInfo(const ExcInfo *excInfo)
|
||||||
{
|
{
|
||||||
UINTPTR LR[LOSCFG_BACKTRACE_DEPTH] = {0};
|
UINTPTR LR[LOSCFG_BACKTRACE_DEPTH] = {0};
|
||||||
@@ -392,6 +516,7 @@ STATIC VOID OsExcBackTraceInfo(const ExcInfo *excInfo)
|
|||||||
}
|
}
|
||||||
PRINTK("----- backtrace end -----\n");
|
PRINTK("----- backtrace end -----\n");
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
STATIC VOID OsExcMemPoolCheckInfo(VOID)
|
STATIC VOID OsExcMemPoolCheckInfo(VOID)
|
||||||
{
|
{
|
||||||
@@ -441,7 +566,9 @@ STATIC VOID OsExcInfoDisplay(const ExcInfo *excInfo)
|
|||||||
OsExcTypeInfo(excInfo);
|
OsExcTypeInfo(excInfo);
|
||||||
OsExcCurTaskInfo(excInfo);
|
OsExcCurTaskInfo(excInfo);
|
||||||
OsExcRegInfo(excInfo);
|
OsExcRegInfo(excInfo);
|
||||||
|
#if (LOSCFG_KERNEL_BACKTRACE == 1)
|
||||||
OsExcBackTraceInfo(excInfo);
|
OsExcBackTraceInfo(excInfo);
|
||||||
|
#endif
|
||||||
OsGetAllTskInfo();
|
OsGetAllTskInfo();
|
||||||
OsExcNvicDump();
|
OsExcNvicDump();
|
||||||
OsExcMemPoolCheckInfo();
|
OsExcMemPoolCheckInfo();
|
||||||
@@ -496,19 +623,19 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
|
|||||||
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
|
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
|
||||||
UINT32 index;
|
UINT32 index;
|
||||||
g_hwiForm[0] = 0; /* [0] Top of Stack */
|
g_hwiForm[0] = 0; /* [0] Top of Stack */
|
||||||
g_hwiForm[1] = Reset_Handler; /* [1] reset */
|
g_hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */
|
||||||
for (index = 2; index < OS_VECTOR_CNT; index++) { /* 2: The starting position of the interrupt */
|
for (index = 2; index < OS_VECTOR_CNT; index++) { /* 2: The starting position of the interrupt */
|
||||||
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
|
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
|
||||||
}
|
}
|
||||||
/* Exception handler register */
|
/* Exception handler register */
|
||||||
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = HalExcNMI;
|
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
|
||||||
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = HalExcHardFault;
|
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
|
||||||
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = HalExcMemFault;
|
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
|
||||||
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcBusFault;
|
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
|
||||||
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcUsageFault;
|
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
|
||||||
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = HalSVCHandler;
|
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
|
||||||
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = HalPendSV;
|
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
|
||||||
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = SysTick_Handler;
|
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
|
||||||
|
|
||||||
/* Interrupt vector table location */
|
/* Interrupt vector table location */
|
||||||
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;
|
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
#include "los_debug.h"
|
#include "los_debug.h"
|
||||||
|
|
||||||
STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler);
|
STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler);
|
||||||
STATIC VOID SysTickReload(UINT64 nextResponseTime);
|
STATIC UINT64 SysTickReload(UINT64 nextResponseTime);
|
||||||
STATIC UINT64 SysTickCycleGet(UINT32 *period);
|
STATIC UINT64 SysTickCycleGet(UINT32 *period);
|
||||||
STATIC VOID SysTickLock(VOID);
|
STATIC VOID SysTickLock(VOID);
|
||||||
STATIC VOID SysTickUnlock(VOID);
|
STATIC VOID SysTickUnlock(VOID);
|
||||||
@@ -44,6 +44,7 @@ STATIC VOID SysTickUnlock(VOID);
|
|||||||
STATIC ArchTickTimer g_archTickTimer = {
|
STATIC ArchTickTimer g_archTickTimer = {
|
||||||
.freq = 0,
|
.freq = 0,
|
||||||
.irqNum = SysTick_IRQn,
|
.irqNum = SysTick_IRQn,
|
||||||
|
.periodMax = LOSCFG_BASE_CORE_TICK_RESPONSE_MAX,
|
||||||
.init = SysTickStart,
|
.init = SysTickStart,
|
||||||
.getCycle = SysTickCycleGet,
|
.getCycle = SysTickCycleGet,
|
||||||
.reload = SysTickReload,
|
.reload = SysTickReload,
|
||||||
@@ -75,13 +76,18 @@ STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler)
|
|||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC VOID SysTickReload(UINT64 nextResponseTime)
|
STATIC UINT64 SysTickReload(UINT64 nextResponseTime)
|
||||||
{
|
{
|
||||||
|
if (nextResponseTime > g_archTickTimer.periodMax) {
|
||||||
|
nextResponseTime = g_archTickTimer.periodMax;
|
||||||
|
}
|
||||||
|
|
||||||
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
|
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
|
||||||
SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */
|
SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */
|
||||||
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
|
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
|
||||||
NVIC_ClearPendingIRQ(SysTick_IRQn);
|
NVIC_ClearPendingIRQ(SysTick_IRQn);
|
||||||
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
|
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
|
||||||
|
return nextResponseTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC UINT64 SysTickCycleGet(UINT32 *period)
|
STATIC UINT64 SysTickCycleGet(UINT32 *period)
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ VOID HalSecureSVCHandler(UINT32 svcID, UINTPTR arg)
|
|||||||
HalSecureContextLoad(g_secureContext);
|
HalSecureContextLoad(g_secureContext);
|
||||||
break;
|
break;
|
||||||
case OS_SVC_FREE_SECURE_CONTEXT:
|
case OS_SVC_FREE_SECURE_CONTEXT:
|
||||||
|
LOS_ASSERT(g_secureContext != NULL);
|
||||||
HalSecureContextFree(g_secureContext);
|
HalSecureContextFree(g_secureContext);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
* Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
* are permitted provided that the following conditions are met:
|
* are permitted provided that the following conditions are met:
|
||||||
@@ -63,5 +63,3 @@ extern VOID HalSecureContextSaveAsm(OsSecureContext *secureContext);
|
|||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@
|
|||||||
#include "los_config.h"
|
#include "los_config.h"
|
||||||
#include "los_list.h"
|
#include "los_list.h"
|
||||||
|
|
||||||
#pragma data_alignment=0x4
|
#pragma data_alignment = 0x4
|
||||||
STATIC UINT8 g_secureHeap[LOSCFG_SECURE_HEAP_SIZE] = {0};
|
STATIC UINT8 g_secureHeap[LOSCFG_SECURE_HEAP_SIZE] = {0};
|
||||||
STATIC LOS_DL_LIST g_secureHeapFreeList = {NULL, NULL};
|
STATIC LOS_DL_LIST g_secureHeapFreeList = {NULL, NULL};
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ kernel_module(module_name) {
|
|||||||
"los_mpu.c",
|
"los_mpu.c",
|
||||||
"los_timer.c",
|
"los_timer.c",
|
||||||
]
|
]
|
||||||
|
configs += [ "$LITEOSTOPDIR:warn_config" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
config("public") {
|
config("public") {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
* Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
* are permitted provided that the following conditions are met:
|
* are permitted provided that the following conditions are met:
|
||||||
@@ -33,6 +33,7 @@
|
|||||||
#define _LOS_ARCH_ATOMIC_H
|
#define _LOS_ARCH_ATOMIC_H
|
||||||
|
|
||||||
#include "los_compiler.h"
|
#include "los_compiler.h"
|
||||||
|
#include "los_interrupt.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
@@ -43,15 +44,11 @@ extern "C" {
|
|||||||
STATIC INLINE INT32 ArchAtomicRead(const Atomic *v)
|
STATIC INLINE INT32 ArchAtomicRead(const Atomic *v)
|
||||||
{
|
{
|
||||||
INT32 val;
|
INT32 val;
|
||||||
UINT32 intSave;
|
|
||||||
|
|
||||||
intSave = LOS_IntLock();
|
__asm__ __volatile__("ldrex %0, [%1]\n"
|
||||||
|
|
||||||
__asm__ __volatile__("ldrex %0, [%1]\n"
|
|
||||||
: "=&r"(val)
|
: "=&r"(val)
|
||||||
: "r"(v)
|
: "r"(v)
|
||||||
: "cc");
|
: "cc");
|
||||||
LOS_IntRestore(intSave);
|
|
||||||
|
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
@@ -59,18 +56,14 @@ STATIC INLINE INT32 ArchAtomicRead(const Atomic *v)
|
|||||||
STATIC INLINE VOID ArchAtomicSet(Atomic *v, INT32 setVal)
|
STATIC INLINE VOID ArchAtomicSet(Atomic *v, INT32 setVal)
|
||||||
{
|
{
|
||||||
UINT32 status;
|
UINT32 status;
|
||||||
UINT32 intSave;
|
|
||||||
|
|
||||||
intSave = LOS_IntLock();
|
do {
|
||||||
|
__asm__ __volatile__("ldrex %0, [%1]\n"
|
||||||
__asm__ __volatile__("1:ldrex %0, [%1]\n"
|
"strex %0, %2, [%1]\n"
|
||||||
" strex %0, %2, [%1]\n"
|
: "=&r"(status)
|
||||||
" teq %0, #0\n"
|
: "r"(v), "r"(setVal)
|
||||||
" bne 1b"
|
: "cc");
|
||||||
: "=&r"(status)
|
} while (__builtin_expect(status != 0, 0));
|
||||||
: "r"(v), "r"(setVal)
|
|
||||||
: "cc");
|
|
||||||
LOS_IntRestore(intSave);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC INLINE INT32 ArchAtomicAdd(Atomic *v, INT32 addVal)
|
STATIC INLINE INT32 ArchAtomicAdd(Atomic *v, INT32 addVal)
|
||||||
@@ -79,9 +72,9 @@ STATIC INLINE INT32 ArchAtomicAdd(Atomic *v, INT32 addVal)
|
|||||||
UINT32 status;
|
UINT32 status;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
__asm__ __volatile__("ldrex %1, [%2]\n"
|
__asm__ __volatile__("ldrex %1, [%2]\n"
|
||||||
"add %1, %1, %3\n"
|
"add %1, %1, %3\n"
|
||||||
"strex %0, %1, [%2]"
|
"strex %0, %1, [%2]"
|
||||||
: "=&r"(status), "=&r"(val)
|
: "=&r"(status), "=&r"(val)
|
||||||
: "r"(v), "r"(addVal)
|
: "r"(v), "r"(addVal)
|
||||||
: "cc");
|
: "cc");
|
||||||
@@ -96,9 +89,9 @@ STATIC INLINE INT32 ArchAtomicSub(Atomic *v, INT32 subVal)
|
|||||||
UINT32 status;
|
UINT32 status;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
__asm__ __volatile__("ldrex %1, [%2]\n"
|
__asm__ __volatile__("ldrex %1, [%2]\n"
|
||||||
"sub %1, %1, %3\n"
|
"sub %1, %1, %3\n"
|
||||||
"strex %0, %1, [%2]"
|
"strex %0, %1, [%2]"
|
||||||
: "=&r"(status), "=&r"(val)
|
: "=&r"(status), "=&r"(val)
|
||||||
: "r"(v), "r"(subVal)
|
: "r"(v), "r"(subVal)
|
||||||
: "cc");
|
: "cc");
|
||||||
@@ -151,8 +144,8 @@ STATIC INLINE INT32 ArchAtomicXchg32bits(volatile INT32 *v, INT32 val)
|
|||||||
UINT32 status = 0;
|
UINT32 status = 0;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
__asm__ __volatile__("ldrex %0, [%3]\n"
|
__asm__ __volatile__("ldrex %0, [%3]\n"
|
||||||
"strex %1, %4, [%3]"
|
"strex %1, %4, [%3]"
|
||||||
: "=&r"(prevVal), "=&r"(status), "+m"(*v)
|
: "=&r"(prevVal), "=&r"(status), "+m"(*v)
|
||||||
: "r"(v), "r"(val)
|
: "r"(v), "r"(val)
|
||||||
: "cc");
|
: "cc");
|
||||||
@@ -186,12 +179,12 @@ STATIC INLINE BOOL ArchAtomicCmpXchg32bits(volatile INT32 *v, INT32 val, INT32 o
|
|||||||
UINT32 status = 0;
|
UINT32 status = 0;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
__asm__ __volatile__("1: ldrex %0, %2\n"
|
__asm__ __volatile__("ldrex %0, %2\n"
|
||||||
" mov %1, #0\n"
|
"mov %1, #0\n"
|
||||||
" cmp %0, %3\n"
|
"cmp %0, %3\n"
|
||||||
" bne 2f\n"
|
"bne 1f\n"
|
||||||
" strex %1, %4, %2\n"
|
"strex %1, %4, %2\n"
|
||||||
"2:"
|
"1:"
|
||||||
: "=&r"(prevVal), "=&r"(status), "+Q"(*v)
|
: "=&r"(prevVal), "=&r"(status), "+Q"(*v)
|
||||||
: "r"(oldVal), "r"(val)
|
: "r"(oldVal), "r"(val)
|
||||||
: "cc");
|
: "cc");
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
* Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
* are permitted provided that the following conditions are met:
|
* are permitted provided that the following conditions are met:
|
||||||
@@ -121,6 +121,29 @@ typedef struct TagTskContext {
|
|||||||
*/
|
*/
|
||||||
extern VOID HalStartToRun(VOID);
|
extern VOID HalStartToRun(VOID);
|
||||||
|
|
||||||
|
#if (LOSCFG_SECURE == 1)
|
||||||
|
/**
|
||||||
|
* @ingroup los_config
|
||||||
|
* @brief: User Task Stack Initialize.
|
||||||
|
*
|
||||||
|
* @par Description:
|
||||||
|
* This API is used to init a user task stack.
|
||||||
|
*
|
||||||
|
* @attention:
|
||||||
|
* <ul><li>None.</li></ul>
|
||||||
|
*
|
||||||
|
* @param: context [IN] Task context.
|
||||||
|
* @param: taskEntry [IN] Task entry function address.
|
||||||
|
* @param: stack [IN] Task stack address.
|
||||||
|
*
|
||||||
|
* @retval None.
|
||||||
|
*
|
||||||
|
* @par Dependency: <ul><li>los_config.h: the header file that contains the API declaration.</li></ul>
|
||||||
|
* @see None.
|
||||||
|
*/
|
||||||
|
extern VOID HalUserTaskStackInit(TaskContext *context, UINTPTR taskEntry, UINTPTR stack);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,7 +109,8 @@ extern UINT32 _BootVectors[];
|
|||||||
*
|
*
|
||||||
* Value: 0x02000900
|
* Value: 0x02000900
|
||||||
*
|
*
|
||||||
* Solution: Ensure that the interrupt number is valid. The value range of the interrupt number applicable for a Cortex-A7 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
|
* Solution: Ensure that the interrupt number is valid.
|
||||||
|
* The value range of the interrupt number applicable for a Cortex-M4 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
|
||||||
*/
|
*/
|
||||||
#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
|
#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
|
||||||
|
|
||||||
@@ -159,7 +160,8 @@ extern UINT32 _BootVectors[];
|
|||||||
*
|
*
|
||||||
* Value: 0x02000905
|
* Value: 0x02000905
|
||||||
*
|
*
|
||||||
* Solution: Ensure that the interrupt priority is valid. The value range of the interrupt priority applicable for a Cortex-A7 platform is [0,15].
|
* Solution: Ensure that the interrupt priority is valid.
|
||||||
|
* The value range of the interrupt priority applicable for a Cortex-M4 platform is [0,15].
|
||||||
*/
|
*/
|
||||||
#define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05)
|
#define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05)
|
||||||
|
|
||||||
@@ -169,7 +171,8 @@ extern UINT32 _BootVectors[];
|
|||||||
*
|
*
|
||||||
* Value: 0x02000906
|
* Value: 0x02000906
|
||||||
*
|
*
|
||||||
* Solution: The interrupt creation mode can be only set to OS_HWI_MODE_COMM or OS_HWI_MODE_FAST of which the value can be 0 or 1.
|
* Solution: The interrupt creation mode can be only set to OS_HWI_MODE_COMM or
|
||||||
|
* OS_HWI_MODE_FAST of which the value can be 0 or 1.
|
||||||
*/
|
*/
|
||||||
#define OS_ERRNO_HWI_MODE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x06)
|
#define OS_ERRNO_HWI_MODE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x06)
|
||||||
|
|
||||||
@@ -342,25 +345,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
|
|||||||
*/
|
*/
|
||||||
extern VOID HalInterrupt(VOID);
|
extern VOID HalInterrupt(VOID);
|
||||||
|
|
||||||
/* *
|
|
||||||
* @ingroup los_arch_interrupt
|
|
||||||
* @brief: Get an interrupt number.
|
|
||||||
*
|
|
||||||
* @par Description:
|
|
||||||
* This API is used to get the current interrupt number.
|
|
||||||
*
|
|
||||||
* @attention:
|
|
||||||
* <ul><li>None.</li></ul>
|
|
||||||
*
|
|
||||||
* @param: None.
|
|
||||||
*
|
|
||||||
* @retval: Interrupt Indexes number.
|
|
||||||
* @par Dependency:
|
|
||||||
* <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
|
|
||||||
* @see None.
|
|
||||||
*/
|
|
||||||
extern UINT32 HalIntNumGet(VOID);
|
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_arch_interrupt
|
* @ingroup los_arch_interrupt
|
||||||
* @brief: Default vector handling function.
|
* @brief: Default vector handling function.
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ LITE_OS_SEC_TEXT_INIT VOID ArchInit(VOID)
|
|||||||
**************************************************************************** */
|
**************************************************************************** */
|
||||||
LITE_OS_SEC_TEXT_MINOR VOID ArchSysExit(VOID)
|
LITE_OS_SEC_TEXT_MINOR VOID ArchSysExit(VOID)
|
||||||
{
|
{
|
||||||
LOS_IntLock();
|
(VOID)LOS_IntLock();
|
||||||
while (1) {
|
while (1) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -74,17 +74,7 @@ LITE_OS_SEC_TEXT_MINOR VOID ArchSysExit(VOID)
|
|||||||
**************************************************************************** */
|
**************************************************************************** */
|
||||||
LITE_OS_SEC_TEXT_INIT VOID *ArchTskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack)
|
LITE_OS_SEC_TEXT_INIT VOID *ArchTskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack)
|
||||||
{
|
{
|
||||||
TaskContext *context = NULL;
|
TaskContext *context = (TaskContext *)((UINTPTR)topStack + stackSize - sizeof(TaskContext));
|
||||||
errno_t result;
|
|
||||||
|
|
||||||
/* initialize the task stack, write magic num to stack top */
|
|
||||||
result = memset_s(topStack, stackSize, (INT32)(OS_TASK_STACK_INIT & 0xFF), stackSize);
|
|
||||||
if (result != EOK) {
|
|
||||||
printf("memset_s is failed:%s[%d]\r\n", __FUNCTION__, __LINE__);
|
|
||||||
}
|
|
||||||
*((UINT32 *)(topStack)) = OS_TASK_MAGIC_WORD;
|
|
||||||
|
|
||||||
context = (TaskContext *)(((UINTPTR)topStack + stackSize) - sizeof(TaskContext));
|
|
||||||
|
|
||||||
#if ((defined(__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
|
#if ((defined(__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
|
||||||
(defined(__FPU_USED) && (__FPU_USED == 1U)))
|
(defined(__FPU_USED) && (__FPU_USED == 1U)))
|
||||||
@@ -145,6 +135,28 @@ LITE_OS_SEC_TEXT_INIT VOID *ArchTskStackInit(UINT32 taskID, UINT32 stackSize, VO
|
|||||||
return (VOID *)context;
|
return (VOID *)context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VOID *ArchSignalContextInit(VOID *stackPointer, VOID *stackTop, UINTPTR sigHandler, UINT32 param)
|
||||||
|
{
|
||||||
|
UNUSED(stackTop);
|
||||||
|
TaskContext *context = (TaskContext *)((UINTPTR)stackPointer - sizeof(TaskContext));
|
||||||
|
(VOID)memset_s((VOID *)context, sizeof(TaskContext), 0, sizeof(TaskContext));
|
||||||
|
|
||||||
|
context->uwR0 = param;
|
||||||
|
context->uwPC = sigHandler;
|
||||||
|
context->uwxPSR = 0x01000000L; /* Thumb flag, always set 1 */
|
||||||
|
|
||||||
|
return (VOID *)context;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if (LOSCFG_SECURE == 1)
|
||||||
|
VOID HalUserTaskStackInit(TaskContext *context, UINTPTR taskEntry, UINTPTR stack)
|
||||||
|
{
|
||||||
|
context->uwR0 = stack;
|
||||||
|
context->uwPC = (UINT32)taskEntry;
|
||||||
|
context->uwxPSR = 0x01000000L; /* Thumb flag, always set 1 */
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
LITE_OS_SEC_TEXT_INIT UINT32 ArchStartSchedule(VOID)
|
LITE_OS_SEC_TEXT_INIT UINT32 ArchStartSchedule(VOID)
|
||||||
{
|
{
|
||||||
(VOID)LOS_IntLock();
|
(VOID)LOS_IntLock();
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
* Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
* are permitted provided that the following conditions are met:
|
* are permitted provided that the following conditions are met:
|
||||||
@@ -40,10 +40,25 @@
|
|||||||
.equ OS_NVIC_PENDSV_PRI, 0xF0F00000
|
.equ OS_NVIC_PENDSV_PRI, 0xF0F00000
|
||||||
.equ OS_NVIC_PENDSVSET, 0x10000000
|
.equ OS_NVIC_PENDSVSET, 0x10000000
|
||||||
.equ OS_TASK_STATUS_RUNNING, 0x0010
|
.equ OS_TASK_STATUS_RUNNING, 0x0010
|
||||||
|
.equ OS_CONTROL_FPCA_ENABLE, 0x4
|
||||||
|
.equ OS_CONTROL_KERNEL_MODE, 0x2
|
||||||
|
#if (LOSCFG_SECURE == 1)
|
||||||
|
.equ OS_CONTROL_USER_MODE, 0x3
|
||||||
|
.equ OS_TASK_FLAG_USER_TASK, 0x0200
|
||||||
|
#endif
|
||||||
|
|
||||||
.section .text
|
.section .text
|
||||||
.thumb
|
.thumb
|
||||||
|
|
||||||
|
.macro SIGNAL_CONTEXT_RESTORE
|
||||||
|
push {r12, lr}
|
||||||
|
blx OsSignalTaskContextRestore
|
||||||
|
pop {r12, lr}
|
||||||
|
cmp r0, #0
|
||||||
|
mov r1, r0
|
||||||
|
bne SignalContextRestore
|
||||||
|
.endm
|
||||||
|
|
||||||
.type HalStartToRun, %function
|
.type HalStartToRun, %function
|
||||||
.global HalStartToRun
|
.global HalStartToRun
|
||||||
HalStartToRun:
|
HalStartToRun:
|
||||||
@@ -54,7 +69,7 @@ HalStartToRun:
|
|||||||
ldr r5, =OS_NVIC_PENDSV_PRI
|
ldr r5, =OS_NVIC_PENDSV_PRI
|
||||||
str r5, [r4]
|
str r5, [r4]
|
||||||
|
|
||||||
mov r0, #2
|
mov r0, #OS_CONTROL_KERNEL_MODE
|
||||||
msr CONTROL, r0
|
msr CONTROL, r0
|
||||||
|
|
||||||
ldr r1, =g_losTask
|
ldr r1, =g_losTask
|
||||||
@@ -88,7 +103,6 @@ __DisabledFPU:
|
|||||||
|
|
||||||
.fnend
|
.fnend
|
||||||
|
|
||||||
|
|
||||||
.type ArchIntLock, %function
|
.type ArchIntLock, %function
|
||||||
.global ArchIntLock
|
.global ArchIntLock
|
||||||
ArchIntLock:
|
ArchIntLock:
|
||||||
@@ -133,10 +147,7 @@ ArchTaskSchedule:
|
|||||||
bx lr
|
bx lr
|
||||||
dsb
|
dsb
|
||||||
isb
|
isb
|
||||||
.fnend
|
.fnend
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.type HalPendSV, %function
|
.type HalPendSV, %function
|
||||||
.global HalPendSV
|
.global HalPendSV
|
||||||
@@ -148,6 +159,8 @@ HalPendSV:
|
|||||||
cpsid I
|
cpsid I
|
||||||
|
|
||||||
HalTaskSwitch:
|
HalTaskSwitch:
|
||||||
|
SIGNAL_CONTEXT_RESTORE
|
||||||
|
|
||||||
push {r12, lr}
|
push {r12, lr}
|
||||||
blx OsSchedTaskSwitch
|
blx OsSchedTaskSwitch
|
||||||
pop {r12, lr}
|
pop {r12, lr}
|
||||||
@@ -176,14 +189,25 @@ __DisabledFPU1:
|
|||||||
|
|
||||||
ldr r0, [r5, #4]
|
ldr r0, [r5, #4]
|
||||||
str r0, [r5]
|
str r0, [r5]
|
||||||
|
|
||||||
ldr r1, [r0]
|
ldr r1, [r0]
|
||||||
|
|
||||||
|
SignalContextRestore:
|
||||||
|
ldr.w r3, =OS_FPU_CPACR
|
||||||
|
ldr r3, [r3]
|
||||||
and r3, r3, #OS_FPU_CPACR_ENABLE
|
and r3, r3, #OS_FPU_CPACR_ENABLE
|
||||||
cmp r3, #OS_FPU_CPACR_ENABLE
|
cmp r3, #OS_FPU_CPACR_ENABLE
|
||||||
bne __DisabledFPU2
|
bne __DisabledFPU2
|
||||||
vldmia r1!, {d8-d15}
|
vldmia r1!, {d8-d15}
|
||||||
|
|
||||||
__DisabledFPU2:
|
__DisabledFPU2:
|
||||||
|
#if (LOSCFG_SECURE == 1)
|
||||||
|
ldrh r7, [r0, #4]
|
||||||
|
tst r7, #OS_TASK_FLAG_USER_TASK
|
||||||
|
ite eq
|
||||||
|
moveq r3, #OS_CONTROL_KERNEL_MODE
|
||||||
|
movne r3, #OS_CONTROL_USER_MODE
|
||||||
|
msr CONTROL, r3
|
||||||
|
#endif
|
||||||
ldmfd r1!, {r4-r12}
|
ldmfd r1!, {r4-r12}
|
||||||
msr psp, r1
|
msr psp, r1
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
* Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
* are permitted provided that the following conditions are met:
|
* are permitted provided that the following conditions are met:
|
||||||
@@ -57,15 +57,15 @@
|
|||||||
|
|
||||||
.equ FLAG_ADDR_VALID, 0x10000
|
.equ FLAG_ADDR_VALID, 0x10000
|
||||||
.equ FLAG_HWI_ACTIVE, 0x20000
|
.equ FLAG_HWI_ACTIVE, 0x20000
|
||||||
.equ FLAG_NO_FLOAT, 0x10000000
|
.equ FLAG_NO_FLOAT, 0x10000000
|
||||||
|
|
||||||
.equ OS_NVIC_FSR , 0xE000ED28 //include BusFault/MemFault/UsageFault State Register
|
.equ OS_NVIC_FSR, 0xE000ED28 //include BusFault/MemFault/UsageFault State Register
|
||||||
.equ OS_NVIC_HFSR , 0xE000ED2C //HardFault State Register
|
.equ OS_NVIC_HFSR, 0xE000ED2C //HardFault State Register
|
||||||
.equ OS_NVIC_BFAR , 0xE000ED38
|
.equ OS_NVIC_BFAR, 0xE000ED38
|
||||||
.equ OS_NVIC_MMAR , 0xE000ED34
|
.equ OS_NVIC_MMAR, 0xE000ED34
|
||||||
.equ OS_NVIC_ACT_BASE , 0xE000E300
|
.equ OS_NVIC_ACT_BASE, 0xE000E300
|
||||||
.equ OS_NVIC_SHCSRS , 0xE000ED24
|
.equ OS_NVIC_SHCSRS, 0xE000ED24
|
||||||
.equ OS_NVIC_SHCSR_MASK , 0xC00
|
.equ OS_NVIC_SHCSR_MASK, 0xC00
|
||||||
|
|
||||||
.type HalExcNMI, %function
|
.type HalExcNMI, %function
|
||||||
.global HalExcNMI
|
.global HalExcNMI
|
||||||
@@ -155,10 +155,25 @@ HalExcSvcCall:
|
|||||||
.cantunwind
|
.cantunwind
|
||||||
TST LR, #0x4
|
TST LR, #0x4
|
||||||
ITE EQ
|
ITE EQ
|
||||||
MRSEQ R0, MSP
|
MRSEQ R1, MSP
|
||||||
MRSNE R0, PSP
|
BNE _svcCallFromPsp
|
||||||
LDR R1, [R0,#24]
|
B _svcCall
|
||||||
LDRB R0, [R1,#-2]
|
_svcCallFromPsp:
|
||||||
|
#ifdef LOSCFG_SECURE
|
||||||
|
PUSH {R0-R12, LR}
|
||||||
|
MOV R0, SP
|
||||||
|
CPSIE I
|
||||||
|
BL OsSyscallHandle
|
||||||
|
CPSID I
|
||||||
|
MRS R12, PSP
|
||||||
|
STM R12, {R0-R1}
|
||||||
|
POP {R0-R12, LR}
|
||||||
|
BX LR
|
||||||
|
#endif
|
||||||
|
MRS R1, PSP
|
||||||
|
_svcCall:
|
||||||
|
LDR R0, [R1,#24]
|
||||||
|
LDRB R0, [R0,#-2]
|
||||||
MOV R1, #0
|
MOV R1, #0
|
||||||
B osExcDispatch
|
B osExcDispatch
|
||||||
.fnend
|
.fnend
|
||||||
@@ -263,7 +278,7 @@ _hwiActiveCheck:
|
|||||||
CMP R3, #0
|
CMP R3, #0
|
||||||
BEQ _hwiActiveCheckNext
|
BEQ _hwiActiveCheckNext
|
||||||
|
|
||||||
// exc occured in IRQ
|
// exc occurred in IRQ
|
||||||
ORR R0, R0, #FLAG_HWI_ACTIVE
|
ORR R0, R0, #FLAG_HWI_ACTIVE
|
||||||
RBIT R2, R3
|
RBIT R2, R3
|
||||||
CLZ R2, R2
|
CLZ R2, R2
|
||||||
@@ -284,7 +299,7 @@ _ExcInMSP:
|
|||||||
PUSH {R4-R12} // store message-->exc: {R4-R12}
|
PUSH {R4-R12} // store message-->exc: {R4-R12}
|
||||||
VPUSH {D8-D15} // FPU
|
VPUSH {D8-D15} // FPU
|
||||||
B _handleEntry
|
B _handleEntry
|
||||||
.fnend
|
.fnend
|
||||||
|
|
||||||
.type _NoFloatInMsp, %function
|
.type _NoFloatInMsp, %function
|
||||||
.global _NoFloatInMsp
|
.global _NoFloatInMsp
|
||||||
@@ -298,7 +313,7 @@ _NoFloatInMsp:
|
|||||||
PUSH {R4-R12} // store message-->exc: {R4-R12}
|
PUSH {R4-R12} // store message-->exc: {R4-R12}
|
||||||
ORR R0, R0, #FLAG_NO_FLOAT
|
ORR R0, R0, #FLAG_NO_FLOAT
|
||||||
B _handleEntry
|
B _handleEntry
|
||||||
.fnend
|
.fnend
|
||||||
|
|
||||||
.type _hwiActiveCheckNext, %function
|
.type _hwiActiveCheckNext, %function
|
||||||
.global _hwiActiveCheckNext
|
.global _hwiActiveCheckNext
|
||||||
@@ -316,19 +331,19 @@ _hwiActiveCheckNext:
|
|||||||
AND R2, R2,R3
|
AND R2, R2,R3
|
||||||
CMP R2,#0
|
CMP R2,#0
|
||||||
BNE _ExcInMSP
|
BNE _ExcInMSP
|
||||||
// exc occured in Task or Init or exc
|
// exc occurred in Task or Init or exc
|
||||||
// reserved for register info from task stack
|
// reserved for register info from task stack
|
||||||
|
|
||||||
LDR R2, =g_taskScheduled
|
LDR R2, =g_taskScheduled
|
||||||
LDR R2, [R2]
|
LDR R2, [R2]
|
||||||
TST R2, #1 // OS_FLG_BGD_ACTIVE
|
TST R2, #1 // OS_FLG_BGD_ACTIVE
|
||||||
BEQ _ExcInMSP // if exc occured in Init then branch
|
BEQ _ExcInMSP // if exc occurred in Init then branch
|
||||||
|
|
||||||
|
|
||||||
CMP LR, #0xFFFFFFED //auto push floating registers
|
CMP LR, #0xFFFFFFED //auto push floating registers
|
||||||
BNE _NoFloatInPsp
|
BNE _NoFloatInPsp
|
||||||
|
|
||||||
// exc occured in Task
|
// exc occurred in Task
|
||||||
MOV R2, R13
|
MOV R2, R13
|
||||||
SUB R13, #96 // add 8 Bytes reg(for STMFD)
|
SUB R13, #96 // add 8 Bytes reg(for STMFD)
|
||||||
|
|
||||||
@@ -347,7 +362,7 @@ _hwiActiveCheckNext:
|
|||||||
VSTMDB R2!, {D8-D15} // FPU
|
VSTMDB R2!, {D8-D15} // FPU
|
||||||
STMFD R2!, {R4-R11}
|
STMFD R2!, {R4-R11}
|
||||||
B _handleEntry
|
B _handleEntry
|
||||||
.fnend
|
.fnend
|
||||||
|
|
||||||
.type _NoFloatInPsp, %function
|
.type _NoFloatInPsp, %function
|
||||||
.global _NoFloatInPsp
|
.global _NoFloatInPsp
|
||||||
@@ -367,7 +382,7 @@ _NoFloatInPsp:
|
|||||||
LDMFD R3, {R4-R11} // R4-R11 store PSP reg(auto push when exc in task)
|
LDMFD R3, {R4-R11} // R4-R11 store PSP reg(auto push when exc in task)
|
||||||
STMFD R2!, {R4-R11}
|
STMFD R2!, {R4-R11}
|
||||||
ORR R0, R0, #FLAG_NO_FLOAT
|
ORR R0, R0, #FLAG_NO_FLOAT
|
||||||
.fnend
|
.fnend
|
||||||
|
|
||||||
.type _handleEntry, %function
|
.type _handleEntry, %function
|
||||||
.global _handleEntry
|
.global _handleEntry
|
||||||
@@ -380,4 +395,4 @@ _handleEntry:
|
|||||||
B HalExcHandleEntry
|
B HalExcHandleEntry
|
||||||
|
|
||||||
NOP
|
NOP
|
||||||
.fnend
|
.fnend
|
||||||
|
|||||||
@@ -39,18 +39,42 @@
|
|||||||
#include "los_sched.h"
|
#include "los_sched.h"
|
||||||
#include "los_memory.h"
|
#include "los_memory.h"
|
||||||
#include "los_membox.h"
|
#include "los_membox.h"
|
||||||
|
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
|
||||||
|
#include "los_cpup.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
/*lint -save -e40 -e522 -e533*/
|
|
||||||
UINT32 g_intCount = 0;
|
UINT32 g_intCount = 0;
|
||||||
|
|
||||||
/*lint -restore*/
|
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_hwi
|
||||||
* Hardware interrupt form mapping handling function array.
|
* Hardware interrupt form mapping handling function array.
|
||||||
*/
|
*/
|
||||||
STATIC HWI_PROC_FUNC __attribute__((aligned(LOSCFG_ARCH_HWI_VECTOR_ALIGN))) g_hwiForm[OS_VECTOR_CNT] = {0};
|
STATIC HWI_PROC_FUNC __attribute__((aligned(LOSCFG_ARCH_HWI_VECTOR_ALIGN))) g_hwiForm[OS_VECTOR_CNT] = {0};
|
||||||
|
|
||||||
|
#if (LOSCFG_DEBUG_TOOLS == 1)
|
||||||
|
STATIC UINT32 g_hwiFormCnt[OS_HWI_MAX_NUM] = {0};
|
||||||
|
STATIC CHAR *g_hwiFormName[OS_HWI_MAX_NUM] = {0};
|
||||||
|
|
||||||
|
UINT32 OsGetHwiFormCnt(UINT32 index)
|
||||||
|
{
|
||||||
|
return g_hwiFormCnt[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
CHAR *OsGetHwiFormName(UINT32 index)
|
||||||
|
{
|
||||||
|
return g_hwiFormName[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL OsGetHwiCreated(UINT32 index)
|
||||||
|
{
|
||||||
|
if (g_hwiForm[index] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
|
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -103,17 +127,85 @@ WEAK VOID SysTick_Handler(VOID)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ****************************************************************************
|
/* ****************************************************************************
|
||||||
Function : HalIntNumGet
|
Function : HwiNumGet
|
||||||
Description : Get an interrupt number
|
Description : Get an interrupt number
|
||||||
Input : None
|
Input : None
|
||||||
Output : None
|
Output : None
|
||||||
Return : Interrupt Indexes number
|
Return : Interrupt Indexes number
|
||||||
**************************************************************************** */
|
**************************************************************************** */
|
||||||
LITE_OS_SEC_TEXT_MINOR UINT32 HalIntNumGet(VOID)
|
STATIC UINT32 HwiNumGet(VOID)
|
||||||
{
|
{
|
||||||
return __get_IPSR();
|
return __get_IPSR();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
|
||||||
|
{
|
||||||
|
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||||
|
return OS_ERRNO_HWI_NUM_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
|
||||||
|
{
|
||||||
|
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||||
|
return OS_ERRNO_HWI_NUM_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
NVIC_DisableIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority)
|
||||||
|
{
|
||||||
|
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||||
|
return OS_ERRNO_HWI_NUM_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (priority > OS_HWI_PRIO_LOWEST) {
|
||||||
|
return OS_ERRNO_HWI_PRIO_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
NVIC_SetPriority((IRQn_Type)hwiNum, priority);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
|
||||||
|
{
|
||||||
|
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||||
|
return OS_ERRNO_HWI_NUM_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
|
||||||
|
{
|
||||||
|
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||||
|
return OS_ERRNO_HWI_NUM_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
HwiControllerOps g_archHwiOps = {
|
||||||
|
.enableIrq = HwiUnmask,
|
||||||
|
.disableIrq = HwiMask,
|
||||||
|
.setIrqPriority = HwiSetPriority,
|
||||||
|
.getCurIrqNum = HwiNumGet,
|
||||||
|
.triggerIrq = HwiPending,
|
||||||
|
.clearIrq = HwiClear,
|
||||||
|
};
|
||||||
|
|
||||||
inline UINT32 ArchIsIntActive(VOID)
|
inline UINT32 ArchIsIntActive(VOID)
|
||||||
{
|
{
|
||||||
return (g_intCount > 0);
|
return (g_intCount > 0);
|
||||||
@@ -125,21 +217,21 @@ inline UINT32 ArchIsIntActive(VOID)
|
|||||||
Output : None
|
Output : None
|
||||||
Return : None
|
Return : None
|
||||||
**************************************************************************** */
|
**************************************************************************** */
|
||||||
/*lint -e529*/
|
|
||||||
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
|
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
|
||||||
{
|
{
|
||||||
UINT32 irqNum = HalIntNumGet();
|
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet());
|
||||||
PRINT_ERR("%s irqnum:%d\n", __FUNCTION__, irqNum);
|
|
||||||
while (1) {}
|
while (1) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
WEAK VOID HalPreInterruptHandler(UINT32 arg)
|
WEAK VOID HalPreInterruptHandler(UINT32 arg)
|
||||||
{
|
{
|
||||||
|
(VOID)arg;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
WEAK VOID HalAftInterruptHandler(UINT32 arg)
|
WEAK VOID HalAftInterruptHandler(UINT32 arg)
|
||||||
{
|
{
|
||||||
|
(VOID)arg;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,9 +255,12 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
|
|||||||
g_intCount++;
|
g_intCount++;
|
||||||
LOS_IntRestore(intSave);
|
LOS_IntRestore(intSave);
|
||||||
|
|
||||||
hwiIndex = HalIntNumGet();
|
hwiIndex = HwiNumGet();
|
||||||
|
|
||||||
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
|
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
|
||||||
|
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
|
||||||
|
OsCpupIrqStart(hwiIndex);
|
||||||
|
#endif
|
||||||
|
|
||||||
HalPreInterruptHandler(hwiIndex);
|
HalPreInterruptHandler(hwiIndex);
|
||||||
|
|
||||||
@@ -179,8 +274,16 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if (LOSCFG_DEBUG_TOOLS == 1)
|
||||||
|
++g_hwiFormCnt[hwiIndex];
|
||||||
|
#endif
|
||||||
|
|
||||||
HalAftInterruptHandler(hwiIndex);
|
HalAftInterruptHandler(hwiIndex);
|
||||||
|
|
||||||
|
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
|
||||||
|
OsCpupIrqEnd(hwiIndex);
|
||||||
|
#endif
|
||||||
|
|
||||||
OsHookCall(LOS_HOOK_TYPE_ISR_EXIT, hwiIndex);
|
OsHookCall(LOS_HOOK_TYPE_ISR_EXIT, hwiIndex);
|
||||||
|
|
||||||
intSave = LOS_IntLock();
|
intSave = LOS_IntLock();
|
||||||
@@ -193,21 +296,22 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
|
|||||||
Description : create hardware interrupt
|
Description : create hardware interrupt
|
||||||
Input : hwiNum --- hwi num to create
|
Input : hwiNum --- hwi num to create
|
||||||
hwiPrio --- priority of the hwi
|
hwiPrio --- priority of the hwi
|
||||||
mode --- unused
|
hwiMode --- unused
|
||||||
handler --- hwi handler
|
hwiHandler --- hwi handler
|
||||||
arg --- param of the hwi handler
|
irqParam --- param of the hwi handler
|
||||||
Output : None
|
Output : None
|
||||||
Return : LOS_OK on success or error code on failure
|
Return : LOS_OK on success or error code on failure
|
||||||
**************************************************************************** */
|
**************************************************************************** */
|
||||||
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
||||||
HWI_PRIOR_T hwiPrio,
|
HWI_PRIOR_T hwiPrio,
|
||||||
HWI_MODE_T mode,
|
HWI_MODE_T hwiMode,
|
||||||
HWI_PROC_FUNC handler,
|
HWI_PROC_FUNC hwiHandler,
|
||||||
HWI_ARG_T arg)
|
HwiIrqParam *irqParam)
|
||||||
{
|
{
|
||||||
|
(VOID)hwiMode;
|
||||||
UINT32 intSave;
|
UINT32 intSave;
|
||||||
|
|
||||||
if (handler == NULL) {
|
if (hwiHandler == NULL) {
|
||||||
return OS_ERRNO_HWI_PROC_FUNC_NULL;
|
return OS_ERRNO_HWI_PROC_FUNC_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -225,12 +329,25 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
|||||||
|
|
||||||
intSave = LOS_IntLock();
|
intSave = LOS_IntLock();
|
||||||
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
|
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
|
||||||
OsSetVector(hwiNum, handler, arg);
|
if (irqParam != NULL) {
|
||||||
|
OsSetVector(hwiNum, hwiHandler, irqParam->pDevId);
|
||||||
|
} else {
|
||||||
|
OsSetVector(hwiNum, hwiHandler, NULL);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
OsSetVector(hwiNum, handler);
|
(VOID)irqParam;
|
||||||
|
OsSetVector(hwiNum, hwiHandler);
|
||||||
#endif
|
#endif
|
||||||
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
|
||||||
NVIC_SetPriority((IRQn_Type)hwiNum, hwiPrio);
|
#if (LOSCFG_DEBUG_TOOLS == 1)
|
||||||
|
if ((irqParam != NULL) && (irqParam->pName != NULL)) {
|
||||||
|
g_hwiFormName[hwiNum + OS_SYS_VECTOR_CNT] = (CHAR *)irqParam->pName;
|
||||||
|
}
|
||||||
|
g_hwiFormCnt[hwiNum + OS_SYS_VECTOR_CNT] = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
HwiUnmask((IRQn_Type)hwiNum);
|
||||||
|
HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
|
||||||
|
|
||||||
LOS_IntRestore(intSave);
|
LOS_IntRestore(intSave);
|
||||||
|
|
||||||
@@ -241,18 +358,20 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
|||||||
Function : ArchHwiDelete
|
Function : ArchHwiDelete
|
||||||
Description : Delete hardware interrupt
|
Description : Delete hardware interrupt
|
||||||
Input : hwiNum --- hwi num to delete
|
Input : hwiNum --- hwi num to delete
|
||||||
|
irqParam --- param of the hwi handler
|
||||||
Output : None
|
Output : None
|
||||||
Return : LOS_OK on success or error code on failure
|
Return : LOS_OK on success or error code on failure
|
||||||
**************************************************************************** */
|
**************************************************************************** */
|
||||||
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum)
|
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam)
|
||||||
{
|
{
|
||||||
|
(VOID)irqParam;
|
||||||
UINT32 intSave;
|
UINT32 intSave;
|
||||||
|
|
||||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
return OS_ERRNO_HWI_NUM_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
NVIC_DisableIRQ((IRQn_Type)hwiNum);
|
HwiMask((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
intSave = LOS_IntLock();
|
intSave = LOS_IntLock();
|
||||||
|
|
||||||
@@ -373,6 +492,7 @@ STATIC VOID OsExcRegInfo(const ExcInfo *excInfo)
|
|||||||
PRINTK("xPSR = 0x%x\n", excInfo->context->uwxPSR);
|
PRINTK("xPSR = 0x%x\n", excInfo->context->uwxPSR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if (LOSCFG_KERNEL_BACKTRACE == 1)
|
||||||
STATIC VOID OsExcBackTraceInfo(const ExcInfo *excInfo)
|
STATIC VOID OsExcBackTraceInfo(const ExcInfo *excInfo)
|
||||||
{
|
{
|
||||||
UINTPTR LR[LOSCFG_BACKTRACE_DEPTH] = {0};
|
UINTPTR LR[LOSCFG_BACKTRACE_DEPTH] = {0};
|
||||||
@@ -389,6 +509,7 @@ STATIC VOID OsExcBackTraceInfo(const ExcInfo *excInfo)
|
|||||||
}
|
}
|
||||||
PRINTK("----- backtrace end -----\n");
|
PRINTK("----- backtrace end -----\n");
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
STATIC VOID OsExcMemPoolCheckInfo(VOID)
|
STATIC VOID OsExcMemPoolCheckInfo(VOID)
|
||||||
{
|
{
|
||||||
@@ -438,7 +559,9 @@ STATIC VOID OsExcInfoDisplay(const ExcInfo *excInfo)
|
|||||||
OsExcTypeInfo(excInfo);
|
OsExcTypeInfo(excInfo);
|
||||||
OsExcCurTaskInfo(excInfo);
|
OsExcCurTaskInfo(excInfo);
|
||||||
OsExcRegInfo(excInfo);
|
OsExcRegInfo(excInfo);
|
||||||
|
#if (LOSCFG_KERNEL_BACKTRACE == 1)
|
||||||
OsExcBackTraceInfo(excInfo);
|
OsExcBackTraceInfo(excInfo);
|
||||||
|
#endif
|
||||||
OsGetAllTskInfo();
|
OsGetAllTskInfo();
|
||||||
OsExcNvicDump();
|
OsExcNvicDump();
|
||||||
OsExcMemPoolCheckInfo();
|
OsExcMemPoolCheckInfo();
|
||||||
@@ -503,19 +626,19 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
|
|||||||
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
|
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
|
||||||
UINT32 index;
|
UINT32 index;
|
||||||
g_hwiForm[0] = 0; /* [0] Top of Stack */
|
g_hwiForm[0] = 0; /* [0] Top of Stack */
|
||||||
g_hwiForm[1] = Reset_Handler; /* [1] reset */
|
g_hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */
|
||||||
for (index = 2; index < OS_VECTOR_CNT; index++) { /* 2: The starting position of the interrupt */
|
for (index = 2; index < OS_VECTOR_CNT; index++) { /* 2: The starting position of the interrupt */
|
||||||
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
|
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
|
||||||
}
|
}
|
||||||
/* Exception handler register */
|
/* Exception handler register */
|
||||||
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = HalExcNMI;
|
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
|
||||||
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = HalExcHardFault;
|
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
|
||||||
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = HalExcMemFault;
|
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
|
||||||
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcBusFault;
|
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
|
||||||
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcUsageFault;
|
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
|
||||||
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = HalExcSvcCall;
|
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcSvcCall;
|
||||||
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = HalPendSV;
|
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
|
||||||
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = SysTick_Handler;
|
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
|
||||||
|
|
||||||
/* Interrupt vector table location */
|
/* Interrupt vector table location */
|
||||||
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;
|
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;
|
||||||
@@ -526,7 +649,7 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
|
|||||||
|
|
||||||
/* Enable USGFAULT, BUSFAULT, MEMFAULT */
|
/* Enable USGFAULT, BUSFAULT, MEMFAULT */
|
||||||
*(volatile UINT32 *)OS_NVIC_SHCSR |= (USGFAULT | BUSFAULT | MEMFAULT);
|
*(volatile UINT32 *)OS_NVIC_SHCSR |= (USGFAULT | BUSFAULT | MEMFAULT);
|
||||||
|
|
||||||
/* Enable DIV 0 and unaligned exception */
|
/* Enable DIV 0 and unaligned exception */
|
||||||
#ifdef LOSCFG_ARCH_UNALIGNED_EXC
|
#ifdef LOSCFG_ARCH_UNALIGNED_EXC
|
||||||
*(volatile UINT32 *)OS_NVIC_CCR |= (DIV0FAULT | UNALIGNFAULT);
|
*(volatile UINT32 *)OS_NVIC_CCR |= (DIV0FAULT | UNALIGNFAULT);
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
#include "los_debug.h"
|
#include "los_debug.h"
|
||||||
|
|
||||||
STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler);
|
STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler);
|
||||||
STATIC VOID SysTickReload(UINT64 nextResponseTime);
|
STATIC UINT64 SysTickReload(UINT64 nextResponseTime);
|
||||||
STATIC UINT64 SysTickCycleGet(UINT32 *period);
|
STATIC UINT64 SysTickCycleGet(UINT32 *period);
|
||||||
STATIC VOID SysTickLock(VOID);
|
STATIC VOID SysTickLock(VOID);
|
||||||
STATIC VOID SysTickUnlock(VOID);
|
STATIC VOID SysTickUnlock(VOID);
|
||||||
@@ -44,6 +44,7 @@ STATIC VOID SysTickUnlock(VOID);
|
|||||||
STATIC ArchTickTimer g_archTickTimer = {
|
STATIC ArchTickTimer g_archTickTimer = {
|
||||||
.freq = 0,
|
.freq = 0,
|
||||||
.irqNum = SysTick_IRQn,
|
.irqNum = SysTick_IRQn,
|
||||||
|
.periodMax = LOSCFG_BASE_CORE_TICK_RESPONSE_MAX,
|
||||||
.init = SysTickStart,
|
.init = SysTickStart,
|
||||||
.getCycle = SysTickCycleGet,
|
.getCycle = SysTickCycleGet,
|
||||||
.reload = SysTickReload,
|
.reload = SysTickReload,
|
||||||
@@ -75,13 +76,17 @@ STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler)
|
|||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC VOID SysTickReload(UINT64 nextResponseTime)
|
STATIC UINT64 SysTickReload(UINT64 nextResponseTime)
|
||||||
{
|
{
|
||||||
|
if (nextResponseTime > g_archTickTimer.periodMax) {
|
||||||
|
nextResponseTime = g_archTickTimer.periodMax;
|
||||||
|
}
|
||||||
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
|
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
|
||||||
SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */
|
SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */
|
||||||
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
|
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
|
||||||
NVIC_ClearPendingIRQ(SysTick_IRQn);
|
NVIC_ClearPendingIRQ(SysTick_IRQn);
|
||||||
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
|
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
|
||||||
|
return nextResponseTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC UINT64 SysTickCycleGet(UINT32 *period)
|
STATIC UINT64 SysTickCycleGet(UINT32 *period)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
* Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
* are permitted provided that the following conditions are met:
|
* are permitted provided that the following conditions are met:
|
||||||
@@ -33,6 +33,7 @@
|
|||||||
#define _LOS_ARCH_ATOMIC_H
|
#define _LOS_ARCH_ATOMIC_H
|
||||||
|
|
||||||
#include "los_compiler.h"
|
#include "los_compiler.h"
|
||||||
|
#include "los_interrupt.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
@@ -43,15 +44,11 @@ extern "C" {
|
|||||||
STATIC INLINE INT32 ArchAtomicRead(const Atomic *v)
|
STATIC INLINE INT32 ArchAtomicRead(const Atomic *v)
|
||||||
{
|
{
|
||||||
INT32 val;
|
INT32 val;
|
||||||
UINT32 intSave;
|
|
||||||
|
|
||||||
intSave = LOS_IntLock();
|
asm volatile("ldrex %0, [%1]\n"
|
||||||
|
: "=&r"(val)
|
||||||
__asm__ __volatile__("ldrex %0, [%1]\n"
|
: "r"(v)
|
||||||
: "=&r"(val)
|
: "cc");
|
||||||
: "r"(v)
|
|
||||||
: "cc");
|
|
||||||
LOS_IntRestore(intSave);
|
|
||||||
|
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
@@ -59,18 +56,14 @@ STATIC INLINE INT32 ArchAtomicRead(const Atomic *v)
|
|||||||
STATIC INLINE VOID ArchAtomicSet(Atomic *v, INT32 setVal)
|
STATIC INLINE VOID ArchAtomicSet(Atomic *v, INT32 setVal)
|
||||||
{
|
{
|
||||||
UINT32 status;
|
UINT32 status;
|
||||||
UINT32 intSave;
|
|
||||||
|
|
||||||
intSave = LOS_IntLock();
|
asm volatile("1:ldrex %0, [%1]\n"
|
||||||
|
" strex %0, %2, [%1]\n"
|
||||||
__asm__ __volatile__("1:ldrex %0, [%1]\n"
|
" teq %0, #0\n"
|
||||||
" strex %0, %2, [%1]\n"
|
" bne 1b"
|
||||||
" teq %0, #0\n"
|
: "=&r"(status)
|
||||||
" bne 1b"
|
: "r"(v), "r"(setVal)
|
||||||
: "=&r"(status)
|
: "cc");
|
||||||
: "r"(v), "r"(setVal)
|
|
||||||
: "cc");
|
|
||||||
LOS_IntRestore(intSave);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC INLINE INT32 ArchAtomicAdd(Atomic *v, INT32 addVal)
|
STATIC INLINE INT32 ArchAtomicAdd(Atomic *v, INT32 addVal)
|
||||||
@@ -79,13 +72,13 @@ STATIC INLINE INT32 ArchAtomicAdd(Atomic *v, INT32 addVal)
|
|||||||
UINT32 status;
|
UINT32 status;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
__asm__ __volatile__("ldrex %1, [%2]\n"
|
asm volatile("ldrex %1, [%2]\n"
|
||||||
"add %1, %1, %3\n"
|
"add %1, %1, %3\n"
|
||||||
"strex %0, %1, [%2]"
|
"strex %0, %1, [%2]"
|
||||||
: "=&r"(status), "=&r"(val)
|
: "=&r"(status), "=&r"(val)
|
||||||
: "r"(v), "r"(addVal)
|
: "r"(v), "r"(addVal)
|
||||||
: "cc");
|
: "cc");
|
||||||
} while (__builtin_expect(status != 0, 0));
|
} while (status != 0);
|
||||||
|
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
@@ -96,13 +89,13 @@ STATIC INLINE INT32 ArchAtomicSub(Atomic *v, INT32 subVal)
|
|||||||
UINT32 status;
|
UINT32 status;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
__asm__ __volatile__("ldrex %1, [%2]\n"
|
asm volatile("ldrex %1, [%2]\n"
|
||||||
"sub %1, %1, %3\n"
|
"sub %1, %1, %3\n"
|
||||||
"strex %0, %1, [%2]"
|
"strex %0, %1, [%2]"
|
||||||
: "=&r"(status), "=&r"(val)
|
: "=&r"(status), "=&r"(val)
|
||||||
: "r"(v), "r"(subVal)
|
: "r"(v), "r"(subVal)
|
||||||
: "cc");
|
: "cc");
|
||||||
} while (__builtin_expect(status != 0, 0));
|
} while (status != 0);
|
||||||
|
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
@@ -151,12 +144,12 @@ STATIC INLINE INT32 ArchAtomicXchg32bits(volatile INT32 *v, INT32 val)
|
|||||||
UINT32 status = 0;
|
UINT32 status = 0;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
__asm__ __volatile__("ldrex %0, [%3]\n"
|
asm volatile("ldrex %0, [%2]\n"
|
||||||
"strex %1, %4, [%3]"
|
"strex %1, %3, [%2]"
|
||||||
: "=&r"(prevVal), "=&r"(status), "+m"(*v)
|
: "=&r"(prevVal), "=&r"(status)
|
||||||
: "r"(v), "r"(val)
|
: "r"(v), "r"(val)
|
||||||
: "cc");
|
: "cc");
|
||||||
} while (__builtin_expect(status != 0, 0));
|
} while (status != 0);
|
||||||
|
|
||||||
return prevVal;
|
return prevVal;
|
||||||
}
|
}
|
||||||
@@ -186,16 +179,16 @@ STATIC INLINE BOOL ArchAtomicCmpXchg32bits(volatile INT32 *v, INT32 val, INT32 o
|
|||||||
UINT32 status = 0;
|
UINT32 status = 0;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
__asm__ __volatile__("1: ldrex %0, %2\n"
|
asm volatile("ldrex %0, [%2]\n"
|
||||||
" mov %1, #0\n"
|
"mov %1, #0\n"
|
||||||
" cmp %0, %3\n"
|
"cmp %0, %3\n"
|
||||||
" bne 2f\n"
|
"bne 1f\n"
|
||||||
" strex %1, %4, %2\n"
|
"strex %1, %4, [%2]\n"
|
||||||
"2:"
|
"1:"
|
||||||
: "=&r"(prevVal), "=&r"(status), "+Q"(*v)
|
: "=&r"(prevVal), "=&r"(status)
|
||||||
: "r"(oldVal), "r"(val)
|
: "r"(v), "r"(oldVal), "r"(val)
|
||||||
: "cc");
|
: "cc");
|
||||||
} while (__builtin_expect(status != 0, 0));
|
} while (status != 0);
|
||||||
|
|
||||||
return prevVal != oldVal;
|
return prevVal != oldVal;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,7 +109,8 @@ extern UINT32 _BootVectors[];
|
|||||||
*
|
*
|
||||||
* Value: 0x02000900
|
* Value: 0x02000900
|
||||||
*
|
*
|
||||||
* Solution: Ensure that the interrupt number is valid. The value range of the interrupt number applicable for a Cortex-A7 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
|
* Solution: Ensure that the interrupt number is valid.
|
||||||
|
* The value range of the interrupt number applicable for a Cortex-M4 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
|
||||||
*/
|
*/
|
||||||
#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
|
#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
|
||||||
|
|
||||||
@@ -159,7 +160,8 @@ extern UINT32 _BootVectors[];
|
|||||||
*
|
*
|
||||||
* Value: 0x02000905
|
* Value: 0x02000905
|
||||||
*
|
*
|
||||||
* Solution: Ensure that the interrupt priority is valid. The value range of the interrupt priority applicable for a Cortex-A7 platform is [0,15].
|
* Solution: Ensure that the interrupt priority is valid.
|
||||||
|
* The value range of the interrupt priority applicable for a Cortex-M4 platform is [0,15].
|
||||||
*/
|
*/
|
||||||
#define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05)
|
#define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05)
|
||||||
|
|
||||||
@@ -169,7 +171,8 @@ extern UINT32 _BootVectors[];
|
|||||||
*
|
*
|
||||||
* Value: 0x02000906
|
* Value: 0x02000906
|
||||||
*
|
*
|
||||||
* Solution: The interrupt creation mode can be only set to OS_HWI_MODE_COMM or OS_HWI_MODE_FAST of which the value can be 0 or 1.
|
* Solution: The interrupt creation mode can be only set to OS_HWI_MODE_COMM or
|
||||||
|
* OS_HWI_MODE_FAST of which the value can be 0 or 1.
|
||||||
*/
|
*/
|
||||||
#define OS_ERRNO_HWI_MODE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x06)
|
#define OS_ERRNO_HWI_MODE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x06)
|
||||||
|
|
||||||
@@ -342,25 +345,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
|
|||||||
*/
|
*/
|
||||||
extern VOID HalInterrupt(VOID);
|
extern VOID HalInterrupt(VOID);
|
||||||
|
|
||||||
/* *
|
|
||||||
* @ingroup los_arch_interrupt
|
|
||||||
* @brief: Get an interrupt number.
|
|
||||||
*
|
|
||||||
* @par Description:
|
|
||||||
* This API is used to get the current interrupt number.
|
|
||||||
*
|
|
||||||
* @attention:
|
|
||||||
* <ul><li>None.</li></ul>
|
|
||||||
*
|
|
||||||
* @param: None.
|
|
||||||
*
|
|
||||||
* @retval: Interrupt Indexes number.
|
|
||||||
* @par Dependency:
|
|
||||||
* <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
|
|
||||||
* @see None.
|
|
||||||
*/
|
|
||||||
extern UINT32 HalIntNumGet(VOID);
|
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_arch_interrupt
|
* @ingroup los_arch_interrupt
|
||||||
* @brief: Default vector handling function.
|
* @brief: Default vector handling function.
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ LITE_OS_SEC_TEXT_INIT VOID ArchInit(VOID)
|
|||||||
**************************************************************************** */
|
**************************************************************************** */
|
||||||
LITE_OS_SEC_TEXT_MINOR VOID ArchSysExit(VOID)
|
LITE_OS_SEC_TEXT_MINOR VOID ArchSysExit(VOID)
|
||||||
{
|
{
|
||||||
LOS_IntLock();
|
(VOID)LOS_IntLock();
|
||||||
while (1) {
|
while (1) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -77,17 +77,7 @@ LITE_OS_SEC_TEXT_MINOR VOID ArchSysExit(VOID)
|
|||||||
**************************************************************************** */
|
**************************************************************************** */
|
||||||
LITE_OS_SEC_TEXT_INIT VOID *ArchTskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack)
|
LITE_OS_SEC_TEXT_INIT VOID *ArchTskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack)
|
||||||
{
|
{
|
||||||
TaskContext *context = NULL;
|
TaskContext *context = (TaskContext *)((UINTPTR)topStack + stackSize - sizeof(TaskContext));
|
||||||
errno_t result;
|
|
||||||
|
|
||||||
/* initialize the task stack, write magic num to stack top */
|
|
||||||
result = memset_s(topStack, stackSize, (INT32)(OS_TASK_STACK_INIT & 0xFF), stackSize);
|
|
||||||
if (result != EOK) {
|
|
||||||
printf("memset_s is failed:%s[%d]\r\n", __FUNCTION__, __LINE__);
|
|
||||||
}
|
|
||||||
*((UINT32 *)(topStack)) = OS_TASK_MAGIC_WORD;
|
|
||||||
|
|
||||||
context = (TaskContext *)(((UINTPTR)topStack + stackSize) - sizeof(TaskContext));
|
|
||||||
|
|
||||||
#if ((defined(__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
|
#if ((defined(__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
|
||||||
(defined(__FPU_USED) && (__FPU_USED == 1U)))
|
(defined(__FPU_USED) && (__FPU_USED == 1U)))
|
||||||
@@ -141,13 +131,26 @@ LITE_OS_SEC_TEXT_INIT VOID *ArchTskStackInit(UINT32 taskID, UINT32 stackSize, VO
|
|||||||
context->uwR2 = 0x02020202L;
|
context->uwR2 = 0x02020202L;
|
||||||
context->uwR3 = 0x03030303L;
|
context->uwR3 = 0x03030303L;
|
||||||
context->uwR12 = 0x12121212L;
|
context->uwR12 = 0x12121212L;
|
||||||
context->uwLR = (UINT32)(UINTPTR)ArchSysExit;
|
context->uwLR = (UINTPTR)ArchSysExit;
|
||||||
context->uwPC = (UINT32)(UINTPTR)OsTaskEntry;
|
context->uwPC = (UINTPTR)OsTaskEntry;
|
||||||
context->uwxPSR = 0x01000000L;
|
context->uwxPSR = 0x01000000L;
|
||||||
|
|
||||||
return (VOID *)context;
|
return (VOID *)context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VOID *ArchSignalContextInit(VOID *stackPointer, VOID *stackTop, UINTPTR sigHandler, UINT32 param)
|
||||||
|
{
|
||||||
|
UNUSED(stackTop);
|
||||||
|
TaskContext *context = (TaskContext *)((UINTPTR)stackPointer - sizeof(TaskContext));
|
||||||
|
(VOID)memset_s((VOID *)context, sizeof(TaskContext), 0, sizeof(TaskContext));
|
||||||
|
|
||||||
|
context->uwR0 = param;
|
||||||
|
context->uwPC = sigHandler;
|
||||||
|
context->uwxPSR = 0x01000000L; /* Thumb flag, always set 1 */
|
||||||
|
|
||||||
|
return (VOID *)context;
|
||||||
|
}
|
||||||
|
|
||||||
LITE_OS_SEC_TEXT_INIT UINT32 ArchStartSchedule(VOID)
|
LITE_OS_SEC_TEXT_INIT UINT32 ArchStartSchedule(VOID)
|
||||||
{
|
{
|
||||||
(VOID)LOS_IntLock();
|
(VOID)LOS_IntLock();
|
||||||
|
|||||||
@@ -38,6 +38,7 @@
|
|||||||
EXPORT ArchTaskSchedule
|
EXPORT ArchTaskSchedule
|
||||||
EXPORT HalPendSV
|
EXPORT HalPendSV
|
||||||
IMPORT OsSchedTaskSwitch
|
IMPORT OsSchedTaskSwitch
|
||||||
|
IMPORT OsSignalTaskContextRestore
|
||||||
IMPORT g_losTask
|
IMPORT g_losTask
|
||||||
|
|
||||||
OS_FPU_CPACR EQU 0xE000ED88
|
OS_FPU_CPACR EQU 0xE000ED88
|
||||||
@@ -52,6 +53,15 @@ OS_TASK_STATUS_RUNNING EQU 0x0010
|
|||||||
THUMB
|
THUMB
|
||||||
REQUIRE8
|
REQUIRE8
|
||||||
|
|
||||||
|
MACRO SIGNAL_CONTEXT_RESTORE
|
||||||
|
PUSH {R12, LR}
|
||||||
|
BLX OsSignalTaskContextRestore
|
||||||
|
POP {R12, LR}
|
||||||
|
CMP R0, #0
|
||||||
|
MOV R1, R0
|
||||||
|
BNE SignalContextRestore
|
||||||
|
ENDM
|
||||||
|
|
||||||
HalStartToRun
|
HalStartToRun
|
||||||
LDR R4, =OS_NVIC_SYSPRI2
|
LDR R4, =OS_NVIC_SYSPRI2
|
||||||
LDR R5, =OS_NVIC_PENDSV_PRI
|
LDR R5, =OS_NVIC_PENDSV_PRI
|
||||||
@@ -117,6 +127,8 @@ HalPendSV
|
|||||||
CPSID I
|
CPSID I
|
||||||
|
|
||||||
HalTaskSwitch
|
HalTaskSwitch
|
||||||
|
SIGNAL_CONTEXT_RESTORE
|
||||||
|
|
||||||
PUSH {R12, LR}
|
PUSH {R12, LR}
|
||||||
BLX OsSchedTaskSwitch
|
BLX OsSchedTaskSwitch
|
||||||
POP {R12, LR}
|
POP {R12, LR}
|
||||||
@@ -128,8 +140,8 @@ HalTaskSwitch
|
|||||||
|
|
||||||
TaskContextSwitch
|
TaskContextSwitch
|
||||||
MOV LR, R0
|
MOV LR, R0
|
||||||
MRS R0, PSP
|
|
||||||
|
|
||||||
|
MRS R0, PSP
|
||||||
STMFD R0!, {R4-R12}
|
STMFD R0!, {R4-R12}
|
||||||
LDR.W R3, =OS_FPU_CPACR
|
LDR.W R3, =OS_FPU_CPACR
|
||||||
LDR R3, [R3]
|
LDR R3, [R3]
|
||||||
@@ -145,8 +157,11 @@ __DisabledFPU1
|
|||||||
|
|
||||||
LDR R0, [R5, #4]
|
LDR R0, [R5, #4]
|
||||||
STR R0, [R5]
|
STR R0, [R5]
|
||||||
|
|
||||||
LDR R1, [R0]
|
LDR R1, [R0]
|
||||||
|
|
||||||
|
SignalContextRestore
|
||||||
|
LDR.W R3, =OS_FPU_CPACR
|
||||||
|
LDR R3, [R3]
|
||||||
AND R3, R3, #OS_FPU_CPACR_ENABLE
|
AND R3, R3, #OS_FPU_CPACR_ENABLE
|
||||||
CMP R3, #OS_FPU_CPACR_ENABLE
|
CMP R3, #OS_FPU_CPACR_ENABLE
|
||||||
BNE __DisabledFPU2
|
BNE __DisabledFPU2
|
||||||
|
|||||||
@@ -190,7 +190,7 @@ _hwiActiveCheck
|
|||||||
CMP R3, #0
|
CMP R3, #0
|
||||||
BEQ _hwiActiveCheckNext
|
BEQ _hwiActiveCheckNext
|
||||||
|
|
||||||
; exc occured in IRQ
|
; exc occurred in IRQ
|
||||||
ORR R0, R0, #FLAG_HWI_ACTIVE
|
ORR R0, R0, #FLAG_HWI_ACTIVE
|
||||||
RBIT R2, R3
|
RBIT R2, R3
|
||||||
CLZ R2, R2
|
CLZ R2, R2
|
||||||
@@ -228,19 +228,19 @@ _hwiActiveCheckNext
|
|||||||
AND R2, R2,R3
|
AND R2, R2,R3
|
||||||
CMP R2,#0
|
CMP R2,#0
|
||||||
BNE _ExcInMSP
|
BNE _ExcInMSP
|
||||||
; exc occured in Task or Init or exc
|
; exc occurred in Task or Init or exc
|
||||||
; reserved for register info from task stack
|
; reserved for register info from task stack
|
||||||
|
|
||||||
LDR R2, =g_taskScheduled
|
LDR R2, =g_taskScheduled
|
||||||
LDR R2, [R2]
|
LDR R2, [R2]
|
||||||
TST R2, #1 ; OS_FLG_BGD_ACTIVE
|
TST R2, #1 ; OS_FLG_BGD_ACTIVE
|
||||||
BEQ _ExcInMSP ; if exc occured in Init then branch
|
BEQ _ExcInMSP ; if exc occurred in Init then branch
|
||||||
|
|
||||||
|
|
||||||
CMP LR, #0xFFFFFFED ;auto push floating registers
|
CMP LR, #0xFFFFFFED ;auto push floating registers
|
||||||
BNE _NoFloatInPsp
|
BNE _NoFloatInPsp
|
||||||
|
|
||||||
; exc occured in Task
|
; exc occurred in Task
|
||||||
MOV R2, R13
|
MOV R2, R13
|
||||||
SUB R13, #96 ; add 8 Bytes reg(for STMFD)
|
SUB R13, #96 ; add 8 Bytes reg(for STMFD)
|
||||||
|
|
||||||
|
|||||||
@@ -40,14 +40,15 @@
|
|||||||
#include "los_sched.h"
|
#include "los_sched.h"
|
||||||
#include "los_memory.h"
|
#include "los_memory.h"
|
||||||
#include "los_membox.h"
|
#include "los_membox.h"
|
||||||
|
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
|
||||||
|
#include "los_cpup.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
/*lint -save -e40 -e522 -e533*/
|
|
||||||
UINT32 g_intCount = 0;
|
UINT32 g_intCount = 0;
|
||||||
|
|
||||||
/*lint -restore*/
|
|
||||||
#ifdef __ICCARM__
|
#ifdef __ICCARM__
|
||||||
#pragma location = ".data.vector"
|
#pragma location = ".data.vector"
|
||||||
#pragma data_alignment=LOSCFG_ARCH_HWI_VECTOR_ALIGN
|
#pragma data_alignment = LOSCFG_ARCH_HWI_VECTOR_ALIGN
|
||||||
#elif defined(__CC_ARM) || defined(__GNUC__)
|
#elif defined(__CC_ARM) || defined(__GNUC__)
|
||||||
LITE_OS_SEC_VEC
|
LITE_OS_SEC_VEC
|
||||||
#endif
|
#endif
|
||||||
@@ -57,6 +58,30 @@ LITE_OS_SEC_VEC
|
|||||||
*/
|
*/
|
||||||
STATIC HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT] = {0};
|
STATIC HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT] = {0};
|
||||||
|
|
||||||
|
#if (LOSCFG_DEBUG_TOOLS == 1)
|
||||||
|
STATIC UINT32 g_hwiFormCnt[OS_HWI_MAX_NUM] = {0};
|
||||||
|
STATIC CHAR *g_hwiFormName[OS_HWI_MAX_NUM] = {0};
|
||||||
|
|
||||||
|
UINT32 OsGetHwiFormCnt(UINT32 index)
|
||||||
|
{
|
||||||
|
return g_hwiFormCnt[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
CHAR *OsGetHwiFormName(UINT32 index)
|
||||||
|
{
|
||||||
|
return g_hwiFormName[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL OsGetHwiCreated(UINT32 index)
|
||||||
|
{
|
||||||
|
if (g_hwiForm[index] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
|
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -109,17 +134,85 @@ WEAK VOID SysTick_Handler(VOID)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ****************************************************************************
|
/* ****************************************************************************
|
||||||
Function : HalIntNumGet
|
Function : HwiNumGet
|
||||||
Description : Get an interrupt number
|
Description : Get an interrupt number
|
||||||
Input : None
|
Input : None
|
||||||
Output : None
|
Output : None
|
||||||
Return : Interrupt Indexes number
|
Return : Interrupt Indexes number
|
||||||
**************************************************************************** */
|
**************************************************************************** */
|
||||||
LITE_OS_SEC_TEXT_MINOR UINT32 HalIntNumGet(VOID)
|
STATIC UINT32 HwiNumGet(VOID)
|
||||||
{
|
{
|
||||||
return __get_IPSR();
|
return __get_IPSR();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
|
||||||
|
{
|
||||||
|
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||||
|
return OS_ERRNO_HWI_NUM_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
|
||||||
|
{
|
||||||
|
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||||
|
return OS_ERRNO_HWI_NUM_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
NVIC_DisableIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority)
|
||||||
|
{
|
||||||
|
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||||
|
return OS_ERRNO_HWI_NUM_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (priority > OS_HWI_PRIO_LOWEST) {
|
||||||
|
return OS_ERRNO_HWI_PRIO_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
NVIC_SetPriority((IRQn_Type)hwiNum, priority);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
|
||||||
|
{
|
||||||
|
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||||
|
return OS_ERRNO_HWI_NUM_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
|
||||||
|
{
|
||||||
|
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||||
|
return OS_ERRNO_HWI_NUM_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
HwiControllerOps g_archHwiOps = {
|
||||||
|
.enableIrq = HwiUnmask,
|
||||||
|
.disableIrq = HwiMask,
|
||||||
|
.setIrqPriority = HwiSetPriority,
|
||||||
|
.getCurIrqNum = HwiNumGet,
|
||||||
|
.triggerIrq = HwiPending,
|
||||||
|
.clearIrq = HwiClear,
|
||||||
|
};
|
||||||
|
|
||||||
inline UINT32 ArchIsIntActive(VOID)
|
inline UINT32 ArchIsIntActive(VOID)
|
||||||
{
|
{
|
||||||
return (g_intCount > 0);
|
return (g_intCount > 0);
|
||||||
@@ -134,18 +227,19 @@ inline UINT32 ArchIsIntActive(VOID)
|
|||||||
/*lint -e529*/
|
/*lint -e529*/
|
||||||
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
|
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
|
||||||
{
|
{
|
||||||
UINT32 irqNum = HalIntNumGet();
|
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet());
|
||||||
PRINT_ERR("%s irqnum:%d\n", __FUNCTION__, irqNum);
|
|
||||||
while (1) {}
|
while (1) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
WEAK VOID HalPreInterruptHandler(UINT32 arg)
|
WEAK VOID HalPreInterruptHandler(UINT32 arg)
|
||||||
{
|
{
|
||||||
|
(VOID)arg;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
WEAK VOID HalAftInterruptHandler(UINT32 arg)
|
WEAK VOID HalAftInterruptHandler(UINT32 arg)
|
||||||
{
|
{
|
||||||
|
(VOID)arg;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,9 +263,12 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
|
|||||||
g_intCount++;
|
g_intCount++;
|
||||||
LOS_IntRestore(intSave);
|
LOS_IntRestore(intSave);
|
||||||
|
|
||||||
hwiIndex = HalIntNumGet();
|
hwiIndex = HwiNumGet();
|
||||||
|
|
||||||
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
|
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
|
||||||
|
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
|
||||||
|
OsCpupIrqStart(hwiIndex);
|
||||||
|
#endif
|
||||||
|
|
||||||
HalPreInterruptHandler(hwiIndex);
|
HalPreInterruptHandler(hwiIndex);
|
||||||
|
|
||||||
@@ -185,8 +282,16 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if (LOSCFG_DEBUG_TOOLS == 1)
|
||||||
|
++g_hwiFormCnt[hwiIndex];
|
||||||
|
#endif
|
||||||
|
|
||||||
HalAftInterruptHandler(hwiIndex);
|
HalAftInterruptHandler(hwiIndex);
|
||||||
|
|
||||||
|
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
|
||||||
|
OsCpupIrqEnd(hwiIndex);
|
||||||
|
#endif
|
||||||
|
|
||||||
OsHookCall(LOS_HOOK_TYPE_ISR_EXIT, hwiIndex);
|
OsHookCall(LOS_HOOK_TYPE_ISR_EXIT, hwiIndex);
|
||||||
|
|
||||||
intSave = LOS_IntLock();
|
intSave = LOS_IntLock();
|
||||||
@@ -199,21 +304,22 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
|
|||||||
Description : create hardware interrupt
|
Description : create hardware interrupt
|
||||||
Input : hwiNum --- hwi num to create
|
Input : hwiNum --- hwi num to create
|
||||||
hwiPrio --- priority of the hwi
|
hwiPrio --- priority of the hwi
|
||||||
mode --- unused
|
hwiMode --- unused
|
||||||
handler --- hwi handler
|
hwiHandler --- hwi handler
|
||||||
arg --- param of the hwi handler
|
irqParam --- param of the hwi handler
|
||||||
Output : None
|
Output : None
|
||||||
Return : LOS_OK on success or error code on failure
|
Return : LOS_OK on success or error code on failure
|
||||||
**************************************************************************** */
|
**************************************************************************** */
|
||||||
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
||||||
HWI_PRIOR_T hwiPrio,
|
HWI_PRIOR_T hwiPrio,
|
||||||
HWI_MODE_T mode,
|
HWI_MODE_T hwiMode,
|
||||||
HWI_PROC_FUNC handler,
|
HWI_PROC_FUNC hwiHandler,
|
||||||
HWI_ARG_T arg)
|
HwiIrqParam *irqParam)
|
||||||
{
|
{
|
||||||
|
(VOID)hwiMode;
|
||||||
UINT32 intSave;
|
UINT32 intSave;
|
||||||
|
|
||||||
if (handler == NULL) {
|
if (hwiHandler == NULL) {
|
||||||
return OS_ERRNO_HWI_PROC_FUNC_NULL;
|
return OS_ERRNO_HWI_PROC_FUNC_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -231,12 +337,25 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
|||||||
|
|
||||||
intSave = LOS_IntLock();
|
intSave = LOS_IntLock();
|
||||||
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
|
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
|
||||||
OsSetVector(hwiNum, handler, arg);
|
if (irqParam != NULL) {
|
||||||
|
OsSetVector(hwiNum, hwiHandler, irqParam->pDevId);
|
||||||
|
} else {
|
||||||
|
OsSetVector(hwiNum, hwiHandler, NULL);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
OsSetVector(hwiNum, handler);
|
(VOID)irqParam;
|
||||||
|
OsSetVector(hwiNum, hwiHandler);
|
||||||
#endif
|
#endif
|
||||||
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
|
||||||
NVIC_SetPriority((IRQn_Type)hwiNum, hwiPrio);
|
#if (LOSCFG_DEBUG_TOOLS == 1)
|
||||||
|
if ((irqParam != NULL) && (irqParam->pName != NULL)) {
|
||||||
|
g_hwiFormName[hwiNum + OS_SYS_VECTOR_CNT] = (CHAR *)irqParam->pName;
|
||||||
|
}
|
||||||
|
g_hwiFormCnt[hwiNum + OS_SYS_VECTOR_CNT] = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
HwiUnmask((IRQn_Type)hwiNum);
|
||||||
|
HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
|
||||||
|
|
||||||
LOS_IntRestore(intSave);
|
LOS_IntRestore(intSave);
|
||||||
|
|
||||||
@@ -247,11 +366,13 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
|||||||
Function : ArchHwiDelete
|
Function : ArchHwiDelete
|
||||||
Description : Delete hardware interrupt
|
Description : Delete hardware interrupt
|
||||||
Input : hwiNum --- hwi num to delete
|
Input : hwiNum --- hwi num to delete
|
||||||
|
irqParam --- param of the hwi handler
|
||||||
Output : None
|
Output : None
|
||||||
Return : LOS_OK on success or error code on failure
|
Return : LOS_OK on success or error code on failure
|
||||||
**************************************************************************** */
|
**************************************************************************** */
|
||||||
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum)
|
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam)
|
||||||
{
|
{
|
||||||
|
(VOID)irqParam;
|
||||||
UINT32 intSave;
|
UINT32 intSave;
|
||||||
|
|
||||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||||
@@ -379,6 +500,7 @@ STATIC VOID OsExcRegInfo(const ExcInfo *excInfo)
|
|||||||
PRINTK("xPSR = 0x%x\n", excInfo->context->uwxPSR);
|
PRINTK("xPSR = 0x%x\n", excInfo->context->uwxPSR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if (LOSCFG_KERNEL_BACKTRACE == 1)
|
||||||
STATIC VOID OsExcBackTraceInfo(const ExcInfo *excInfo)
|
STATIC VOID OsExcBackTraceInfo(const ExcInfo *excInfo)
|
||||||
{
|
{
|
||||||
UINTPTR LR[LOSCFG_BACKTRACE_DEPTH] = {0};
|
UINTPTR LR[LOSCFG_BACKTRACE_DEPTH] = {0};
|
||||||
@@ -395,6 +517,7 @@ STATIC VOID OsExcBackTraceInfo(const ExcInfo *excInfo)
|
|||||||
}
|
}
|
||||||
PRINTK("----- backtrace end -----\n");
|
PRINTK("----- backtrace end -----\n");
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
STATIC VOID OsExcMemPoolCheckInfo(VOID)
|
STATIC VOID OsExcMemPoolCheckInfo(VOID)
|
||||||
{
|
{
|
||||||
@@ -444,7 +567,9 @@ STATIC VOID OsExcInfoDisplay(const ExcInfo *excInfo)
|
|||||||
OsExcTypeInfo(excInfo);
|
OsExcTypeInfo(excInfo);
|
||||||
OsExcCurTaskInfo(excInfo);
|
OsExcCurTaskInfo(excInfo);
|
||||||
OsExcRegInfo(excInfo);
|
OsExcRegInfo(excInfo);
|
||||||
|
#if (LOSCFG_KERNEL_BACKTRACE == 1)
|
||||||
OsExcBackTraceInfo(excInfo);
|
OsExcBackTraceInfo(excInfo);
|
||||||
|
#endif
|
||||||
OsGetAllTskInfo();
|
OsGetAllTskInfo();
|
||||||
OsExcNvicDump();
|
OsExcNvicDump();
|
||||||
OsExcMemPoolCheckInfo();
|
OsExcMemPoolCheckInfo();
|
||||||
@@ -499,19 +624,19 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
|
|||||||
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
|
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
|
||||||
UINT32 index;
|
UINT32 index;
|
||||||
g_hwiForm[0] = 0; /* [0] Top of Stack */
|
g_hwiForm[0] = 0; /* [0] Top of Stack */
|
||||||
g_hwiForm[1] = Reset_Handler; /* [1] reset */
|
g_hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */
|
||||||
for (index = 2; index < OS_VECTOR_CNT; index++) { /* 2: The starting position of the interrupt */
|
for (index = 2; index < OS_VECTOR_CNT; index++) { /* 2: The starting position of the interrupt */
|
||||||
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
|
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
|
||||||
}
|
}
|
||||||
/* Exception handler register */
|
/* Exception handler register */
|
||||||
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = HalExcNMI;
|
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
|
||||||
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = HalExcHardFault;
|
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
|
||||||
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = HalExcMemFault;
|
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
|
||||||
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcBusFault;
|
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
|
||||||
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcUsageFault;
|
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
|
||||||
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = HalExcSvcCall;
|
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcSvcCall;
|
||||||
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = HalPendSV;
|
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
|
||||||
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = SysTick_Handler;
|
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
|
||||||
|
|
||||||
/* Interrupt vector table location */
|
/* Interrupt vector table location */
|
||||||
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;
|
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;
|
||||||
@@ -522,7 +647,7 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
|
|||||||
|
|
||||||
/* Enable USGFAULT, BUSFAULT, MEMFAULT */
|
/* Enable USGFAULT, BUSFAULT, MEMFAULT */
|
||||||
*(volatile UINT32 *)OS_NVIC_SHCSR |= (USGFAULT | BUSFAULT | MEMFAULT);
|
*(volatile UINT32 *)OS_NVIC_SHCSR |= (USGFAULT | BUSFAULT | MEMFAULT);
|
||||||
|
|
||||||
/* Enable DIV 0 and unaligned exception */
|
/* Enable DIV 0 and unaligned exception */
|
||||||
#ifdef LOSCFG_ARCH_UNALIGNED_EXC
|
#ifdef LOSCFG_ARCH_UNALIGNED_EXC
|
||||||
*(volatile UINT32 *)OS_NVIC_CCR |= (DIV0FAULT | UNALIGNFAULT);
|
*(volatile UINT32 *)OS_NVIC_CCR |= (DIV0FAULT | UNALIGNFAULT);
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
#include "los_debug.h"
|
#include "los_debug.h"
|
||||||
|
|
||||||
STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler);
|
STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler);
|
||||||
STATIC VOID SysTickReload(UINT64 nextResponseTime);
|
STATIC UINT64 SysTickReload(UINT64 nextResponseTime);
|
||||||
STATIC UINT64 SysTickCycleGet(UINT32 *period);
|
STATIC UINT64 SysTickCycleGet(UINT32 *period);
|
||||||
STATIC VOID SysTickLock(VOID);
|
STATIC VOID SysTickLock(VOID);
|
||||||
STATIC VOID SysTickUnlock(VOID);
|
STATIC VOID SysTickUnlock(VOID);
|
||||||
@@ -44,6 +44,7 @@ STATIC VOID SysTickUnlock(VOID);
|
|||||||
STATIC ArchTickTimer g_archTickTimer = {
|
STATIC ArchTickTimer g_archTickTimer = {
|
||||||
.freq = 0,
|
.freq = 0,
|
||||||
.irqNum = SysTick_IRQn,
|
.irqNum = SysTick_IRQn,
|
||||||
|
.periodMax = LOSCFG_BASE_CORE_TICK_RESPONSE_MAX,
|
||||||
.init = SysTickStart,
|
.init = SysTickStart,
|
||||||
.getCycle = SysTickCycleGet,
|
.getCycle = SysTickCycleGet,
|
||||||
.reload = SysTickReload,
|
.reload = SysTickReload,
|
||||||
@@ -75,13 +76,17 @@ STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler)
|
|||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC VOID SysTickReload(UINT64 nextResponseTime)
|
STATIC UINT64 SysTickReload(UINT64 nextResponseTime)
|
||||||
{
|
{
|
||||||
|
if (nextResponseTime > g_archTickTimer.periodMax) {
|
||||||
|
nextResponseTime = g_archTickTimer.periodMax;
|
||||||
|
}
|
||||||
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
|
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
|
||||||
SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */
|
SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */
|
||||||
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
|
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
|
||||||
NVIC_ClearPendingIRQ(SysTick_IRQn);
|
NVIC_ClearPendingIRQ(SysTick_IRQn);
|
||||||
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
|
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
|
||||||
|
return nextResponseTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC UINT64 SysTickCycleGet(UINT32 *period)
|
STATIC UINT64 SysTickCycleGet(UINT32 *period)
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
# 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("//kernel/liteos_m/liteos.gni")
|
||||||
|
|
||||||
|
module_group("gcc") {
|
||||||
|
if (defined(LOSCFG_SECURE_TRUSTZONE)) {
|
||||||
|
modules = [ "TZ" ]
|
||||||
|
} else {
|
||||||
|
modules = [ "NTZ" ]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
# 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("//kernel/liteos_m/liteos.gni")
|
||||||
|
|
||||||
|
module_name = "arch"
|
||||||
|
kernel_module(module_name) {
|
||||||
|
sources = [
|
||||||
|
"los_context.c",
|
||||||
|
"los_dispatch.S",
|
||||||
|
"los_exc.S",
|
||||||
|
"los_interrupt.c",
|
||||||
|
"los_timer.c",
|
||||||
|
]
|
||||||
|
configs += [ "$LITEOSTOPDIR:warn_config" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
config("public") {
|
||||||
|
include_dirs = [ "." ]
|
||||||
|
}
|
||||||
@@ -0,0 +1,296 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _LOS_ARCH_ATOMIC_H
|
||||||
|
#define _LOS_ARCH_ATOMIC_H
|
||||||
|
|
||||||
|
#include "los_compiler.h"
|
||||||
|
#include "los_interrupt.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#if __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
STATIC INLINE INT32 ArchAtomicRead(const Atomic *v)
|
||||||
|
{
|
||||||
|
INT32 val;
|
||||||
|
|
||||||
|
__asm__ __volatile__("ldrex %0, [%1]\n"
|
||||||
|
: "=&r"(val)
|
||||||
|
: "r"(v)
|
||||||
|
: "cc");
|
||||||
|
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC INLINE VOID ArchAtomicSet(Atomic *v, INT32 setVal)
|
||||||
|
{
|
||||||
|
UINT32 status;
|
||||||
|
|
||||||
|
do {
|
||||||
|
__asm__ __volatile__("ldrex %0, [%1]\n"
|
||||||
|
"strex %0, %2, [%1]\n"
|
||||||
|
: "=&r"(status)
|
||||||
|
: "r"(v), "r"(setVal)
|
||||||
|
: "cc");
|
||||||
|
} while (__builtin_expect(status != 0, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC INLINE INT32 ArchAtomicAdd(Atomic *v, INT32 addVal)
|
||||||
|
{
|
||||||
|
INT32 val;
|
||||||
|
UINT32 status;
|
||||||
|
|
||||||
|
do {
|
||||||
|
__asm__ __volatile__("ldrex %1, [%2]\n"
|
||||||
|
"add %1, %1, %3\n"
|
||||||
|
"strex %0, %1, [%2]"
|
||||||
|
: "=&r"(status), "=&r"(val)
|
||||||
|
: "r"(v), "r"(addVal)
|
||||||
|
: "cc");
|
||||||
|
} while (__builtin_expect(status != 0, 0));
|
||||||
|
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC INLINE INT32 ArchAtomicSub(Atomic *v, INT32 subVal)
|
||||||
|
{
|
||||||
|
INT32 val;
|
||||||
|
UINT32 status;
|
||||||
|
|
||||||
|
do {
|
||||||
|
__asm__ __volatile__("ldrex %1, [%2]\n"
|
||||||
|
"sub %1, %1, %3\n"
|
||||||
|
"strex %0, %1, [%2]"
|
||||||
|
: "=&r"(status), "=&r"(val)
|
||||||
|
: "r"(v), "r"(subVal)
|
||||||
|
: "cc");
|
||||||
|
} while (__builtin_expect(status != 0, 0));
|
||||||
|
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC INLINE VOID ArchAtomicInc(Atomic *v)
|
||||||
|
{
|
||||||
|
(VOID)ArchAtomicAdd(v, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC INLINE VOID ArchAtomicDec(Atomic *v)
|
||||||
|
{
|
||||||
|
(VOID)ArchAtomicSub(v, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC INLINE INT32 ArchAtomicIncRet(Atomic *v)
|
||||||
|
{
|
||||||
|
return ArchAtomicAdd(v, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC INLINE INT32 ArchAtomicDecRet(Atomic *v)
|
||||||
|
{
|
||||||
|
return ArchAtomicSub(v, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup los_arch_atomic
|
||||||
|
* @brief Atomic exchange for 32-bit variable.
|
||||||
|
*
|
||||||
|
* @par Description:
|
||||||
|
* This API is used to implement the atomic exchange for 32-bit variable
|
||||||
|
* and return the previous value of the atomic variable.
|
||||||
|
* @attention
|
||||||
|
* <ul>The pointer v must not be NULL.</ul>
|
||||||
|
*
|
||||||
|
* @param v [IN] The variable pointer.
|
||||||
|
* @param val [IN] The exchange value.
|
||||||
|
*
|
||||||
|
* @retval #INT32 The previous value of the atomic variable
|
||||||
|
* @par Dependency:
|
||||||
|
* <ul><li>los_arch_atomic.h: the header file that contains the API declaration.</li></ul>
|
||||||
|
* @see
|
||||||
|
*/
|
||||||
|
STATIC INLINE INT32 ArchAtomicXchg32bits(volatile INT32 *v, INT32 val)
|
||||||
|
{
|
||||||
|
INT32 prevVal = 0;
|
||||||
|
UINT32 status = 0;
|
||||||
|
|
||||||
|
do {
|
||||||
|
__asm__ __volatile__("ldrex %0, [%3]\n"
|
||||||
|
"strex %1, %4, [%3]"
|
||||||
|
: "=&r"(prevVal), "=&r"(status), "+m"(*v)
|
||||||
|
: "r"(v), "r"(val)
|
||||||
|
: "cc");
|
||||||
|
} while (__builtin_expect(status != 0, 0));
|
||||||
|
|
||||||
|
return prevVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup los_arch_atomic
|
||||||
|
* @brief Atomic exchange for 32-bit variable with compare.
|
||||||
|
*
|
||||||
|
* @par Description:
|
||||||
|
* This API is used to implement the atomic exchange for 32-bit variable, if the value of variable is equal to oldVal.
|
||||||
|
* @attention
|
||||||
|
* <ul>The pointer v must not be NULL.</ul>
|
||||||
|
*
|
||||||
|
* @param v [IN] The variable pointer.
|
||||||
|
* @param val [IN] The new value.
|
||||||
|
* @param oldVal [IN] The old value.
|
||||||
|
*
|
||||||
|
* @retval TRUE The previous value of the atomic variable is not equal to oldVal.
|
||||||
|
* @retval FALSE The previous value of the atomic variable is equal to oldVal.
|
||||||
|
* @par Dependency:
|
||||||
|
* <ul><li>los_arch_atomic.h: the header file that contains the API declaration.</li></ul>
|
||||||
|
* @see
|
||||||
|
*/
|
||||||
|
STATIC INLINE BOOL ArchAtomicCmpXchg32bits(volatile INT32 *v, INT32 val, INT32 oldVal)
|
||||||
|
{
|
||||||
|
INT32 prevVal = 0;
|
||||||
|
UINT32 status = 0;
|
||||||
|
|
||||||
|
do {
|
||||||
|
__asm__ __volatile__("ldrex %0, %2\n"
|
||||||
|
"mov %1, #0\n"
|
||||||
|
"cmp %0, %3\n"
|
||||||
|
"bne 1f\n"
|
||||||
|
"strex %1, %4, %2\n"
|
||||||
|
"1:"
|
||||||
|
: "=&r"(prevVal), "=&r"(status), "+Q"(*v)
|
||||||
|
: "r"(oldVal), "r"(val)
|
||||||
|
: "cc");
|
||||||
|
} while (__builtin_expect(status != 0, 0));
|
||||||
|
|
||||||
|
return prevVal != oldVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC INLINE INT64 ArchAtomic64Read(const Atomic64 *v)
|
||||||
|
{
|
||||||
|
INT64 val;
|
||||||
|
UINT32 intSave;
|
||||||
|
|
||||||
|
intSave = LOS_IntLock();
|
||||||
|
val = *v;
|
||||||
|
LOS_IntRestore(intSave);
|
||||||
|
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC INLINE VOID ArchAtomic64Set(Atomic64 *v, INT64 setVal)
|
||||||
|
{
|
||||||
|
UINT32 intSave;
|
||||||
|
|
||||||
|
intSave = LOS_IntLock();
|
||||||
|
*v = setVal;
|
||||||
|
LOS_IntRestore(intSave);
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC INLINE INT64 ArchAtomic64Add(Atomic64 *v, INT64 addVal)
|
||||||
|
{
|
||||||
|
INT64 val;
|
||||||
|
UINT32 intSave;
|
||||||
|
|
||||||
|
intSave = LOS_IntLock();
|
||||||
|
*v += addVal;
|
||||||
|
val = *v;
|
||||||
|
LOS_IntRestore(intSave);
|
||||||
|
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC INLINE INT64 ArchAtomic64Sub(Atomic64 *v, INT64 subVal)
|
||||||
|
{
|
||||||
|
INT64 val;
|
||||||
|
UINT32 intSave;
|
||||||
|
|
||||||
|
intSave = LOS_IntLock();
|
||||||
|
*v -= subVal;
|
||||||
|
val = *v;
|
||||||
|
LOS_IntRestore(intSave);
|
||||||
|
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC INLINE VOID ArchAtomic64Inc(Atomic64 *v)
|
||||||
|
{
|
||||||
|
(VOID)ArchAtomic64Add(v, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC INLINE INT64 ArchAtomic64IncRet(Atomic64 *v)
|
||||||
|
{
|
||||||
|
return ArchAtomic64Add(v, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC INLINE VOID ArchAtomic64Dec(Atomic64 *v)
|
||||||
|
{
|
||||||
|
(VOID)ArchAtomic64Sub(v, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC INLINE INT64 ArchAtomic64DecRet(Atomic64 *v)
|
||||||
|
{
|
||||||
|
return ArchAtomic64Sub(v, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC INLINE INT64 ArchAtomicXchg64bits(Atomic64 *v, INT64 val)
|
||||||
|
{
|
||||||
|
INT64 prevVal;
|
||||||
|
UINT32 intSave;
|
||||||
|
|
||||||
|
intSave = LOS_IntLock();
|
||||||
|
prevVal = *v;
|
||||||
|
*v = val;
|
||||||
|
LOS_IntRestore(intSave);
|
||||||
|
|
||||||
|
return prevVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC INLINE BOOL ArchAtomicCmpXchg64bits(Atomic64 *v, INT64 val, INT64 oldVal)
|
||||||
|
{
|
||||||
|
INT64 prevVal;
|
||||||
|
UINT32 intSave;
|
||||||
|
|
||||||
|
intSave = LOS_IntLock();
|
||||||
|
prevVal = *v;
|
||||||
|
if (prevVal == oldVal) {
|
||||||
|
*v = val;
|
||||||
|
}
|
||||||
|
LOS_IntRestore(intSave);
|
||||||
|
|
||||||
|
return prevVal != oldVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#if __cplusplus
|
||||||
|
}
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
#endif /* _LOS_ARCH_ATOMIC_H */
|
||||||
@@ -0,0 +1,131 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _LOS_ARCH_CONTEXT_H
|
||||||
|
#define _LOS_ARCH_CONTEXT_H
|
||||||
|
|
||||||
|
#include "los_config.h"
|
||||||
|
#include "los_compiler.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#if __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
typedef struct TagTskContext {
|
||||||
|
UINT32 uwPspLim;
|
||||||
|
UINT32 uwExcLR;
|
||||||
|
UINT32 uwR4;
|
||||||
|
UINT32 uwR5;
|
||||||
|
UINT32 uwR6;
|
||||||
|
UINT32 uwR7;
|
||||||
|
UINT32 uwR8;
|
||||||
|
UINT32 uwR9;
|
||||||
|
UINT32 uwR10;
|
||||||
|
UINT32 uwR11;
|
||||||
|
UINT32 uwPriMask;
|
||||||
|
#if ((defined(__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
|
||||||
|
(defined(__FPU_USED) && (__FPU_USED == 1U)))
|
||||||
|
UINT32 S16;
|
||||||
|
UINT32 S17;
|
||||||
|
UINT32 S18;
|
||||||
|
UINT32 S19;
|
||||||
|
UINT32 S20;
|
||||||
|
UINT32 S21;
|
||||||
|
UINT32 S22;
|
||||||
|
UINT32 S23;
|
||||||
|
UINT32 S24;
|
||||||
|
UINT32 S25;
|
||||||
|
UINT32 S26;
|
||||||
|
UINT32 S27;
|
||||||
|
UINT32 S28;
|
||||||
|
UINT32 S29;
|
||||||
|
UINT32 S30;
|
||||||
|
UINT32 S31;
|
||||||
|
#endif
|
||||||
|
UINT32 uwR0;
|
||||||
|
UINT32 uwR1;
|
||||||
|
UINT32 uwR2;
|
||||||
|
UINT32 uwR3;
|
||||||
|
UINT32 uwR12;
|
||||||
|
UINT32 uwLR;
|
||||||
|
UINT32 uwPC;
|
||||||
|
UINT32 uwxPSR;
|
||||||
|
#if ((defined(__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
|
||||||
|
(defined(__FPU_USED) && (__FPU_USED == 1U)))
|
||||||
|
UINT32 S0;
|
||||||
|
UINT32 S1;
|
||||||
|
UINT32 S2;
|
||||||
|
UINT32 S3;
|
||||||
|
UINT32 S4;
|
||||||
|
UINT32 S5;
|
||||||
|
UINT32 S6;
|
||||||
|
UINT32 S7;
|
||||||
|
UINT32 S8;
|
||||||
|
UINT32 S9;
|
||||||
|
UINT32 S10;
|
||||||
|
UINT32 S11;
|
||||||
|
UINT32 S12;
|
||||||
|
UINT32 S13;
|
||||||
|
UINT32 S14;
|
||||||
|
UINT32 S15;
|
||||||
|
UINT32 FPSCR;
|
||||||
|
UINT32 NO_NAME;
|
||||||
|
#endif
|
||||||
|
} TaskContext;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup los_config
|
||||||
|
* @brief: Task start running function.
|
||||||
|
*
|
||||||
|
* @par Description:
|
||||||
|
* This API is used to start a task.
|
||||||
|
*
|
||||||
|
* @attention:
|
||||||
|
* <ul><li>None.</li></ul>
|
||||||
|
*
|
||||||
|
* @param: None.
|
||||||
|
*
|
||||||
|
* @retval None.
|
||||||
|
*
|
||||||
|
* @par Dependency:
|
||||||
|
* <ul><li>los_config.h: the header file that contains the API declaration.</li></ul>
|
||||||
|
* @see None.
|
||||||
|
*/
|
||||||
|
extern VOID HalStartToRun(VOID);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#if __cplusplus
|
||||||
|
}
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
#endif /* _LOS_ARCH_CONTEXT_H */
|
||||||
@@ -0,0 +1,693 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _LOS_ARCH_INTERRUPT_H
|
||||||
|
#define _LOS_ARCH_INTERRUPT_H
|
||||||
|
|
||||||
|
#include "los_config.h"
|
||||||
|
#include "los_compiler.h"
|
||||||
|
#include "los_interrupt.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#if __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Maximum number of used hardware interrupts.
|
||||||
|
*/
|
||||||
|
#ifndef OS_HWI_MAX_NUM
|
||||||
|
#define OS_HWI_MAX_NUM LOSCFG_PLATFORM_HWI_LIMIT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Highest priority of a hardware interrupt.
|
||||||
|
*/
|
||||||
|
#ifndef OS_HWI_PRIO_HIGHEST
|
||||||
|
#define OS_HWI_PRIO_HIGHEST 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Lowest priority of a hardware interrupt.
|
||||||
|
*/
|
||||||
|
#ifndef OS_HWI_PRIO_LOWEST
|
||||||
|
#define OS_HWI_PRIO_LOWEST 7
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Define the type of a hardware interrupt vector table function.
|
||||||
|
*/
|
||||||
|
typedef VOID (**HWI_VECTOR_FUNC)(void);
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Count of interrupts.
|
||||||
|
*/
|
||||||
|
extern UINT32 g_intCount;
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Count of M-Core system interrupt vector.
|
||||||
|
*/
|
||||||
|
#define OS_SYS_VECTOR_CNT 16
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Count of M-Core interrupt vector.
|
||||||
|
*/
|
||||||
|
#define OS_VECTOR_CNT (OS_SYS_VECTOR_CNT + OS_HWI_MAX_NUM)
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* AIRCR register priority group parameter .
|
||||||
|
*/
|
||||||
|
#define OS_NVIC_AIRCR_PRIGROUP 7
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Hardware interrupt error code: Invalid interrupt number.
|
||||||
|
*
|
||||||
|
* Value: 0x02000900
|
||||||
|
*
|
||||||
|
* Solution: Ensure that the interrupt number is valid.
|
||||||
|
* The value range of the interrupt number applicable for a Cortex-M33 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
|
||||||
|
*/
|
||||||
|
#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Hardware interrupt error code: Null hardware interrupt handling function.
|
||||||
|
*
|
||||||
|
* Value: 0x02000901
|
||||||
|
*
|
||||||
|
* Solution: Pass in a valid non-null hardware interrupt handling function.
|
||||||
|
*/
|
||||||
|
#define OS_ERRNO_HWI_PROC_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x01)
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Hardware interrupt error code: Insufficient interrupt resources for hardware interrupt creation.
|
||||||
|
*
|
||||||
|
* Value: 0x02000902
|
||||||
|
*
|
||||||
|
* Solution: Increase the configured maximum number of supported hardware interrupts.
|
||||||
|
*/
|
||||||
|
#define OS_ERRNO_HWI_CB_UNAVAILABLE LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x02)
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Hardware interrupt error code: Insufficient memory for hardware interrupt initialization.
|
||||||
|
*
|
||||||
|
* Value: 0x02000903
|
||||||
|
*
|
||||||
|
* Solution: Expand the configured memory.
|
||||||
|
*/
|
||||||
|
#define OS_ERRNO_HWI_NO_MEMORY LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x03)
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Hardware interrupt error code: The interrupt has already been created.
|
||||||
|
*
|
||||||
|
* Value: 0x02000904
|
||||||
|
*
|
||||||
|
* Solution: Check whether the interrupt specified by the passed-in interrupt number has already been created.
|
||||||
|
*/
|
||||||
|
#define OS_ERRNO_HWI_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x04)
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Hardware interrupt error code: Invalid interrupt priority.
|
||||||
|
*
|
||||||
|
* Value: 0x02000905
|
||||||
|
*
|
||||||
|
* Solution: Ensure that the interrupt priority is valid.
|
||||||
|
* The value range of the interrupt priority applicable for a Cortex-M33 platform is [0,15].
|
||||||
|
*/
|
||||||
|
#define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05)
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Hardware interrupt error code: Incorrect interrupt creation mode.
|
||||||
|
*
|
||||||
|
* Value: 0x02000906
|
||||||
|
*
|
||||||
|
* Solution: The interrupt creation mode can be only set to OS_HWI_MODE_COMM or
|
||||||
|
* OS_HWI_MODE_FAST of which the value can be 0 or 1.
|
||||||
|
*/
|
||||||
|
#define OS_ERRNO_HWI_MODE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x06)
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Hardware interrupt error code: The interrupt has already been created as a fast interrupt.
|
||||||
|
*
|
||||||
|
* Value: 0x02000907
|
||||||
|
*
|
||||||
|
* Solution: Check whether the interrupt specified by the passed-in interrupt number has already been created.
|
||||||
|
*/
|
||||||
|
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* SysTick control and status register.
|
||||||
|
*/
|
||||||
|
#define OS_SYSTICK_CONTROL_REG 0xE000E010
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_hw
|
||||||
|
* SysTick current value register.
|
||||||
|
*/
|
||||||
|
#define OS_SYSTICK_CURRENT_REG 0xE000E018
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Interrupt Priority-Level Registers.
|
||||||
|
*/
|
||||||
|
#define OS_NVIC_PRI_BASE 0xE000E400
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Interrupt enable register for 0-31.
|
||||||
|
*/
|
||||||
|
#define OS_NVIC_SETENA_BASE 0xE000E100
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* interrupt pending register.
|
||||||
|
*/
|
||||||
|
#define OS_NVIC_SETPEND_BASE 0xE000E200
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Interrupt active register.
|
||||||
|
*/
|
||||||
|
#define OS_NVIC_INT_ACT_BASE 0xE000E300
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Interrupt disable register for 0-31.
|
||||||
|
*/
|
||||||
|
#define OS_NVIC_CLRENA_BASE 0xE000E180
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Interrupt control and status register.
|
||||||
|
*/
|
||||||
|
#define OS_NVIC_INT_CTRL 0xE000ED04
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Vector table offset register.
|
||||||
|
*/
|
||||||
|
#define OS_NVIC_VTOR 0xE000ED08
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Application interrupt and reset control register
|
||||||
|
*/
|
||||||
|
#define OS_NVIC_AIRCR 0xE000ED0C
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* System exception priority register.
|
||||||
|
*/
|
||||||
|
#define OS_NVIC_EXCPRI_BASE 0xE000ED18
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Interrupt No. 1 :reset.
|
||||||
|
*/
|
||||||
|
#define OS_EXC_RESET 1
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Interrupt No. 2 :Non-Maskable Interrupt.
|
||||||
|
*/
|
||||||
|
#define OS_EXC_NMI 2
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Interrupt No. 3 :(hard)fault.
|
||||||
|
*/
|
||||||
|
#define OS_EXC_HARD_FAULT 3
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Interrupt No. 4 :MemManage fault.
|
||||||
|
*/
|
||||||
|
#define OS_EXC_MPU_FAULT 4
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Interrupt No. 5 :Bus fault.
|
||||||
|
*/
|
||||||
|
#define OS_EXC_BUS_FAULT 5
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Interrupt No. 6 :Usage fault.
|
||||||
|
*/
|
||||||
|
#define OS_EXC_USAGE_FAULT 6
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Interrupt No. 11 :SVCall.
|
||||||
|
*/
|
||||||
|
#define OS_EXC_SVC_CALL 11
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Interrupt No. 12 :Debug monitor.
|
||||||
|
*/
|
||||||
|
#define OS_EXC_DBG_MONITOR 12
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Interrupt No. 14 :PendSV.
|
||||||
|
*/
|
||||||
|
#define OS_EXC_PEND_SV 14
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Interrupt No. 15 :SysTick.
|
||||||
|
*/
|
||||||
|
#define OS_EXC_SYS_TICK 15
|
||||||
|
|
||||||
|
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Set interrupt vector table.
|
||||||
|
*/
|
||||||
|
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg);
|
||||||
|
#else
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Set interrupt vector table.
|
||||||
|
*/
|
||||||
|
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* @brief: Hardware interrupt entry function.
|
||||||
|
*
|
||||||
|
* @par Description:
|
||||||
|
* This API is used as all hardware interrupt handling function entry.
|
||||||
|
*
|
||||||
|
* @attention:
|
||||||
|
* <ul><li>None.</li></ul>
|
||||||
|
*
|
||||||
|
* @param:None.
|
||||||
|
*
|
||||||
|
* @retval:None.
|
||||||
|
* @par Dependency:
|
||||||
|
* <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
|
||||||
|
* @see None.
|
||||||
|
*/
|
||||||
|
extern VOID HalInterrupt(VOID);
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* @brief: Default vector handling function.
|
||||||
|
*
|
||||||
|
* @par Description:
|
||||||
|
* This API is used to configure interrupt for null function.
|
||||||
|
*
|
||||||
|
* @attention:
|
||||||
|
* <ul><li>None.</li></ul>
|
||||||
|
*
|
||||||
|
* @param:None.
|
||||||
|
*
|
||||||
|
* @retval:None.
|
||||||
|
* @par Dependency:
|
||||||
|
* <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
|
||||||
|
* @see None.
|
||||||
|
*/
|
||||||
|
extern VOID HalHwiDefaultHandler(VOID);
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* @brief: Reset the vector table.
|
||||||
|
*
|
||||||
|
* @par Description:
|
||||||
|
* This API is used to reset the vector table.
|
||||||
|
*
|
||||||
|
* @attention:
|
||||||
|
* <ul><li>None.</li></ul>
|
||||||
|
*
|
||||||
|
* @param:None.
|
||||||
|
*
|
||||||
|
* @retval:None.
|
||||||
|
* @par Dependency:
|
||||||
|
* <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
|
||||||
|
* @see None.
|
||||||
|
*/
|
||||||
|
extern VOID Reset_Handler(VOID);
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* @brief: Pended System Call.
|
||||||
|
*
|
||||||
|
* @par Description:
|
||||||
|
* PendSV can be pended and is useful for an OS to pend an exception
|
||||||
|
* so that an action can be performed after other important tasks are completed.
|
||||||
|
*
|
||||||
|
* @attention:
|
||||||
|
* <ul><li>None.</li></ul>
|
||||||
|
*
|
||||||
|
* @param:None.
|
||||||
|
*
|
||||||
|
* @retval:None.
|
||||||
|
* @par Dependency:
|
||||||
|
* <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
|
||||||
|
* @see None.
|
||||||
|
*/
|
||||||
|
extern VOID HalPendSV(VOID);
|
||||||
|
|
||||||
|
|
||||||
|
#define OS_EXC_IN_INIT 0
|
||||||
|
#define OS_EXC_IN_TASK 1
|
||||||
|
#define OS_EXC_IN_HWI 2
|
||||||
|
|
||||||
|
#define OS_EXC_MAX_BUF_LEN 25
|
||||||
|
#define OS_EXC_MAX_NEST_DEPTH 1
|
||||||
|
|
||||||
|
#define OS_NVIC_SHCSR 0xE000ED24
|
||||||
|
#define OS_NVIC_CCR 0xE000ED14
|
||||||
|
|
||||||
|
#define OS_NVIC_INT_ENABLE_SIZE 0x20
|
||||||
|
#define OS_NVIC_INT_PRI_SIZE 0xF0
|
||||||
|
#define OS_NVIC_EXCPRI_SIZE 0xC
|
||||||
|
#define OS_NVIC_INT_CTRL_SIZE 4
|
||||||
|
#define OS_NVIC_SHCSR_SIZE 4
|
||||||
|
|
||||||
|
#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
|
||||||
|
#define OS_NVIC_INT_ACT_SIZE OS_NVIC_INT_ENABLE_SIZE
|
||||||
|
|
||||||
|
#define OS_EXC_FLAG_NO_FLOAT 0x10000000
|
||||||
|
#define OS_EXC_FLAG_FAULTADDR_VALID 0x01
|
||||||
|
#define OS_EXC_FLAG_IN_HWI 0x02
|
||||||
|
|
||||||
|
#define OS_EXC_IMPRECISE_ACCESS_ADDR 0xABABABAB
|
||||||
|
|
||||||
|
#define OS_EXC_EVENT 0x00000001
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup los_exc
|
||||||
|
* the struct of register files
|
||||||
|
*
|
||||||
|
* description: the register files that saved when exception triggered
|
||||||
|
*
|
||||||
|
* notes:the following register with prefix 'uw' correspond to the registers in the cpu data sheet.
|
||||||
|
*/
|
||||||
|
typedef struct TagExcContext {
|
||||||
|
#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
|
||||||
|
(defined (__FPU_USED ) && (__FPU_USED == 1U)) )
|
||||||
|
UINT32 S16;
|
||||||
|
UINT32 S17;
|
||||||
|
UINT32 S18;
|
||||||
|
UINT32 S19;
|
||||||
|
UINT32 S20;
|
||||||
|
UINT32 S21;
|
||||||
|
UINT32 S22;
|
||||||
|
UINT32 S23;
|
||||||
|
UINT32 S24;
|
||||||
|
UINT32 S25;
|
||||||
|
UINT32 S26;
|
||||||
|
UINT32 S27;
|
||||||
|
UINT32 S28;
|
||||||
|
UINT32 S29;
|
||||||
|
UINT32 S30;
|
||||||
|
UINT32 S31;
|
||||||
|
#endif
|
||||||
|
UINT32 uwR4;
|
||||||
|
UINT32 uwR5;
|
||||||
|
UINT32 uwR6;
|
||||||
|
UINT32 uwR7;
|
||||||
|
UINT32 uwR8;
|
||||||
|
UINT32 uwR9;
|
||||||
|
UINT32 uwR10;
|
||||||
|
UINT32 uwR11;
|
||||||
|
UINT32 uwPriMask;
|
||||||
|
/* auto save */
|
||||||
|
UINT32 uwSP;
|
||||||
|
UINT32 uwR0;
|
||||||
|
UINT32 uwR1;
|
||||||
|
UINT32 uwR2;
|
||||||
|
UINT32 uwR3;
|
||||||
|
UINT32 uwR12;
|
||||||
|
UINT32 uwLR;
|
||||||
|
UINT32 uwPC;
|
||||||
|
UINT32 uwxPSR;
|
||||||
|
#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
|
||||||
|
(defined (__FPU_USED) && (__FPU_USED== 1U)))
|
||||||
|
UINT32 S0;
|
||||||
|
UINT32 S1;
|
||||||
|
UINT32 S2;
|
||||||
|
UINT32 S3;
|
||||||
|
UINT32 S4;
|
||||||
|
UINT32 S5;
|
||||||
|
UINT32 S6;
|
||||||
|
UINT32 S7;
|
||||||
|
UINT32 S8;
|
||||||
|
UINT32 S9;
|
||||||
|
UINT32 S10;
|
||||||
|
UINT32 S11;
|
||||||
|
UINT32 S12;
|
||||||
|
UINT32 S13;
|
||||||
|
UINT32 S14;
|
||||||
|
UINT32 S15;
|
||||||
|
UINT32 FPSCR;
|
||||||
|
UINT32 NO_NAME;
|
||||||
|
#endif
|
||||||
|
} EXC_CONTEXT_S;
|
||||||
|
|
||||||
|
typedef VOID (*EXC_PROC_FUNC)(UINT32, EXC_CONTEXT_S *);
|
||||||
|
VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr);
|
||||||
|
|
||||||
|
VOID HalExcNMI(VOID);
|
||||||
|
VOID HalExcHardFault(VOID);
|
||||||
|
VOID HalExcMemFault(VOID);
|
||||||
|
VOID HalExcBusFault(VOID);
|
||||||
|
VOID HalExcUsageFault(VOID);
|
||||||
|
VOID HalSVCHandler(VOID);
|
||||||
|
VOID HalHwiInit(VOID);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup los_exc
|
||||||
|
* Cortex-M exception types: Record whether a precise BusFault occurred during floating-point lazy state preservation.
|
||||||
|
*/
|
||||||
|
#define OS_EXC_BF_LSPERR 1
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup los_exc
|
||||||
|
* Cortex-M exception types: An error occurred while the bus status register was being pushed.
|
||||||
|
*/
|
||||||
|
#define OS_EXC_BF_STKERR 2
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup los_exc
|
||||||
|
* Cortex-M exception types: An error occurred while the bus status register was out of the stack.
|
||||||
|
*/
|
||||||
|
#define OS_EXC_BF_UNSTKERR 3
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup los_exc
|
||||||
|
* Cortex-M exception types: Bus status register imprecise data access violation.
|
||||||
|
*/
|
||||||
|
#define OS_EXC_BF_IMPRECISERR 4
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup los_exc
|
||||||
|
* Cortex-M exception types: Bus status register exact data access violation.
|
||||||
|
*/
|
||||||
|
#define OS_EXC_BF_PRECISERR 5
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup los_exc
|
||||||
|
* Cortex-M exception types: Bus status register access violation while pointing.
|
||||||
|
*/
|
||||||
|
#define OS_EXC_BF_IBUSERR 6
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup los_exc
|
||||||
|
* Cortex-M exception types: Record whether a MemManage fault occurred during floating-point lazy state preservation.
|
||||||
|
*/
|
||||||
|
#define OS_EXC_MF_MLSPERR 7
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup los_exc
|
||||||
|
* Cortex-M exception types: An error occurred while the memory management status register was being pushed.
|
||||||
|
*/
|
||||||
|
#define OS_EXC_MF_MSTKERR 8
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup los_exc
|
||||||
|
* Cortex-M exception types: An error occurred while the memory management status register was out of the stack.
|
||||||
|
*/
|
||||||
|
#define OS_EXC_MF_MUNSTKERR 9
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup los_exc
|
||||||
|
* Cortex-M exception types: Memory management status register data access violation.
|
||||||
|
*/
|
||||||
|
#define OS_EXC_MF_DACCVIOL 10
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup los_exc
|
||||||
|
* Cortex-M exception types: Memory management status register access violation.
|
||||||
|
*/
|
||||||
|
#define OS_EXC_MF_IACCVIOL 11
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup los_exc
|
||||||
|
* Cortex-M exception types: Incorrect usage indicating that the divisor is zero during the division operation.
|
||||||
|
*/
|
||||||
|
#define OS_EXC_UF_DIVBYZERO 12
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup los_exc
|
||||||
|
* Cortex-M exception types: Usage error, error caused by unaligned access.
|
||||||
|
*/
|
||||||
|
#define OS_EXC_UF_UNALIGNED 13
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup los_exc
|
||||||
|
* Cortex-M exception types: Sticky flag indicating whether a stack overflow error has occurred.
|
||||||
|
*/
|
||||||
|
#define OS_EXC_UF_STKOF 14
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup los_exc
|
||||||
|
* Cortex-M exception types: Incorrect usage attempting to execute coprocessor related instruction.
|
||||||
|
*/
|
||||||
|
#define OS_EXC_UF_NOCP 15
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup los_exc
|
||||||
|
* Cortex-M exception types: Usage error attempting to load EXC_RETURN to PC illegally on exception return.
|
||||||
|
*/
|
||||||
|
#define OS_EXC_UF_INVPC 16
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup los_exc
|
||||||
|
* Cortex-M exception types: Incorrect usage, attempting to cut to ARM state.
|
||||||
|
*/
|
||||||
|
#define OS_EXC_UF_INVSTATE 17
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup los_exc
|
||||||
|
* Cortex-M exception types: Incorrect usage. Executed instruction whose code is undefined.
|
||||||
|
*/
|
||||||
|
#define OS_EXC_UF_UNDEFINSTR 18
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup los_exc
|
||||||
|
* Cortex-M exception types: NMI
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define OS_EXC_CAUSE_NMI 19
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup los_exc
|
||||||
|
* Cortex-M exception types: hard fault
|
||||||
|
*/
|
||||||
|
#define OS_EXC_CAUSE_HARDFAULT 20
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup los_exc
|
||||||
|
* Cortex-M exception types: The task handler exits.
|
||||||
|
*/
|
||||||
|
#define OS_EXC_CAUSE_TASK_EXIT 21
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup los_exc
|
||||||
|
* Cortex-M exception types: A fatal error.
|
||||||
|
*/
|
||||||
|
#define OS_EXC_CAUSE_FATAL_ERR 22
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup los_exc
|
||||||
|
* Cortex-M exception types: Hard Fault caused by a debug event.
|
||||||
|
*/
|
||||||
|
#define OS_EXC_CAUSE_DEBUGEVT 23
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup los_exc
|
||||||
|
* Cortex-M exception types: A hard fault that occurs when a quantity is oriented.
|
||||||
|
*/
|
||||||
|
#define OS_EXC_CAUSE_VECTBL 24
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup los_exc
|
||||||
|
* Exception information structure
|
||||||
|
*
|
||||||
|
* Description: Exception information saved when an exception is triggered on the Cortex-M33 platform.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
typedef struct TagExcInfo {
|
||||||
|
/**< Exception occurrence phase: 0 means that an exception occurs in initialization,
|
||||||
|
* 1 means that an exception occurs in a task, and 2 means that an exception occurs in an interrupt */
|
||||||
|
UINT16 phase;
|
||||||
|
/**< Exception type. When exceptions occur, check the numbers 1 - 21 listed above */
|
||||||
|
UINT16 type;
|
||||||
|
/**< If the exact address access error indicates the wrong access address when the exception occurred */
|
||||||
|
UINT32 faultAddr;
|
||||||
|
/**< An exception occurs in an interrupt, indicating the interrupt number.
|
||||||
|
* An exception occurs in the task, indicating the task ID, or 0xFFFFFFFF if it occurs during initialization */
|
||||||
|
UINT32 thrdPid;
|
||||||
|
/**< Number of nested exceptions. Currently only registered hook functions are supported
|
||||||
|
* when an exception is entered for the first time */
|
||||||
|
UINT16 nestCnt;
|
||||||
|
/**< reserve */
|
||||||
|
UINT16 reserved;
|
||||||
|
/**< Hardware context at the time an exception to the automatic stack floating-point register occurs */
|
||||||
|
EXC_CONTEXT_S *context;
|
||||||
|
} ExcInfo;
|
||||||
|
|
||||||
|
extern UINT32 g_curNestCount;
|
||||||
|
extern UINT32 g_intCount;
|
||||||
|
extern UINT8 g_uwExcTbl[32];
|
||||||
|
extern ExcInfo g_excInfo;
|
||||||
|
|
||||||
|
#define MAX_INT_INFO_SIZE (8 + 0x164)
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#if __cplusplus
|
||||||
|
}
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
#endif /* _LOS_ARCH_INTERRUPT_H */
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _LOS_ARCH_TIMER_H
|
||||||
|
#define _LOS_ARCH_TIMER_H
|
||||||
|
|
||||||
|
#include "los_config.h"
|
||||||
|
#include "los_compiler.h"
|
||||||
|
#include "los_timer.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#if __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#if __cplusplus
|
||||||
|
}
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
#endif /* _LOS_ARCH_TIMER_H */
|
||||||
@@ -0,0 +1,162 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "los_context.h"
|
||||||
|
#include "securec.h"
|
||||||
|
#include "los_arch_context.h"
|
||||||
|
#include "los_arch_interrupt.h"
|
||||||
|
#include "los_task.h"
|
||||||
|
#include "los_sched.h"
|
||||||
|
#include "los_interrupt.h"
|
||||||
|
#include "los_debug.h"
|
||||||
|
|
||||||
|
/* ****************************************************************************
|
||||||
|
Function : ArchInit
|
||||||
|
Description : arch init function
|
||||||
|
Input : None
|
||||||
|
Output : None
|
||||||
|
Return : None
|
||||||
|
**************************************************************************** */
|
||||||
|
LITE_OS_SEC_TEXT_INIT VOID ArchInit(VOID)
|
||||||
|
{
|
||||||
|
HalHwiInit();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ****************************************************************************
|
||||||
|
Function : ArchSysExit
|
||||||
|
Description : Task exit function
|
||||||
|
Input : None
|
||||||
|
Output : None
|
||||||
|
Return : None
|
||||||
|
**************************************************************************** */
|
||||||
|
LITE_OS_SEC_TEXT_MINOR VOID ArchSysExit(VOID)
|
||||||
|
{
|
||||||
|
(VOID)LOS_IntLock();
|
||||||
|
while (1) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ****************************************************************************
|
||||||
|
Function : ArchTskStackInit
|
||||||
|
Description : Task stack initialization function
|
||||||
|
Input : taskID --- TaskID
|
||||||
|
stackSize --- Total size of the stack
|
||||||
|
topStack --- Top of task's stack
|
||||||
|
Output : None
|
||||||
|
Return : Context pointer
|
||||||
|
**************************************************************************** */
|
||||||
|
LITE_OS_SEC_TEXT_INIT VOID *ArchTskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack)
|
||||||
|
{
|
||||||
|
TaskContext *context = (TaskContext *)((UINTPTR)topStack + stackSize - sizeof(TaskContext));
|
||||||
|
|
||||||
|
#if ((defined(__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
|
||||||
|
(defined(__FPU_USED) && (__FPU_USED == 1U)))
|
||||||
|
context->S16 = 0xAA000010;
|
||||||
|
context->S17 = 0xAA000011;
|
||||||
|
context->S18 = 0xAA000012;
|
||||||
|
context->S19 = 0xAA000013;
|
||||||
|
context->S20 = 0xAA000014;
|
||||||
|
context->S21 = 0xAA000015;
|
||||||
|
context->S22 = 0xAA000016;
|
||||||
|
context->S23 = 0xAA000017;
|
||||||
|
context->S24 = 0xAA000018;
|
||||||
|
context->S25 = 0xAA000019;
|
||||||
|
context->S26 = 0xAA00001A;
|
||||||
|
context->S27 = 0xAA00001B;
|
||||||
|
context->S28 = 0xAA00001C;
|
||||||
|
context->S29 = 0xAA00001D;
|
||||||
|
context->S30 = 0xAA00001E;
|
||||||
|
context->S31 = 0xAA00001F;
|
||||||
|
context->S0 = 0xAA000000;
|
||||||
|
context->S1 = 0xAA000001;
|
||||||
|
context->S2 = 0xAA000002;
|
||||||
|
context->S3 = 0xAA000003;
|
||||||
|
context->S4 = 0xAA000004;
|
||||||
|
context->S5 = 0xAA000005;
|
||||||
|
context->S6 = 0xAA000006;
|
||||||
|
context->S7 = 0xAA000007;
|
||||||
|
context->S8 = 0xAA000008;
|
||||||
|
context->S9 = 0xAA000009;
|
||||||
|
context->S10 = 0xAA00000A;
|
||||||
|
context->S11 = 0xAA00000B;
|
||||||
|
context->S12 = 0xAA00000C;
|
||||||
|
context->S13 = 0xAA00000D;
|
||||||
|
context->S14 = 0xAA00000E;
|
||||||
|
context->S15 = 0xAA00000F;
|
||||||
|
context->FPSCR = 0x00000000;
|
||||||
|
context->NO_NAME = 0xAA000011;
|
||||||
|
context->uwExcLR = 0xFFFFFFEDL;
|
||||||
|
#else
|
||||||
|
context->uwExcLR = 0xFFFFFFFDL;
|
||||||
|
#endif
|
||||||
|
context->uwPspLim = (UINT32)topStack;
|
||||||
|
context->uwR4 = 0x04040404L;
|
||||||
|
context->uwR5 = 0x05050505L;
|
||||||
|
context->uwR6 = 0x06060606L;
|
||||||
|
context->uwR7 = 0x07070707L;
|
||||||
|
context->uwR8 = 0x08080808L;
|
||||||
|
context->uwR9 = 0x09090909L;
|
||||||
|
context->uwR10 = 0x10101010L;
|
||||||
|
context->uwR11 = 0x11111111L;
|
||||||
|
context->uwPriMask = 0;
|
||||||
|
context->uwR0 = taskID;
|
||||||
|
context->uwR1 = 0x01010101L;
|
||||||
|
context->uwR2 = 0x02020202L;
|
||||||
|
context->uwR3 = 0x03030303L;
|
||||||
|
context->uwR12 = 0x12121212L;
|
||||||
|
context->uwLR = (UINT32)(UINTPTR)ArchSysExit;
|
||||||
|
context->uwPC = (UINT32)(UINTPTR)OsTaskEntry;
|
||||||
|
context->uwxPSR = 0x01000000L;
|
||||||
|
|
||||||
|
return (VOID *)context;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if (LOSCFG_KERNEL_SIGNAL == 1)
|
||||||
|
VOID *ArchSignalContextInit(VOID *stackPointer, VOID *stackTop, UINTPTR sigHandler, UINT32 param)
|
||||||
|
{
|
||||||
|
UNUSED(stackTop);
|
||||||
|
TaskContext *context = (TaskContext *)((UINTPTR)stackPointer - sizeof(TaskContext));
|
||||||
|
(VOID)memset_s((VOID *)context, sizeof(TaskContext), 0, sizeof(TaskContext));
|
||||||
|
|
||||||
|
context->uwR0 = param;
|
||||||
|
context->uwPC = sigHandler;
|
||||||
|
context->uwxPSR = 0x01000000L; /* Thumb flag, always set 1 */
|
||||||
|
|
||||||
|
return (VOID *)context;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
LITE_OS_SEC_TEXT_INIT UINT32 ArchStartSchedule(VOID)
|
||||||
|
{
|
||||||
|
(VOID)LOS_IntLock();
|
||||||
|
OsSchedStart();
|
||||||
|
HalStartToRun();
|
||||||
|
return LOS_OK; /* never return */
|
||||||
|
}
|
||||||
@@ -0,0 +1,191 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
.syntax unified
|
||||||
|
.arch armv8.1-m.main
|
||||||
|
.fpu vfpv3-d16-fp16
|
||||||
|
.thumb
|
||||||
|
|
||||||
|
.equ OS_NVIC_INT_CTRL, 0xE000ED04
|
||||||
|
.equ OS_NVIC_SYSPRI3, 0xE000ED20
|
||||||
|
.equ OS_NVIC_PENDSV_PRI, 0xF0F00000
|
||||||
|
.equ OS_NVIC_PENDSVSET, 0x10000000
|
||||||
|
|
||||||
|
.section .text
|
||||||
|
.thumb
|
||||||
|
|
||||||
|
.macro SIGNAL_CONTEXT_RESTORE
|
||||||
|
push {r12, lr}
|
||||||
|
blx OsSignalTaskContextRestore
|
||||||
|
pop {r12, lr}
|
||||||
|
cmp r0, #0
|
||||||
|
mov r1, r0
|
||||||
|
bne SignalContextRestore
|
||||||
|
.endm
|
||||||
|
|
||||||
|
.type HalStartToRun, %function
|
||||||
|
.global HalStartToRun
|
||||||
|
HalStartToRun:
|
||||||
|
.fnstart
|
||||||
|
.cantunwind
|
||||||
|
|
||||||
|
ldr r4, =OS_NVIC_SYSPRI3
|
||||||
|
ldr r5, =OS_NVIC_PENDSV_PRI
|
||||||
|
str r5, [r4]
|
||||||
|
|
||||||
|
mov r0, #2
|
||||||
|
msr CONTROL, r0
|
||||||
|
|
||||||
|
ldr r1, =g_losTask
|
||||||
|
ldr r0, [r1, #4]
|
||||||
|
ldr r12, [r0]
|
||||||
|
|
||||||
|
ldr r2, [r12, #4]
|
||||||
|
tst r2, #0x10
|
||||||
|
it ne
|
||||||
|
bne __DisabledFPU
|
||||||
|
|
||||||
|
add r12, r12, #108
|
||||||
|
ldmfd r12!, {r0-r7}
|
||||||
|
add r12, r12, #72
|
||||||
|
msr psp, r12
|
||||||
|
vpush {s0}
|
||||||
|
vpop {s0}
|
||||||
|
|
||||||
|
mov lr, r5
|
||||||
|
cpsie I
|
||||||
|
bx r6
|
||||||
|
|
||||||
|
__DisabledFPU:
|
||||||
|
add r12, r12, #44
|
||||||
|
|
||||||
|
ldmfd r12!, {r0-r7}
|
||||||
|
msr psp, r12
|
||||||
|
mov lr, r5
|
||||||
|
cpsie I
|
||||||
|
bx r6
|
||||||
|
.fnend
|
||||||
|
|
||||||
|
.type ArchIntLock, %function
|
||||||
|
.global ArchIntLock
|
||||||
|
ArchIntLock:
|
||||||
|
.fnstart
|
||||||
|
.cantunwind
|
||||||
|
|
||||||
|
mrs r0, PRIMASK
|
||||||
|
cpsid I
|
||||||
|
bx lr
|
||||||
|
.fnend
|
||||||
|
|
||||||
|
.type ArchIntUnLock, %function
|
||||||
|
.global ArchIntUnLock
|
||||||
|
ArchIntUnLock:
|
||||||
|
.fnstart
|
||||||
|
.cantunwind
|
||||||
|
|
||||||
|
mrs r0, PRIMASK
|
||||||
|
cpsie I
|
||||||
|
bx lr
|
||||||
|
.fnend
|
||||||
|
|
||||||
|
.type ArchIntRestore, %function
|
||||||
|
.global ArchIntRestore
|
||||||
|
ArchIntRestore:
|
||||||
|
.fnstart
|
||||||
|
.cantunwind
|
||||||
|
|
||||||
|
msr PRIMASK, r0
|
||||||
|
bx lr
|
||||||
|
.fnend
|
||||||
|
|
||||||
|
.type ArchTaskSchedule, %function
|
||||||
|
.global ArchTaskSchedule
|
||||||
|
ArchTaskSchedule:
|
||||||
|
.fnstart
|
||||||
|
.cantunwind
|
||||||
|
|
||||||
|
ldr r0, =OS_NVIC_INT_CTRL
|
||||||
|
ldr r1, =OS_NVIC_PENDSVSET
|
||||||
|
str r1, [r0]
|
||||||
|
dsb
|
||||||
|
isb
|
||||||
|
bx lr
|
||||||
|
.fnend
|
||||||
|
|
||||||
|
.type HalPendSV, %function
|
||||||
|
.global HalPendSV
|
||||||
|
HalPendSV:
|
||||||
|
.fnstart
|
||||||
|
.cantunwind
|
||||||
|
|
||||||
|
mrs r12, PRIMASK
|
||||||
|
cpsid I
|
||||||
|
|
||||||
|
HalTaskSwitch:
|
||||||
|
SIGNAL_CONTEXT_RESTORE
|
||||||
|
|
||||||
|
push {r12, lr}
|
||||||
|
blx OsSchedTaskSwitch
|
||||||
|
pop {r12, lr}
|
||||||
|
cmp r0, #0
|
||||||
|
mov r0, lr
|
||||||
|
bne TaskContextSwitch
|
||||||
|
msr PRIMASK, r12
|
||||||
|
bx lr
|
||||||
|
|
||||||
|
TaskContextSwitch:
|
||||||
|
mov lr, r0
|
||||||
|
mrs r0, psp
|
||||||
|
tst lr, #0x10
|
||||||
|
it eq
|
||||||
|
vstmdbeq r0!, {d8-d15}
|
||||||
|
mrs r2, psplim
|
||||||
|
mov r3, lr
|
||||||
|
stmfd r0!, {r2-r12}
|
||||||
|
|
||||||
|
ldr r5, =g_losTask
|
||||||
|
ldr r6, [r5]
|
||||||
|
str r0, [r6]
|
||||||
|
|
||||||
|
ldr r0, [r5, #4]
|
||||||
|
str r0, [r5]
|
||||||
|
ldr r1, [r0]
|
||||||
|
|
||||||
|
SignalContextRestore:
|
||||||
|
ldmfd r1!, {r2-r12}
|
||||||
|
msr psplim, r2
|
||||||
|
tst r3, #0x10
|
||||||
|
it eq
|
||||||
|
vldmiaeq r1!, {d8-d15}
|
||||||
|
msr psp, r1
|
||||||
|
msr PRIMASK, r12
|
||||||
|
|
||||||
|
bx lr
|
||||||
|
.fnend
|
||||||
@@ -0,0 +1,381 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
.syntax unified
|
||||||
|
.arch armv8.1-m.main
|
||||||
|
.fpu vfpv3-d16-fp16
|
||||||
|
.thumb
|
||||||
|
.section .text
|
||||||
|
|
||||||
|
.global HalExcNMI
|
||||||
|
.global HalExcHardFault
|
||||||
|
.global HalExcMemFault
|
||||||
|
.global HalExcBusFault
|
||||||
|
.global HalExcUsageFault
|
||||||
|
.global HalSVCHandler
|
||||||
|
|
||||||
|
.extern HalExcHandleEntry
|
||||||
|
.extern g_uwExcTbl
|
||||||
|
.extern g_taskScheduled
|
||||||
|
|
||||||
|
.equ OS_FLG_BGD_ACTIVE, 0x0002
|
||||||
|
.equ OS_EXC_CAUSE_NMI, 19
|
||||||
|
.equ OS_EXC_CAUSE_HARDFAULT, 20
|
||||||
|
|
||||||
|
.equ HF_DEBUGEVT, 23
|
||||||
|
.equ HF_VECTBL, 24
|
||||||
|
|
||||||
|
.equ FLAG_ADDR_VALID, 0x10000
|
||||||
|
.equ FLAG_HWI_ACTIVE, 0x20000
|
||||||
|
.equ FLAG_NO_FLOAT, 0x10000000
|
||||||
|
|
||||||
|
.equ OS_NVIC_FSR, 0xE000ED28 //include BusFault/MemFault/UsageFault State Register
|
||||||
|
.equ OS_NVIC_HFSR, 0xE000ED2C //HardFault State Register
|
||||||
|
.equ OS_NVIC_BFAR, 0xE000ED38
|
||||||
|
.equ OS_NVIC_MMAR, 0xE000ED34
|
||||||
|
.equ OS_NVIC_ACT_BASE, 0xE000E300
|
||||||
|
.equ OS_NVIC_SHCSRS, 0xE000ED24
|
||||||
|
.equ OS_NVIC_SHCSR_MASK, 0xC00
|
||||||
|
|
||||||
|
.type HalExcNMI, %function
|
||||||
|
.global HalExcNMI
|
||||||
|
HalExcNMI:
|
||||||
|
.fnstart
|
||||||
|
.cantunwind
|
||||||
|
MOV R0, #OS_EXC_CAUSE_NMI
|
||||||
|
MOV R1, #0
|
||||||
|
B osExcDispatch
|
||||||
|
.fnend
|
||||||
|
|
||||||
|
.type HalExcHardFault, %function
|
||||||
|
.global HalExcHardFault
|
||||||
|
HalExcHardFault:
|
||||||
|
.fnstart
|
||||||
|
.cantunwind
|
||||||
|
MOV R0, #OS_EXC_CAUSE_HARDFAULT
|
||||||
|
LDR R2, =OS_NVIC_HFSR
|
||||||
|
LDR R2, [R2]
|
||||||
|
|
||||||
|
MOV R1, #HF_DEBUGEVT
|
||||||
|
ORR R0, R0, R1, LSL #0x8
|
||||||
|
TST R2, #0x80000000
|
||||||
|
BNE osExcDispatch // DEBUGEVT
|
||||||
|
|
||||||
|
AND R0, R0, #0x000000FF
|
||||||
|
MOV R1, #HF_VECTBL
|
||||||
|
ORR R0, R0, R1, LSL #0x8
|
||||||
|
TST R2, #0x00000002
|
||||||
|
BNE osExcDispatch // VECTBL
|
||||||
|
|
||||||
|
//if not DEBUGEVT and VECTBL then is FORCED
|
||||||
|
AND R0, R0, #0x000000FF
|
||||||
|
|
||||||
|
LDR R2, =OS_NVIC_FSR
|
||||||
|
LDR R2, [R2]
|
||||||
|
|
||||||
|
TST R2, #0x8000 // BFARVALID
|
||||||
|
BNE _HFBusFault // BusFault
|
||||||
|
|
||||||
|
TST R2, #0x80 // MMARVALID
|
||||||
|
BNE _HFMemFault // MemFault
|
||||||
|
|
||||||
|
MOV R12, #0
|
||||||
|
B osHFExcCommonBMU
|
||||||
|
.fnend
|
||||||
|
|
||||||
|
.type _HFBusFault, %function
|
||||||
|
|
||||||
|
_HFBusFault:
|
||||||
|
.fnstart
|
||||||
|
.cantunwind
|
||||||
|
LDR R1, =OS_NVIC_BFAR
|
||||||
|
LDR R1, [R1]
|
||||||
|
MOV R12, #FLAG_ADDR_VALID
|
||||||
|
B osHFExcCommonBMU
|
||||||
|
.fnend
|
||||||
|
|
||||||
|
.type _HFMemFault, %function
|
||||||
|
|
||||||
|
_HFMemFault:
|
||||||
|
.fnstart
|
||||||
|
.cantunwind
|
||||||
|
LDR R1, =OS_NVIC_MMAR
|
||||||
|
LDR R1, [R1]
|
||||||
|
MOV R12, #FLAG_ADDR_VALID
|
||||||
|
.fnend
|
||||||
|
|
||||||
|
.type osHFExcCommonBMU, %function
|
||||||
|
.global osHFExcCommonBMU
|
||||||
|
osHFExcCommonBMU:
|
||||||
|
.fnstart
|
||||||
|
.cantunwind
|
||||||
|
CLZ R2, R2
|
||||||
|
LDR R3, =g_uwExcTbl
|
||||||
|
ADD R3, R3, R2
|
||||||
|
LDRB R2, [R3]
|
||||||
|
ORR R0, R0, R2, LSL #0x8
|
||||||
|
ORR R0, R0, R12
|
||||||
|
B osExcDispatch
|
||||||
|
.fnend
|
||||||
|
|
||||||
|
.type HalSVCHandler, %function
|
||||||
|
.global HalSVCHandler
|
||||||
|
HalSVCHandler:
|
||||||
|
.fnstart
|
||||||
|
.cantunwind
|
||||||
|
TST LR, #0x4
|
||||||
|
ITE EQ
|
||||||
|
MRSEQ R0, MSP
|
||||||
|
MRSNE R0, PSP
|
||||||
|
LDR R1, [R0,#24]
|
||||||
|
LDRB R0, [R1,#-2]
|
||||||
|
MOV R1, #0
|
||||||
|
B osExcDispatch
|
||||||
|
.fnend
|
||||||
|
|
||||||
|
.type HalExcBusFault, %function
|
||||||
|
.global HalExcBusFault
|
||||||
|
HalExcBusFault:
|
||||||
|
.fnstart
|
||||||
|
.cantunwind
|
||||||
|
LDR R0, =OS_NVIC_FSR
|
||||||
|
LDR R0, [R0]
|
||||||
|
|
||||||
|
TST R0, #0x8000 // BFARVALID
|
||||||
|
BEQ _ExcBusNoADDR
|
||||||
|
LDR R1, =OS_NVIC_BFAR
|
||||||
|
LDR R1, [R1]
|
||||||
|
MOV R12, #FLAG_ADDR_VALID
|
||||||
|
AND R0, R0, #0x1F00
|
||||||
|
|
||||||
|
B osExcCommonBMU
|
||||||
|
.fnend
|
||||||
|
|
||||||
|
.type _ExcBusNoADDR, %function
|
||||||
|
.global _ExcBusNoADDR
|
||||||
|
_ExcBusNoADDR:
|
||||||
|
.fnstart
|
||||||
|
.cantunwind
|
||||||
|
MOV R12, #0
|
||||||
|
B osExcCommonBMU
|
||||||
|
.fnend
|
||||||
|
|
||||||
|
.type HalExcMemFault, %function
|
||||||
|
.global HalExcMemFault
|
||||||
|
HalExcMemFault:
|
||||||
|
.fnstart
|
||||||
|
.cantunwind
|
||||||
|
LDR R0, =OS_NVIC_FSR
|
||||||
|
LDR R0, [R0]
|
||||||
|
|
||||||
|
TST R0, #0x80 // MMARVALID
|
||||||
|
BEQ _ExcMemNoADDR
|
||||||
|
LDR R1, =OS_NVIC_MMAR
|
||||||
|
LDR R1, [R1]
|
||||||
|
MOV R12, #FLAG_ADDR_VALID
|
||||||
|
AND R0, R0, #0x1B
|
||||||
|
|
||||||
|
B osExcCommonBMU
|
||||||
|
.fnend
|
||||||
|
|
||||||
|
.type _ExcMemNoADDR, %function
|
||||||
|
.global _ExcMemNoADDR
|
||||||
|
_ExcMemNoADDR:
|
||||||
|
.fnstart
|
||||||
|
.cantunwind
|
||||||
|
MOV R12, #0
|
||||||
|
B osExcCommonBMU
|
||||||
|
.fnend
|
||||||
|
|
||||||
|
.type HalExcUsageFault, %function
|
||||||
|
.global HalExcUsageFault
|
||||||
|
HalExcUsageFault:
|
||||||
|
.fnstart
|
||||||
|
.cantunwind
|
||||||
|
LDR R0, =OS_NVIC_FSR
|
||||||
|
LDR R0, [R0]
|
||||||
|
|
||||||
|
MOVW R1, #0x031F
|
||||||
|
LSL R1, R1, #16
|
||||||
|
AND R0, R0, R1
|
||||||
|
MOV R12, #0
|
||||||
|
|
||||||
|
.fnend
|
||||||
|
|
||||||
|
.type osExcCommonBMU, %function
|
||||||
|
.global osExcCommonBMU
|
||||||
|
osExcCommonBMU:
|
||||||
|
.fnstart
|
||||||
|
.cantunwind
|
||||||
|
CLZ R0, R0
|
||||||
|
LDR R3, =g_uwExcTbl
|
||||||
|
ADD R3, R3, R0
|
||||||
|
LDRB R0, [R3]
|
||||||
|
ORR R0, R0, R12
|
||||||
|
.fnend
|
||||||
|
// R0 -- EXCCAUSE(bit 16 is 1 if EXCADDR valid), R1 -- EXCADDR
|
||||||
|
|
||||||
|
.type osExcDispatch, %function
|
||||||
|
.global osExcDispatch
|
||||||
|
osExcDispatch:
|
||||||
|
.fnstart
|
||||||
|
.cantunwind
|
||||||
|
LDR R2, =OS_NVIC_ACT_BASE
|
||||||
|
MOV R12, #16 // R12 is hwi check loop counter
|
||||||
|
.fnend
|
||||||
|
|
||||||
|
.type _hwiActiveCheck, %function
|
||||||
|
.global _hwiActiveCheck
|
||||||
|
_hwiActiveCheck:
|
||||||
|
.fnstart
|
||||||
|
.cantunwind
|
||||||
|
LDR R3, [R2] // R3 store active hwi register when exc
|
||||||
|
CMP R3, #0
|
||||||
|
BEQ _hwiActiveCheckNext
|
||||||
|
|
||||||
|
// exc occurred in IRQ
|
||||||
|
ORR R0, R0, #FLAG_HWI_ACTIVE
|
||||||
|
RBIT R2, R3
|
||||||
|
CLZ R2, R2
|
||||||
|
AND R12, R12, #1
|
||||||
|
ADD R2, R2, R12, LSL #5 // calculate R2 (hwi number) as pid
|
||||||
|
.fnend
|
||||||
|
|
||||||
|
.type _ExcInMSP, %function
|
||||||
|
.global _ExcInMSP
|
||||||
|
_ExcInMSP:
|
||||||
|
.fnstart
|
||||||
|
.cantunwind
|
||||||
|
CMP LR, #0xFFFFFFE9
|
||||||
|
BNE _NoFloatInMsp
|
||||||
|
ADD R3, R13, #104
|
||||||
|
PUSH {R3}
|
||||||
|
MRS R12, PRIMASK // store message-->exc: disable int?
|
||||||
|
PUSH {R4-R12} // store message-->exc: {R4-R12}
|
||||||
|
VPUSH {D8-D15}
|
||||||
|
B _handleEntry
|
||||||
|
.fnend
|
||||||
|
|
||||||
|
.type _NoFloatInMsp, %function
|
||||||
|
.global _NoFloatInMsp
|
||||||
|
_NoFloatInMsp:
|
||||||
|
.fnstart
|
||||||
|
.cantunwind
|
||||||
|
ADD R3, R13, #32
|
||||||
|
PUSH {R3} // save IRQ SP // store message-->exc: MSP(R13)
|
||||||
|
|
||||||
|
MRS R12, PRIMASK // store message-->exc: disable int?
|
||||||
|
PUSH {R4-R12} // store message-->exc: {R4-R12}
|
||||||
|
ORR R0, R0, #FLAG_NO_FLOAT
|
||||||
|
B _handleEntry
|
||||||
|
.fnend
|
||||||
|
|
||||||
|
.type _hwiActiveCheckNext, %function
|
||||||
|
.global _hwiActiveCheckNext
|
||||||
|
_hwiActiveCheckNext:
|
||||||
|
.fnstart
|
||||||
|
.cantunwind
|
||||||
|
ADD R2, R2, #4 // next NVIC ACT ADDR
|
||||||
|
SUBS R12, R12, #1
|
||||||
|
BNE _hwiActiveCheck
|
||||||
|
|
||||||
|
/*NMI interrupt excption*/
|
||||||
|
LDR R2, =OS_NVIC_SHCSRS
|
||||||
|
LDRH R2, [R2]
|
||||||
|
LDR R3, =OS_NVIC_SHCSR_MASK
|
||||||
|
AND R2, R2, R3
|
||||||
|
CMP R2, #0
|
||||||
|
BNE _ExcInMSP
|
||||||
|
// exc occurred in Task or Init or exc
|
||||||
|
// reserved for register info from task stack
|
||||||
|
|
||||||
|
LDR R2, =g_taskScheduled
|
||||||
|
LDR R2, [R2]
|
||||||
|
TST R2, #1 // OS_FLG_BGD_ACTIVE
|
||||||
|
BEQ _ExcInMSP // if exc occurred in Init then branch
|
||||||
|
|
||||||
|
|
||||||
|
CMP LR, #0xFFFFFFED //auto push floating registers
|
||||||
|
BNE _NoFloatInPsp
|
||||||
|
|
||||||
|
// exc occurred in Task
|
||||||
|
MOV R2, R13
|
||||||
|
SUB R13, #96 // add 8 Bytes reg(for STMFD)
|
||||||
|
|
||||||
|
MRS R3, PSP
|
||||||
|
ADD R12, R3, #104
|
||||||
|
PUSH {R12} // save task SP
|
||||||
|
|
||||||
|
MRS R12, PRIMASK
|
||||||
|
PUSH {R4-R12}
|
||||||
|
VPUSH {D8-D15}
|
||||||
|
|
||||||
|
// copy auto saved task register
|
||||||
|
|
||||||
|
LDMFD R3!, {R4-R11} // R4-R11 store PSP reg(auto push when exc in task)
|
||||||
|
VLDMIA R3!, {D8-D15}
|
||||||
|
VSTMDB R2!, {D8-D15}
|
||||||
|
STMFD R2!, {R4-R11}
|
||||||
|
B _handleEntry
|
||||||
|
.fnend
|
||||||
|
|
||||||
|
.type _NoFloatInPsp, %function
|
||||||
|
.global _NoFloatInPsp
|
||||||
|
_NoFloatInPsp:
|
||||||
|
.fnstart
|
||||||
|
.cantunwind
|
||||||
|
MOV R2, R13 // no auto push floating registers
|
||||||
|
SUB R13, #32 // add 8 Bytes reg(for STMFD)
|
||||||
|
|
||||||
|
MRS R3, PSP
|
||||||
|
ADD R12, R3, #32
|
||||||
|
PUSH {R12} // save task SP
|
||||||
|
|
||||||
|
MRS R12, PRIMASK
|
||||||
|
PUSH {R4-R12}
|
||||||
|
|
||||||
|
LDMFD R3, {R4-R11} // R4-R11 store PSP reg(auto push when exc in task)
|
||||||
|
STMFD R2!, {R4-R11}
|
||||||
|
ORR R0, R0, #FLAG_NO_FLOAT
|
||||||
|
.fnend
|
||||||
|
|
||||||
|
.type _handleEntry, %function
|
||||||
|
.global _handleEntry
|
||||||
|
_handleEntry:
|
||||||
|
.fnstart
|
||||||
|
.cantunwind
|
||||||
|
MOV R3, R13 // R13:the 4th param
|
||||||
|
CPSID I
|
||||||
|
CPSID F
|
||||||
|
B HalExcHandleEntry
|
||||||
|
|
||||||
|
NOP
|
||||||
|
.fnend
|
||||||
|
|
||||||
@@ -0,0 +1,657 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
#include "los_interrupt.h"
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include "securec.h"
|
||||||
|
#include "los_context.h"
|
||||||
|
#include "los_arch_interrupt.h"
|
||||||
|
#include "los_debug.h"
|
||||||
|
#include "los_hook.h"
|
||||||
|
#include "los_task.h"
|
||||||
|
#include "los_sched.h"
|
||||||
|
#include "los_memory.h"
|
||||||
|
#include "los_membox.h"
|
||||||
|
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
|
||||||
|
#include "los_cpup.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define DEF_HANDLER_START_INDEX 2
|
||||||
|
UINT32 g_intCount = 0;
|
||||||
|
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_hwi
|
||||||
|
* Hardware interrupt form mapping handling function array.
|
||||||
|
*/
|
||||||
|
STATIC HWI_PROC_FUNC __attribute__((aligned(LOSCFG_ARCH_HWI_VECTOR_ALIGN))) g_hwiForm[OS_VECTOR_CNT] = {0};
|
||||||
|
|
||||||
|
#if (LOSCFG_DEBUG_TOOLS == 1)
|
||||||
|
STATIC UINT32 g_hwiFormCnt[OS_HWI_MAX_NUM] = {0};
|
||||||
|
STATIC CHAR *g_hwiFormName[OS_HWI_MAX_NUM] = {0};
|
||||||
|
|
||||||
|
UINT32 OsGetHwiFormCnt(UINT32 index)
|
||||||
|
{
|
||||||
|
return g_hwiFormCnt[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
CHAR *OsGetHwiFormName(UINT32 index)
|
||||||
|
{
|
||||||
|
return g_hwiFormName[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL OsGetHwiCreated(UINT32 index)
|
||||||
|
{
|
||||||
|
if (g_hwiForm[index] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
HWI_PROC_FUNC pfnHandler;
|
||||||
|
VOID *pParm;
|
||||||
|
} HWI_HANDLER_FUNC;
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_hwi
|
||||||
|
* Hardware interrupt handler form mapping handling function array.
|
||||||
|
*/
|
||||||
|
STATIC HWI_HANDLER_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }};
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_hwi
|
||||||
|
* Set interrupt vector table.
|
||||||
|
*/
|
||||||
|
VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg)
|
||||||
|
{
|
||||||
|
if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
|
||||||
|
g_hwiForm[num + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalInterrupt;
|
||||||
|
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector;
|
||||||
|
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pParm = arg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
/* *
|
||||||
|
* @ingroup los_hwi
|
||||||
|
* hardware interrupt handler form mapping handling function array.
|
||||||
|
*/
|
||||||
|
STATIC HWI_PROC_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {0};
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_hwi
|
||||||
|
* Set interrupt vector table.
|
||||||
|
*/
|
||||||
|
VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector)
|
||||||
|
{
|
||||||
|
if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
|
||||||
|
g_hwiForm[num + OS_SYS_VECTOR_CNT] = HalInterrupt;
|
||||||
|
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT] = vector;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
WEAK VOID SysTick_Handler(VOID)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ****************************************************************************
|
||||||
|
Function : HwiNumGet
|
||||||
|
Description : Get an interrupt number
|
||||||
|
Input : None
|
||||||
|
Output : None
|
||||||
|
Return : Interrupt Indexes number
|
||||||
|
**************************************************************************** */
|
||||||
|
STATIC UINT32 HwiNumGet(VOID)
|
||||||
|
{
|
||||||
|
return __get_IPSR();
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
|
||||||
|
{
|
||||||
|
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||||
|
return OS_ERRNO_HWI_NUM_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
|
||||||
|
{
|
||||||
|
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||||
|
return OS_ERRNO_HWI_NUM_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
NVIC_DisableIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority)
|
||||||
|
{
|
||||||
|
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||||
|
return OS_ERRNO_HWI_NUM_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (priority > OS_HWI_PRIO_LOWEST) {
|
||||||
|
return OS_ERRNO_HWI_PRIO_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
NVIC_SetPriority((IRQn_Type)hwiNum, priority);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
|
||||||
|
{
|
||||||
|
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||||
|
return OS_ERRNO_HWI_NUM_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
|
||||||
|
{
|
||||||
|
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||||
|
return OS_ERRNO_HWI_NUM_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
HwiControllerOps g_archHwiOps = {
|
||||||
|
.enableIrq = HwiUnmask,
|
||||||
|
.disableIrq = HwiMask,
|
||||||
|
.setIrqPriority = HwiSetPriority,
|
||||||
|
.getCurIrqNum = HwiNumGet,
|
||||||
|
.triggerIrq = HwiPending,
|
||||||
|
.clearIrq = HwiClear,
|
||||||
|
};
|
||||||
|
|
||||||
|
inline UINT32 ArchIsIntActive(VOID)
|
||||||
|
{
|
||||||
|
return (g_intCount > 0);
|
||||||
|
}
|
||||||
|
/* ****************************************************************************
|
||||||
|
Function : HalHwiDefaultHandler
|
||||||
|
Description : default handler of the hardware interrupt
|
||||||
|
Input : None
|
||||||
|
Output : None
|
||||||
|
Return : None
|
||||||
|
**************************************************************************** */
|
||||||
|
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
|
||||||
|
{
|
||||||
|
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet());
|
||||||
|
while (1) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
WEAK VOID HalPreInterruptHandler(UINT32 arg)
|
||||||
|
{
|
||||||
|
(VOID)arg;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
WEAK VOID HalAftInterruptHandler(UINT32 arg)
|
||||||
|
{
|
||||||
|
(VOID)arg;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ****************************************************************************
|
||||||
|
Function : HalInterrupt
|
||||||
|
Description : Hardware interrupt entry function
|
||||||
|
Input : None
|
||||||
|
Output : None
|
||||||
|
Return : None
|
||||||
|
**************************************************************************** */
|
||||||
|
LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
|
||||||
|
{
|
||||||
|
UINT32 hwiIndex;
|
||||||
|
UINT32 intSave;
|
||||||
|
|
||||||
|
#if (LOSCFG_KERNEL_RUNSTOP == 1)
|
||||||
|
SCB->SCR &= (UINT32) ~((UINT32)SCB_SCR_SLEEPDEEP_Msk);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
intSave = LOS_IntLock();
|
||||||
|
g_intCount++;
|
||||||
|
LOS_IntRestore(intSave);
|
||||||
|
|
||||||
|
hwiIndex = HwiNumGet();
|
||||||
|
|
||||||
|
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
|
||||||
|
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
|
||||||
|
OsCpupIrqStart(hwiIndex);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
HalPreInterruptHandler(hwiIndex);
|
||||||
|
|
||||||
|
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
|
||||||
|
if (g_hwiHandlerForm[hwiIndex].pfnHandler != 0) {
|
||||||
|
g_hwiHandlerForm[hwiIndex].pfnHandler((VOID *)g_hwiHandlerForm[hwiIndex].pParm);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
if (g_hwiHandlerForm[hwiIndex] != 0) {
|
||||||
|
g_hwiHandlerForm[hwiIndex]();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (LOSCFG_DEBUG_TOOLS == 1)
|
||||||
|
++g_hwiFormCnt[hwiIndex];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
HalAftInterruptHandler(hwiIndex);
|
||||||
|
|
||||||
|
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
|
||||||
|
OsCpupIrqEnd(hwiIndex);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
OsHookCall(LOS_HOOK_TYPE_ISR_EXIT, hwiIndex);
|
||||||
|
|
||||||
|
intSave = LOS_IntLock();
|
||||||
|
g_intCount--;
|
||||||
|
LOS_IntRestore(intSave);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ****************************************************************************
|
||||||
|
Function : ArchHwiCreate
|
||||||
|
Description : create hardware interrupt
|
||||||
|
Input : hwiNum --- hwi num to create
|
||||||
|
hwiPrio --- priority of the hwi
|
||||||
|
hwiMode --- unused
|
||||||
|
hwiHandler --- hwi handler
|
||||||
|
irqParam --- param of the hwi handler
|
||||||
|
Output : None
|
||||||
|
Return : LOS_OK on success or error code on failure
|
||||||
|
**************************************************************************** */
|
||||||
|
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
||||||
|
HWI_PRIOR_T hwiPrio,
|
||||||
|
HWI_MODE_T hwiMode,
|
||||||
|
HWI_PROC_FUNC hwiHandler,
|
||||||
|
HwiIrqParam *irqParam)
|
||||||
|
{
|
||||||
|
(VOID)hwiMode;
|
||||||
|
UINT32 intSave;
|
||||||
|
|
||||||
|
if (hwiHandler == NULL) {
|
||||||
|
return OS_ERRNO_HWI_PROC_FUNC_NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||||
|
return OS_ERRNO_HWI_NUM_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
|
||||||
|
return OS_ERRNO_HWI_ALREADY_CREATED;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hwiPrio > OS_HWI_PRIO_LOWEST) {
|
||||||
|
return OS_ERRNO_HWI_PRIO_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
intSave = LOS_IntLock();
|
||||||
|
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
|
||||||
|
if (irqParam != NULL) {
|
||||||
|
OsSetVector(hwiNum, hwiHandler, irqParam->pDevId);
|
||||||
|
} else {
|
||||||
|
OsSetVector(hwiNum, hwiHandler, NULL);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
(VOID)irqParam;
|
||||||
|
OsSetVector(hwiNum, hwiHandler);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (LOSCFG_DEBUG_TOOLS == 1)
|
||||||
|
if ((irqParam != NULL) && (irqParam->pName != NULL)) {
|
||||||
|
g_hwiFormName[hwiNum + OS_SYS_VECTOR_CNT] = (CHAR *)irqParam->pName;
|
||||||
|
}
|
||||||
|
g_hwiFormCnt[hwiNum + OS_SYS_VECTOR_CNT] = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
HwiUnmask((IRQn_Type)hwiNum);
|
||||||
|
HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
|
||||||
|
|
||||||
|
LOS_IntRestore(intSave);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ****************************************************************************
|
||||||
|
Function : ArchHwiDelete
|
||||||
|
Description : Delete hardware interrupt
|
||||||
|
Input : hwiNum --- hwi num to delete
|
||||||
|
irqParam --- param of the hwi handler
|
||||||
|
Output : None
|
||||||
|
Return : LOS_OK on success or error code on failure
|
||||||
|
**************************************************************************** */
|
||||||
|
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam)
|
||||||
|
{
|
||||||
|
(VOID)irqParam;
|
||||||
|
UINT32 intSave;
|
||||||
|
|
||||||
|
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||||
|
return OS_ERRNO_HWI_NUM_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
HwiMask((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
|
intSave = LOS_IntLock();
|
||||||
|
|
||||||
|
g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
|
||||||
|
|
||||||
|
LOS_IntRestore(intSave);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define FAULT_STATUS_REG_BIT 32
|
||||||
|
#define USGFAULT (1 << 18)
|
||||||
|
#define BUSFAULT (1 << 17)
|
||||||
|
#define MEMFAULT (1 << 16)
|
||||||
|
#define DIV0FAULT (1 << 4)
|
||||||
|
#define UNALIGNFAULT (1 << 3)
|
||||||
|
#define HARDFAULT_IRQN (-13)
|
||||||
|
|
||||||
|
ExcInfo g_excInfo = {0};
|
||||||
|
|
||||||
|
UINT8 g_uwExcTbl[FAULT_STATUS_REG_BIT] = {
|
||||||
|
0, 0, 0, 0,
|
||||||
|
0, 0, OS_EXC_UF_DIVBYZERO, OS_EXC_UF_UNALIGNED,
|
||||||
|
0, 0, 0, OS_EXC_UF_STKOF,
|
||||||
|
OS_EXC_UF_NOCP, OS_EXC_UF_INVPC, OS_EXC_UF_INVSTATE, OS_EXC_UF_UNDEFINSTR,
|
||||||
|
0, 0, OS_EXC_BF_LSPERR, OS_EXC_BF_STKERR,
|
||||||
|
OS_EXC_BF_UNSTKERR, OS_EXC_BF_IMPRECISERR, OS_EXC_BF_PRECISERR, OS_EXC_BF_IBUSERR,
|
||||||
|
0, 0, OS_EXC_MF_MLSPERR, OS_EXC_MF_MSTKERR,
|
||||||
|
OS_EXC_MF_MUNSTKERR, 0, OS_EXC_MF_DACCVIOL, OS_EXC_MF_IACCVIOL
|
||||||
|
};
|
||||||
|
|
||||||
|
#if (LOSCFG_KERNEL_PRINTF != 0)
|
||||||
|
STATIC VOID OsExcNvicDump(VOID)
|
||||||
|
{
|
||||||
|
#define OS_NR_NVIC_EXC_DUMP_TYPES 7
|
||||||
|
UINT32 *base = NULL;
|
||||||
|
UINT32 len, i, j;
|
||||||
|
UINT32 rgNvicBases[OS_NR_NVIC_EXC_DUMP_TYPES] = {
|
||||||
|
OS_NVIC_SETENA_BASE, OS_NVIC_SETPEND_BASE, OS_NVIC_INT_ACT_BASE,
|
||||||
|
OS_NVIC_PRI_BASE, OS_NVIC_EXCPRI_BASE, OS_NVIC_SHCSR, OS_NVIC_INT_CTRL
|
||||||
|
};
|
||||||
|
UINT32 rgNvicLens[OS_NR_NVIC_EXC_DUMP_TYPES] = {
|
||||||
|
OS_NVIC_INT_ENABLE_SIZE, OS_NVIC_INT_PEND_SIZE, OS_NVIC_INT_ACT_SIZE,
|
||||||
|
OS_NVIC_INT_PRI_SIZE, OS_NVIC_EXCPRI_SIZE, OS_NVIC_SHCSR_SIZE,
|
||||||
|
OS_NVIC_INT_CTRL_SIZE
|
||||||
|
};
|
||||||
|
CHAR strRgEnable[] = "enable";
|
||||||
|
CHAR strRgPending[] = "pending";
|
||||||
|
CHAR strRgActive[] = "active";
|
||||||
|
CHAR strRgPriority[] = "priority";
|
||||||
|
CHAR strRgException[] = "exception";
|
||||||
|
CHAR strRgShcsr[] = "shcsr";
|
||||||
|
CHAR strRgIntCtrl[] = "control";
|
||||||
|
CHAR *strRgs[] = {
|
||||||
|
strRgEnable, strRgPending, strRgActive, strRgPriority,
|
||||||
|
strRgException, strRgShcsr, strRgIntCtrl
|
||||||
|
};
|
||||||
|
|
||||||
|
PRINTK("\r\nOS exception NVIC dump:\n");
|
||||||
|
for (i = 0; i < OS_NR_NVIC_EXC_DUMP_TYPES; i++) {
|
||||||
|
base = (UINT32 *)rgNvicBases[i];
|
||||||
|
len = rgNvicLens[i];
|
||||||
|
PRINTK("interrupt %s register, base address: %p, size: 0x%x\n", strRgs[i], base, len);
|
||||||
|
len = (len >> 2); /* 2: Gets the next register offset */
|
||||||
|
for (j = 0; j < len; j++) {
|
||||||
|
PRINTK("0x%x ", *(base + j));
|
||||||
|
if ((j != 0) && ((j % 16) == 0)) { /* 16: print wrap line */
|
||||||
|
PRINTK("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
PRINTK("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC VOID OsExcTypeInfo(const ExcInfo *excInfo)
|
||||||
|
{
|
||||||
|
CHAR *phaseStr[] = {"exc in init", "exc in task", "exc in hwi"};
|
||||||
|
|
||||||
|
PRINTK("Type = %d\n", excInfo->type);
|
||||||
|
PRINTK("ThrdPid = %d\n", excInfo->thrdPid);
|
||||||
|
PRINTK("Phase = %s\n", phaseStr[excInfo->phase]);
|
||||||
|
PRINTK("FaultAddr = 0x%x\n", excInfo->faultAddr);
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC VOID OsExcCurTaskInfo(const ExcInfo *excInfo)
|
||||||
|
{
|
||||||
|
PRINTK("Current task info:\n");
|
||||||
|
if (excInfo->phase == OS_EXC_IN_TASK) {
|
||||||
|
LosTaskCB *taskCB = OS_TCB_FROM_TID(LOS_CurTaskIDGet());
|
||||||
|
PRINTK("Task name = %s\n", taskCB->taskName);
|
||||||
|
PRINTK("Task ID = %d\n", taskCB->taskID);
|
||||||
|
PRINTK("Task SP = %p\n", taskCB->stackPointer);
|
||||||
|
PRINTK("Task ST = 0x%x\n", taskCB->topOfStack);
|
||||||
|
PRINTK("Task SS = 0x%x\n", taskCB->stackSize);
|
||||||
|
} else if (excInfo->phase == OS_EXC_IN_HWI) {
|
||||||
|
PRINTK("Exception occur in interrupt phase!\n");
|
||||||
|
} else {
|
||||||
|
PRINTK("Exception occur in system init phase!\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC VOID OsExcRegInfo(const ExcInfo *excInfo)
|
||||||
|
{
|
||||||
|
PRINTK("Exception reg dump:\n");
|
||||||
|
PRINTK("PC = 0x%x\n", excInfo->context->uwPC);
|
||||||
|
PRINTK("LR = 0x%x\n", excInfo->context->uwLR);
|
||||||
|
PRINTK("SP = 0x%x\n", excInfo->context->uwSP);
|
||||||
|
PRINTK("R0 = 0x%x\n", excInfo->context->uwR0);
|
||||||
|
PRINTK("R1 = 0x%x\n", excInfo->context->uwR1);
|
||||||
|
PRINTK("R2 = 0x%x\n", excInfo->context->uwR2);
|
||||||
|
PRINTK("R3 = 0x%x\n", excInfo->context->uwR3);
|
||||||
|
PRINTK("R4 = 0x%x\n", excInfo->context->uwR4);
|
||||||
|
PRINTK("R5 = 0x%x\n", excInfo->context->uwR5);
|
||||||
|
PRINTK("R6 = 0x%x\n", excInfo->context->uwR6);
|
||||||
|
PRINTK("R7 = 0x%x\n", excInfo->context->uwR7);
|
||||||
|
PRINTK("R8 = 0x%x\n", excInfo->context->uwR8);
|
||||||
|
PRINTK("R9 = 0x%x\n", excInfo->context->uwR9);
|
||||||
|
PRINTK("R10 = 0x%x\n", excInfo->context->uwR10);
|
||||||
|
PRINTK("R11 = 0x%x\n", excInfo->context->uwR11);
|
||||||
|
PRINTK("R12 = 0x%x\n", excInfo->context->uwR12);
|
||||||
|
PRINTK("PriMask = 0x%x\n", excInfo->context->uwPriMask);
|
||||||
|
PRINTK("xPSR = 0x%x\n", excInfo->context->uwxPSR);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if (LOSCFG_KERNEL_BACKTRACE == 1)
|
||||||
|
STATIC VOID OsExcBackTraceInfo(const ExcInfo *excInfo)
|
||||||
|
{
|
||||||
|
UINTPTR LR[LOSCFG_BACKTRACE_DEPTH] = {0};
|
||||||
|
UINT32 index;
|
||||||
|
|
||||||
|
OsBackTraceHookCall(LR, LOSCFG_BACKTRACE_DEPTH, 0, excInfo->context->uwSP);
|
||||||
|
|
||||||
|
PRINTK("----- backtrace start -----\n");
|
||||||
|
for (index = 0; index < LOSCFG_BACKTRACE_DEPTH; index++) {
|
||||||
|
if (LR[index] == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
PRINTK("backtrace %d -- lr = 0x%x\n", index, LR[index]);
|
||||||
|
}
|
||||||
|
PRINTK("----- backtrace end -----\n");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
STATIC VOID OsExcMemPoolCheckInfo(VOID)
|
||||||
|
{
|
||||||
|
PRINTK("\r\nmemory pools check:\n");
|
||||||
|
#if (LOSCFG_PLATFORM_EXC == 1)
|
||||||
|
MemInfoCB memExcInfo[OS_SYS_MEM_NUM];
|
||||||
|
UINT32 errCnt;
|
||||||
|
UINT32 i;
|
||||||
|
|
||||||
|
(VOID)memset_s(memExcInfo, sizeof(memExcInfo), 0, sizeof(memExcInfo));
|
||||||
|
|
||||||
|
errCnt = OsMemExcInfoGet(OS_SYS_MEM_NUM, memExcInfo);
|
||||||
|
if (errCnt < OS_SYS_MEM_NUM) {
|
||||||
|
errCnt += OsMemboxExcInfoGet(OS_SYS_MEM_NUM - errCnt, memExcInfo + errCnt);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (errCnt == 0) {
|
||||||
|
PRINTK("all memory pool check passed!\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < errCnt; i++) {
|
||||||
|
PRINTK("pool num = %d\n", i);
|
||||||
|
PRINTK("pool type = %d\n", memExcInfo[i].type);
|
||||||
|
PRINTK("pool addr = 0x%x\n", memExcInfo[i].startAddr);
|
||||||
|
PRINTK("pool size = 0x%x\n", memExcInfo[i].size);
|
||||||
|
PRINTK("pool free = 0x%x\n", memExcInfo[i].free);
|
||||||
|
PRINTK("pool blkNum = %d\n", memExcInfo[i].blockSize);
|
||||||
|
PRINTK("pool error node addr = 0x%x\n", memExcInfo[i].errorAddr);
|
||||||
|
PRINTK("pool error node len = 0x%x\n", memExcInfo[i].errorLen);
|
||||||
|
PRINTK("pool error node owner = %d\n", memExcInfo[i].errorOwner);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
UINT32 ret = LOS_MemIntegrityCheck(LOSCFG_SYS_HEAP_ADDR);
|
||||||
|
if (ret == LOS_OK) {
|
||||||
|
PRINTK("system heap memcheck over, all passed!\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
PRINTK("memory pool check end!\n");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
STATIC VOID OsExcInfoDisplay(const ExcInfo *excInfo)
|
||||||
|
{
|
||||||
|
#if (LOSCFG_KERNEL_PRINTF != 0)
|
||||||
|
PRINTK("*************Exception Information**************\n");
|
||||||
|
OsExcTypeInfo(excInfo);
|
||||||
|
OsExcCurTaskInfo(excInfo);
|
||||||
|
OsExcRegInfo(excInfo);
|
||||||
|
#if (LOSCFG_KERNEL_BACKTRACE == 1)
|
||||||
|
OsExcBackTraceInfo(excInfo);
|
||||||
|
#endif
|
||||||
|
OsGetAllTskInfo();
|
||||||
|
OsExcNvicDump();
|
||||||
|
OsExcMemPoolCheckInfo();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
LITE_OS_SEC_TEXT_INIT VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr)
|
||||||
|
{
|
||||||
|
UINT16 tmpFlag = (excType >> 16) & OS_NULL_SHORT; /* 16: Get Exception Type */
|
||||||
|
g_intCount++;
|
||||||
|
g_excInfo.nestCnt++;
|
||||||
|
|
||||||
|
g_excInfo.type = excType & OS_NULL_SHORT;
|
||||||
|
|
||||||
|
if (tmpFlag & OS_EXC_FLAG_FAULTADDR_VALID) {
|
||||||
|
g_excInfo.faultAddr = faultAddr;
|
||||||
|
} else {
|
||||||
|
g_excInfo.faultAddr = OS_EXC_IMPRECISE_ACCESS_ADDR;
|
||||||
|
}
|
||||||
|
if (g_losTask.runTask != NULL) {
|
||||||
|
if (tmpFlag & OS_EXC_FLAG_IN_HWI) {
|
||||||
|
g_excInfo.phase = OS_EXC_IN_HWI;
|
||||||
|
g_excInfo.thrdPid = pid;
|
||||||
|
} else {
|
||||||
|
g_excInfo.phase = OS_EXC_IN_TASK;
|
||||||
|
g_excInfo.thrdPid = g_losTask.runTask->taskID;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
g_excInfo.phase = OS_EXC_IN_INIT;
|
||||||
|
g_excInfo.thrdPid = OS_NULL_INT;
|
||||||
|
}
|
||||||
|
if (excType & OS_EXC_FLAG_NO_FLOAT) {
|
||||||
|
g_excInfo.context = (EXC_CONTEXT_S *)((CHAR *)excBufAddr - LOS_OFF_SET_OF(EXC_CONTEXT_S, uwR4));
|
||||||
|
} else {
|
||||||
|
g_excInfo.context = excBufAddr;
|
||||||
|
}
|
||||||
|
|
||||||
|
OsDoExcHook(EXC_INTERRUPT);
|
||||||
|
OsExcInfoDisplay(&g_excInfo);
|
||||||
|
ArchSysExit();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ****************************************************************************
|
||||||
|
Function : HalHwiInit
|
||||||
|
Description : initialization of the hardware interrupt
|
||||||
|
Input : None
|
||||||
|
Output : None
|
||||||
|
Return : None
|
||||||
|
**************************************************************************** */
|
||||||
|
LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
|
||||||
|
{
|
||||||
|
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
|
||||||
|
UINT32 index;
|
||||||
|
g_hwiForm[0] = 0; /* [0] Top of Stack */
|
||||||
|
g_hwiForm[1] = 0; /* [1] reset */
|
||||||
|
for (index = DEF_HANDLER_START_INDEX; index < OS_VECTOR_CNT; index++) {
|
||||||
|
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
|
||||||
|
}
|
||||||
|
/* Exception handler register */
|
||||||
|
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
|
||||||
|
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
|
||||||
|
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
|
||||||
|
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
|
||||||
|
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
|
||||||
|
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
|
||||||
|
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
|
||||||
|
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)OsTickHandler;
|
||||||
|
|
||||||
|
/* Interrupt vector table location */
|
||||||
|
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;
|
||||||
|
#endif
|
||||||
|
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
|
||||||
|
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Enable USGFAULT, BUSFAULT, MEMFAULT */
|
||||||
|
*(volatile UINT32 *)OS_NVIC_SHCSR |= (USGFAULT | BUSFAULT | MEMFAULT);
|
||||||
|
|
||||||
|
/* Enable DIV 0 and unaligned exception */
|
||||||
|
#ifdef LOSCFG_ARCH_UNALIGNED_EXC
|
||||||
|
*(volatile UINT32 *)OS_NVIC_CCR |= (DIV0FAULT | UNALIGNFAULT);
|
||||||
|
#else
|
||||||
|
*(volatile UINT32 *)OS_NVIC_CCR |= (DIV0FAULT);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,127 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "los_timer.h"
|
||||||
|
#include "los_config.h"
|
||||||
|
#include "los_tick.h"
|
||||||
|
#include "los_arch_interrupt.h"
|
||||||
|
#include "los_debug.h"
|
||||||
|
|
||||||
|
STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler);
|
||||||
|
STATIC UINT64 SysTickReload(UINT64 nextResponseTime);
|
||||||
|
STATIC UINT64 SysTickCycleGet(UINT32 *period);
|
||||||
|
STATIC VOID SysTickLock(VOID);
|
||||||
|
STATIC VOID SysTickUnlock(VOID);
|
||||||
|
|
||||||
|
STATIC ArchTickTimer g_archTickTimer = {
|
||||||
|
.freq = 0,
|
||||||
|
.irqNum = SysTick_IRQn,
|
||||||
|
.periodMax = LOSCFG_BASE_CORE_TICK_RESPONSE_MAX,
|
||||||
|
.init = SysTickStart,
|
||||||
|
.getCycle = SysTickCycleGet,
|
||||||
|
.reload = SysTickReload,
|
||||||
|
.lock = SysTickLock,
|
||||||
|
.unlock = SysTickUnlock,
|
||||||
|
.tickHandler = NULL,
|
||||||
|
};
|
||||||
|
|
||||||
|
STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler)
|
||||||
|
{
|
||||||
|
UINT32 ret;
|
||||||
|
ArchTickTimer *tick = &g_archTickTimer;
|
||||||
|
|
||||||
|
tick->freq = OS_SYS_CLOCK;
|
||||||
|
|
||||||
|
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
|
||||||
|
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
|
||||||
|
OsSetVector(tick->irqNum, handler, NULL);
|
||||||
|
#else
|
||||||
|
OsSetVector(tick->irqNum, handler);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ret = SysTick_Config(LOSCFG_BASE_CORE_TICK_RESPONSE_MAX);
|
||||||
|
if (ret == 1) {
|
||||||
|
return LOS_ERRNO_TICK_PER_SEC_TOO_SMALL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC UINT64 SysTickReload(UINT64 nextResponseTime)
|
||||||
|
{
|
||||||
|
if (nextResponseTime > g_archTickTimer.periodMax) {
|
||||||
|
nextResponseTime = g_archTickTimer.periodMax;
|
||||||
|
}
|
||||||
|
|
||||||
|
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
|
||||||
|
SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */
|
||||||
|
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
|
||||||
|
NVIC_ClearPendingIRQ(SysTick_IRQn);
|
||||||
|
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
|
||||||
|
return nextResponseTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC UINT64 SysTickCycleGet(UINT32 *period)
|
||||||
|
{
|
||||||
|
UINT32 hwCycle = 0;
|
||||||
|
UINT32 intSave = LOS_IntLock();
|
||||||
|
UINT32 val = SysTick->VAL;
|
||||||
|
*period = SysTick->LOAD;
|
||||||
|
if (val != 0) {
|
||||||
|
hwCycle = *period - val;
|
||||||
|
}
|
||||||
|
LOS_IntRestore(intSave);
|
||||||
|
return (UINT64)hwCycle;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC VOID SysTickLock(VOID)
|
||||||
|
{
|
||||||
|
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC VOID SysTickUnlock(VOID)
|
||||||
|
{
|
||||||
|
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
|
||||||
|
}
|
||||||
|
|
||||||
|
ArchTickTimer *ArchSysTickTimerGet(VOID)
|
||||||
|
{
|
||||||
|
return &g_archTickTimer;
|
||||||
|
}
|
||||||
|
|
||||||
|
UINT32 ArchEnterSleep(VOID)
|
||||||
|
{
|
||||||
|
__DSB();
|
||||||
|
__WFI();
|
||||||
|
__ISB();
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||||
|
# Copyright (c) 2020-2021 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("//kernel/liteos_m/liteos.gni")
|
||||||
|
|
||||||
|
module_name = "arch"
|
||||||
|
kernel_module(module_name) {
|
||||||
|
sources = [
|
||||||
|
"non_secure/los_context.c",
|
||||||
|
"non_secure/los_dispatch.S",
|
||||||
|
"non_secure/los_exc.S",
|
||||||
|
"non_secure/los_interrupt.c",
|
||||||
|
"non_secure/los_timer.c",
|
||||||
|
"non_secure/los_trustzone.c",
|
||||||
|
]
|
||||||
|
configs += [ "$LITEOSTOPDIR:warn_config" ]
|
||||||
|
|
||||||
|
include_dirs = [
|
||||||
|
"non_secure",
|
||||||
|
"secure",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
config("public") {
|
||||||
|
include_dirs = [ "non_secure" ]
|
||||||
|
}
|
||||||
@@ -0,0 +1,297 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||||
|
* Copyright (c) 2020-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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _LOS_ARCH_ATOMIC_H
|
||||||
|
#define _LOS_ARCH_ATOMIC_H
|
||||||
|
|
||||||
|
#include "los_compiler.h"
|
||||||
|
#include "los_interrupt.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#if __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
STATIC INLINE INT32 ArchAtomicRead(const Atomic *v)
|
||||||
|
{
|
||||||
|
INT32 val;
|
||||||
|
|
||||||
|
__asm__ __volatile__("ldrex %0, [%1]\n"
|
||||||
|
: "=&r"(val)
|
||||||
|
: "r"(v)
|
||||||
|
: "cc");
|
||||||
|
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC INLINE VOID ArchAtomicSet(Atomic *v, INT32 setVal)
|
||||||
|
{
|
||||||
|
UINT32 status;
|
||||||
|
|
||||||
|
do {
|
||||||
|
__asm__ __volatile__("ldrex %0, [%1]\n"
|
||||||
|
"strex %0, %2, [%1]\n"
|
||||||
|
: "=&r"(status)
|
||||||
|
: "r"(v), "r"(setVal)
|
||||||
|
: "cc");
|
||||||
|
} while (__builtin_expect(status != 0, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC INLINE INT32 ArchAtomicAdd(Atomic *v, INT32 addVal)
|
||||||
|
{
|
||||||
|
INT32 val;
|
||||||
|
UINT32 status;
|
||||||
|
|
||||||
|
do {
|
||||||
|
__asm__ __volatile__("ldrex %1, [%2]\n"
|
||||||
|
"add %1, %1, %3\n"
|
||||||
|
"strex %0, %1, [%2]"
|
||||||
|
: "=&r"(status), "=&r"(val)
|
||||||
|
: "r"(v), "r"(addVal)
|
||||||
|
: "cc");
|
||||||
|
} while (__builtin_expect(status != 0, 0));
|
||||||
|
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC INLINE INT32 ArchAtomicSub(Atomic *v, INT32 subVal)
|
||||||
|
{
|
||||||
|
INT32 val;
|
||||||
|
UINT32 status;
|
||||||
|
|
||||||
|
do {
|
||||||
|
__asm__ __volatile__("ldrex %1, [%2]\n"
|
||||||
|
"sub %1, %1, %3\n"
|
||||||
|
"strex %0, %1, [%2]"
|
||||||
|
: "=&r"(status), "=&r"(val)
|
||||||
|
: "r"(v), "r"(subVal)
|
||||||
|
: "cc");
|
||||||
|
} while (__builtin_expect(status != 0, 0));
|
||||||
|
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC INLINE VOID ArchAtomicInc(Atomic *v)
|
||||||
|
{
|
||||||
|
(VOID)ArchAtomicAdd(v, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC INLINE VOID ArchAtomicDec(Atomic *v)
|
||||||
|
{
|
||||||
|
(VOID)ArchAtomicSub(v, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC INLINE INT32 ArchAtomicIncRet(Atomic *v)
|
||||||
|
{
|
||||||
|
return ArchAtomicAdd(v, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC INLINE INT32 ArchAtomicDecRet(Atomic *v)
|
||||||
|
{
|
||||||
|
return ArchAtomicSub(v, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup los_arch_atomic
|
||||||
|
* @brief Atomic exchange for 32-bit variable.
|
||||||
|
*
|
||||||
|
* @par Description:
|
||||||
|
* This API is used to implement the atomic exchange for 32-bit variable
|
||||||
|
* and return the previous value of the atomic variable.
|
||||||
|
* @attention
|
||||||
|
* <ul>The pointer v must not be NULL.</ul>
|
||||||
|
*
|
||||||
|
* @param v [IN] The variable pointer.
|
||||||
|
* @param val [IN] The exchange value.
|
||||||
|
*
|
||||||
|
* @retval #INT32 The previous value of the atomic variable
|
||||||
|
* @par Dependency:
|
||||||
|
* <ul><li>los_arch_atomic.h: the header file that contains the API declaration.</li></ul>
|
||||||
|
* @see
|
||||||
|
*/
|
||||||
|
STATIC INLINE INT32 ArchAtomicXchg32bits(volatile INT32 *v, INT32 val)
|
||||||
|
{
|
||||||
|
INT32 prevVal = 0;
|
||||||
|
UINT32 status = 0;
|
||||||
|
|
||||||
|
do {
|
||||||
|
__asm__ __volatile__("ldrex %0, [%3]\n"
|
||||||
|
"strex %1, %4, [%3]"
|
||||||
|
: "=&r"(prevVal), "=&r"(status), "+m"(*v)
|
||||||
|
: "r"(v), "r"(val)
|
||||||
|
: "cc");
|
||||||
|
} while (__builtin_expect(status != 0, 0));
|
||||||
|
|
||||||
|
return prevVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup los_arch_atomic
|
||||||
|
* @brief Atomic exchange for 32-bit variable with compare.
|
||||||
|
*
|
||||||
|
* @par Description:
|
||||||
|
* This API is used to implement the atomic exchange for 32-bit variable, if the value of variable is equal to oldVal.
|
||||||
|
* @attention
|
||||||
|
* <ul>The pointer v must not be NULL.</ul>
|
||||||
|
*
|
||||||
|
* @param v [IN] The variable pointer.
|
||||||
|
* @param val [IN] The new value.
|
||||||
|
* @param oldVal [IN] The old value.
|
||||||
|
*
|
||||||
|
* @retval TRUE The previous value of the atomic variable is not equal to oldVal.
|
||||||
|
* @retval FALSE The previous value of the atomic variable is equal to oldVal.
|
||||||
|
* @par Dependency:
|
||||||
|
* <ul><li>los_arch_atomic.h: the header file that contains the API declaration.</li></ul>
|
||||||
|
* @see
|
||||||
|
*/
|
||||||
|
STATIC INLINE BOOL ArchAtomicCmpXchg32bits(volatile INT32 *v, INT32 val, INT32 oldVal)
|
||||||
|
{
|
||||||
|
INT32 prevVal = 0;
|
||||||
|
UINT32 status = 0;
|
||||||
|
|
||||||
|
do {
|
||||||
|
__asm__ __volatile__("ldrex %0, %2\n"
|
||||||
|
"mov %1, #0\n"
|
||||||
|
"cmp %0, %3\n"
|
||||||
|
"bne 1f\n"
|
||||||
|
"strex %1, %4, %2\n"
|
||||||
|
"1:"
|
||||||
|
: "=&r"(prevVal), "=&r"(status), "+Q"(*v)
|
||||||
|
: "r"(oldVal), "r"(val)
|
||||||
|
: "cc");
|
||||||
|
} while (__builtin_expect(status != 0, 0));
|
||||||
|
|
||||||
|
return prevVal != oldVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC INLINE INT64 ArchAtomic64Read(const Atomic64 *v)
|
||||||
|
{
|
||||||
|
INT64 val;
|
||||||
|
UINT32 intSave;
|
||||||
|
|
||||||
|
intSave = LOS_IntLock();
|
||||||
|
val = *v;
|
||||||
|
LOS_IntRestore(intSave);
|
||||||
|
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC INLINE VOID ArchAtomic64Set(Atomic64 *v, INT64 setVal)
|
||||||
|
{
|
||||||
|
UINT32 intSave;
|
||||||
|
|
||||||
|
intSave = LOS_IntLock();
|
||||||
|
*v = setVal;
|
||||||
|
LOS_IntRestore(intSave);
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC INLINE INT64 ArchAtomic64Add(Atomic64 *v, INT64 addVal)
|
||||||
|
{
|
||||||
|
INT64 val;
|
||||||
|
UINT32 intSave;
|
||||||
|
|
||||||
|
intSave = LOS_IntLock();
|
||||||
|
*v += addVal;
|
||||||
|
val = *v;
|
||||||
|
LOS_IntRestore(intSave);
|
||||||
|
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC INLINE INT64 ArchAtomic64Sub(Atomic64 *v, INT64 subVal)
|
||||||
|
{
|
||||||
|
INT64 val;
|
||||||
|
UINT32 intSave;
|
||||||
|
|
||||||
|
intSave = LOS_IntLock();
|
||||||
|
*v -= subVal;
|
||||||
|
val = *v;
|
||||||
|
LOS_IntRestore(intSave);
|
||||||
|
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC INLINE VOID ArchAtomic64Inc(Atomic64 *v)
|
||||||
|
{
|
||||||
|
(VOID)ArchAtomic64Add(v, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC INLINE INT64 ArchAtomic64IncRet(Atomic64 *v)
|
||||||
|
{
|
||||||
|
return ArchAtomic64Add(v, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC INLINE VOID ArchAtomic64Dec(Atomic64 *v)
|
||||||
|
{
|
||||||
|
(VOID)ArchAtomic64Sub(v, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC INLINE INT64 ArchAtomic64DecRet(Atomic64 *v)
|
||||||
|
{
|
||||||
|
return ArchAtomic64Sub(v, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC INLINE INT64 ArchAtomicXchg64bits(Atomic64 *v, INT64 val)
|
||||||
|
{
|
||||||
|
INT64 prevVal;
|
||||||
|
UINT32 intSave;
|
||||||
|
|
||||||
|
intSave = LOS_IntLock();
|
||||||
|
prevVal = *v;
|
||||||
|
*v = val;
|
||||||
|
LOS_IntRestore(intSave);
|
||||||
|
|
||||||
|
return prevVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC INLINE BOOL ArchAtomicCmpXchg64bits(Atomic64 *v, INT64 val, INT64 oldVal)
|
||||||
|
{
|
||||||
|
INT64 prevVal;
|
||||||
|
UINT32 intSave;
|
||||||
|
|
||||||
|
intSave = LOS_IntLock();
|
||||||
|
prevVal = *v;
|
||||||
|
if (prevVal == oldVal) {
|
||||||
|
*v = val;
|
||||||
|
}
|
||||||
|
LOS_IntRestore(intSave);
|
||||||
|
|
||||||
|
return prevVal != oldVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#if __cplusplus
|
||||||
|
}
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
#endif /* _LOS_ARCH_ATOMIC_H */
|
||||||
@@ -0,0 +1,133 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||||
|
* Copyright (c) 2020-2021 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _LOS_ARCH_CONTEXT_H
|
||||||
|
#define _LOS_ARCH_CONTEXT_H
|
||||||
|
|
||||||
|
#include "los_config.h"
|
||||||
|
#include "los_compiler.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#if __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
typedef struct TagTskContext {
|
||||||
|
UINT32 secureContext;
|
||||||
|
UINT32 stackLimit;
|
||||||
|
UINT32 excReturn;
|
||||||
|
#if ((defined(__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
|
||||||
|
(defined(__FPU_USED) && (__FPU_USED == 1U)))
|
||||||
|
UINT32 S16;
|
||||||
|
UINT32 S17;
|
||||||
|
UINT32 S18;
|
||||||
|
UINT32 S19;
|
||||||
|
UINT32 S20;
|
||||||
|
UINT32 S21;
|
||||||
|
UINT32 S22;
|
||||||
|
UINT32 S23;
|
||||||
|
UINT32 S24;
|
||||||
|
UINT32 S25;
|
||||||
|
UINT32 S26;
|
||||||
|
UINT32 S27;
|
||||||
|
UINT32 S28;
|
||||||
|
UINT32 S29;
|
||||||
|
UINT32 S30;
|
||||||
|
UINT32 S31;
|
||||||
|
#endif
|
||||||
|
UINT32 uwR4;
|
||||||
|
UINT32 uwR5;
|
||||||
|
UINT32 uwR6;
|
||||||
|
UINT32 uwR7;
|
||||||
|
UINT32 uwR8;
|
||||||
|
UINT32 uwR9;
|
||||||
|
UINT32 uwR10;
|
||||||
|
UINT32 uwR11;
|
||||||
|
UINT32 uwPriMask;
|
||||||
|
UINT32 uwR0;
|
||||||
|
UINT32 uwR1;
|
||||||
|
UINT32 uwR2;
|
||||||
|
UINT32 uwR3;
|
||||||
|
UINT32 uwR12;
|
||||||
|
UINT32 uwLR;
|
||||||
|
UINT32 uwPC;
|
||||||
|
UINT32 uwxPSR;
|
||||||
|
#if ((defined(__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
|
||||||
|
(defined(__FPU_USED) && (__FPU_USED == 1U)))
|
||||||
|
UINT32 S0;
|
||||||
|
UINT32 S1;
|
||||||
|
UINT32 S2;
|
||||||
|
UINT32 S3;
|
||||||
|
UINT32 S4;
|
||||||
|
UINT32 S5;
|
||||||
|
UINT32 S6;
|
||||||
|
UINT32 S7;
|
||||||
|
UINT32 S8;
|
||||||
|
UINT32 S9;
|
||||||
|
UINT32 S10;
|
||||||
|
UINT32 S11;
|
||||||
|
UINT32 S12;
|
||||||
|
UINT32 S13;
|
||||||
|
UINT32 S14;
|
||||||
|
UINT32 S15;
|
||||||
|
UINT32 FPSCR;
|
||||||
|
UINT32 NO_NAME;
|
||||||
|
#endif
|
||||||
|
} TaskContext;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup los_config
|
||||||
|
* @brief: Task start running function.
|
||||||
|
*
|
||||||
|
* @par Description:
|
||||||
|
* This API is used to start a task.
|
||||||
|
*
|
||||||
|
* @attention:
|
||||||
|
* <ul><li>None.</li></ul>
|
||||||
|
*
|
||||||
|
* @param: None.
|
||||||
|
*
|
||||||
|
* @retval None.
|
||||||
|
*
|
||||||
|
* @par Dependency:
|
||||||
|
* <ul><li>los_config.h: the header file that contains the API declaration.</li></ul>
|
||||||
|
* @see None.
|
||||||
|
*/
|
||||||
|
extern VOID HalStartToRun(VOID);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#if __cplusplus
|
||||||
|
}
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
#endif /* _LOS_ARCH_CONTEXT_H */
|
||||||
@@ -0,0 +1,683 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||||
|
* Copyright (c) 2020-2021 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _LOS_ARCH_INTERRUPT_H
|
||||||
|
#define _LOS_ARCH_INTERRUPT_H
|
||||||
|
|
||||||
|
#include "los_config.h"
|
||||||
|
#include "los_compiler.h"
|
||||||
|
#include "los_interrupt.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#if __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Maximum number of used hardware interrupts.
|
||||||
|
*/
|
||||||
|
#ifndef OS_HWI_MAX_NUM
|
||||||
|
#define OS_HWI_MAX_NUM LOSCFG_PLATFORM_HWI_LIMIT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Highest priority of a hardware interrupt.
|
||||||
|
*/
|
||||||
|
#ifndef OS_HWI_PRIO_HIGHEST
|
||||||
|
#define OS_HWI_PRIO_HIGHEST 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Lowest priority of a hardware interrupt.
|
||||||
|
*/
|
||||||
|
#ifndef OS_HWI_PRIO_LOWEST
|
||||||
|
#define OS_HWI_PRIO_LOWEST 7
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Define the type of a hardware interrupt vector table function.
|
||||||
|
*/
|
||||||
|
typedef VOID (**HWI_VECTOR_FUNC)(void);
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Count of interrupts.
|
||||||
|
*/
|
||||||
|
extern UINT32 g_intCount;
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Count of M-Core system interrupt vector.
|
||||||
|
*/
|
||||||
|
#define OS_SYS_VECTOR_CNT 16
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Count of M-Core interrupt vector.
|
||||||
|
*/
|
||||||
|
#define OS_VECTOR_CNT (OS_SYS_VECTOR_CNT + OS_HWI_MAX_NUM)
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* AIRCR register priority group parameter .
|
||||||
|
*/
|
||||||
|
#define OS_NVIC_AIRCR_PRIGROUP 7
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Boot interrupt vector table.
|
||||||
|
*/
|
||||||
|
extern UINT32 _BootVectors[];
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Hardware interrupt error code: Invalid interrupt number.
|
||||||
|
*
|
||||||
|
* Value: 0x02000900
|
||||||
|
*
|
||||||
|
* Solution: Ensure that the interrupt number is valid.
|
||||||
|
* The value range of the interrupt number applicable for a Cortex-M33 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
|
||||||
|
*/
|
||||||
|
#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Hardware interrupt error code: Null hardware interrupt handling function.
|
||||||
|
*
|
||||||
|
* Value: 0x02000901
|
||||||
|
*
|
||||||
|
* Solution: Pass in a valid non-null hardware interrupt handling function.
|
||||||
|
*/
|
||||||
|
#define OS_ERRNO_HWI_PROC_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x01)
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Hardware interrupt error code: Insufficient interrupt resources for hardware interrupt creation.
|
||||||
|
*
|
||||||
|
* Value: 0x02000902
|
||||||
|
*
|
||||||
|
* Solution: Increase the configured maximum number of supported hardware interrupts.
|
||||||
|
*/
|
||||||
|
#define OS_ERRNO_HWI_CB_UNAVAILABLE LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x02)
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Hardware interrupt error code: Insufficient memory for hardware interrupt initialization.
|
||||||
|
*
|
||||||
|
* Value: 0x02000903
|
||||||
|
*
|
||||||
|
* Solution: Expand the configured memory.
|
||||||
|
*/
|
||||||
|
#define OS_ERRNO_HWI_NO_MEMORY LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x03)
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Hardware interrupt error code: The interrupt has already been created.
|
||||||
|
*
|
||||||
|
* Value: 0x02000904
|
||||||
|
*
|
||||||
|
* Solution: Check whether the interrupt specified by the passed-in interrupt number has already been created.
|
||||||
|
*/
|
||||||
|
#define OS_ERRNO_HWI_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x04)
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Hardware interrupt error code: Invalid interrupt priority.
|
||||||
|
*
|
||||||
|
* Value: 0x02000905
|
||||||
|
*
|
||||||
|
* Solution: Ensure that the interrupt priority is valid.
|
||||||
|
* The value range of the interrupt priority applicable for a Cortex-M33 platform is [0,15].
|
||||||
|
*/
|
||||||
|
#define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05)
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Hardware interrupt error code: Incorrect interrupt creation mode.
|
||||||
|
*
|
||||||
|
* Value: 0x02000906
|
||||||
|
*
|
||||||
|
* Solution: The interrupt creation mode can be only set to OS_HWI_MODE_COMM or
|
||||||
|
* OS_HWI_MODE_FAST of which the value can be 0 or 1.
|
||||||
|
*/
|
||||||
|
#define OS_ERRNO_HWI_MODE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x06)
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Hardware interrupt error code: The interrupt has already been created as a fast interrupt.
|
||||||
|
*
|
||||||
|
* Value: 0x02000907
|
||||||
|
*
|
||||||
|
* Solution: Check whether the interrupt specified by the passed-in interrupt number has already been created.
|
||||||
|
*/
|
||||||
|
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* SysTick control and status register.
|
||||||
|
*/
|
||||||
|
#define OS_SYSTICK_CONTROL_REG 0xE000E010
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_hw
|
||||||
|
* SysTick current value register.
|
||||||
|
*/
|
||||||
|
#define OS_SYSTICK_CURRENT_REG 0xE000E018
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Interrupt Priority-Level Registers.
|
||||||
|
*/
|
||||||
|
#define OS_NVIC_PRI_BASE 0xE000E400
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Interrupt enable register for 0-31.
|
||||||
|
*/
|
||||||
|
#define OS_NVIC_SETENA_BASE 0xE000E100
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* interrupt pending register.
|
||||||
|
*/
|
||||||
|
#define OS_NVIC_SETPEND_BASE 0xE000E200
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Interrupt active register.
|
||||||
|
*/
|
||||||
|
#define OS_NVIC_INT_ACT_BASE 0xE000E300
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Interrupt disable register for 0-31.
|
||||||
|
*/
|
||||||
|
#define OS_NVIC_CLRENA_BASE 0xE000E180
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Interrupt control and status register.
|
||||||
|
*/
|
||||||
|
#define OS_NVIC_INT_CTRL 0xE000ED04
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Vector table offset register.
|
||||||
|
*/
|
||||||
|
#define OS_NVIC_VTOR 0xE000ED08
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Application interrupt and reset control register
|
||||||
|
*/
|
||||||
|
#define OS_NVIC_AIRCR 0xE000ED0C
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* System exception priority register.
|
||||||
|
*/
|
||||||
|
#define OS_NVIC_EXCPRI_BASE 0xE000ED18
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Interrupt No. 1 :reset.
|
||||||
|
*/
|
||||||
|
#define OS_EXC_RESET 1
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Interrupt No. 2 :Non-Maskable Interrupt.
|
||||||
|
*/
|
||||||
|
#define OS_EXC_NMI 2
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Interrupt No. 3 :(hard)fault.
|
||||||
|
*/
|
||||||
|
#define OS_EXC_HARD_FAULT 3
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Interrupt No. 4 :MemManage fault.
|
||||||
|
*/
|
||||||
|
#define OS_EXC_MPU_FAULT 4
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Interrupt No. 5 :Bus fault.
|
||||||
|
*/
|
||||||
|
#define OS_EXC_BUS_FAULT 5
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Interrupt No. 6 :Usage fault.
|
||||||
|
*/
|
||||||
|
#define OS_EXC_USAGE_FAULT 6
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Interrupt No. 11 :SVCall.
|
||||||
|
*/
|
||||||
|
#define OS_EXC_SVC_CALL 11
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Interrupt No. 12 :Debug monitor.
|
||||||
|
*/
|
||||||
|
#define OS_EXC_DBG_MONITOR 12
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Interrupt No. 14 :PendSV.
|
||||||
|
*/
|
||||||
|
#define OS_EXC_PEND_SV 14
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Interrupt No. 15 :SysTick.
|
||||||
|
*/
|
||||||
|
#define OS_EXC_SYS_TICK 15
|
||||||
|
|
||||||
|
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Set interrupt vector table.
|
||||||
|
*/
|
||||||
|
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg);
|
||||||
|
#else
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Set interrupt vector table.
|
||||||
|
*/
|
||||||
|
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* @brief: Hardware interrupt entry function.
|
||||||
|
*
|
||||||
|
* @par Description:
|
||||||
|
* This API is used as all hardware interrupt handling function entry.
|
||||||
|
*
|
||||||
|
* @attention:
|
||||||
|
* <ul><li>None.</li></ul>
|
||||||
|
*
|
||||||
|
* @param:None.
|
||||||
|
*
|
||||||
|
* @retval:None.
|
||||||
|
* @par Dependency:
|
||||||
|
* <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
|
||||||
|
* @see None.
|
||||||
|
*/
|
||||||
|
extern VOID HalInterrupt(VOID);
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* @brief: Default vector handling function.
|
||||||
|
*
|
||||||
|
* @par Description:
|
||||||
|
* This API is used to configure interrupt for null function.
|
||||||
|
*
|
||||||
|
* @attention:
|
||||||
|
* <ul><li>None.</li></ul>
|
||||||
|
*
|
||||||
|
* @param:None.
|
||||||
|
*
|
||||||
|
* @retval:None.
|
||||||
|
* @par Dependency:
|
||||||
|
* <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
|
||||||
|
* @see None.
|
||||||
|
*/
|
||||||
|
extern VOID HalHwiDefaultHandler(VOID);
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* @brief: Reset the vector table.
|
||||||
|
*
|
||||||
|
* @par Description:
|
||||||
|
* This API is used to reset the vector table.
|
||||||
|
*
|
||||||
|
* @attention:
|
||||||
|
* <ul><li>None.</li></ul>
|
||||||
|
*
|
||||||
|
* @param:None.
|
||||||
|
*
|
||||||
|
* @retval:None.
|
||||||
|
* @par Dependency:
|
||||||
|
* <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
|
||||||
|
* @see None.
|
||||||
|
*/
|
||||||
|
extern VOID Reset_Handler(VOID);
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* @brief: Pended System Call.
|
||||||
|
*
|
||||||
|
* @par Description:
|
||||||
|
* PendSV can be pended and is useful for an OS to pend an exception
|
||||||
|
* so that an action can be performed after other important tasks are completed.
|
||||||
|
*
|
||||||
|
* @attention:
|
||||||
|
* <ul><li>None.</li></ul>
|
||||||
|
*
|
||||||
|
* @param:None.
|
||||||
|
*
|
||||||
|
* @retval:None.
|
||||||
|
* @par Dependency:
|
||||||
|
* <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
|
||||||
|
* @see None.
|
||||||
|
*/
|
||||||
|
extern VOID HalPendSV(VOID);
|
||||||
|
|
||||||
|
|
||||||
|
#define OS_EXC_IN_INIT 0
|
||||||
|
#define OS_EXC_IN_TASK 1
|
||||||
|
#define OS_EXC_IN_HWI 2
|
||||||
|
|
||||||
|
#define OS_EXC_MAX_BUF_LEN 25
|
||||||
|
#define OS_EXC_MAX_NEST_DEPTH 1
|
||||||
|
|
||||||
|
#define OS_NVIC_SHCSR 0xE000ED24
|
||||||
|
#define OS_NVIC_CCR 0xE000ED14
|
||||||
|
|
||||||
|
#define OS_NVIC_INT_ENABLE_SIZE 0x20
|
||||||
|
#define OS_NVIC_INT_PRI_SIZE 0xF0
|
||||||
|
#define OS_NVIC_EXCPRI_SIZE 0xC
|
||||||
|
#define OS_NVIC_INT_CTRL_SIZE 4
|
||||||
|
#define OS_NVIC_SHCSR_SIZE 4
|
||||||
|
|
||||||
|
#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
|
||||||
|
#define OS_NVIC_INT_ACT_SIZE OS_NVIC_INT_ENABLE_SIZE
|
||||||
|
|
||||||
|
#define OS_EXC_FLAG_NO_FLOAT 0x10000000
|
||||||
|
#define OS_EXC_FLAG_FAULTADDR_VALID 0x01
|
||||||
|
#define OS_EXC_FLAG_IN_HWI 0x02
|
||||||
|
|
||||||
|
#define OS_EXC_IMPRECISE_ACCESS_ADDR 0xABABABAB
|
||||||
|
|
||||||
|
#define OS_EXC_EVENT 0x00000001
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup los_exc
|
||||||
|
* the struct of register files
|
||||||
|
*
|
||||||
|
* description: the register files that saved when exception triggered
|
||||||
|
*
|
||||||
|
* notes:the following register with prefix 'uw' correspond to the registers in the cpu data sheet.
|
||||||
|
*/
|
||||||
|
typedef struct TagExcContext {
|
||||||
|
#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
|
||||||
|
(defined (__FPU_USED ) && (__FPU_USED == 1U)) )
|
||||||
|
UINT32 S16;
|
||||||
|
UINT32 S17;
|
||||||
|
UINT32 S18;
|
||||||
|
UINT32 S19;
|
||||||
|
UINT32 S20;
|
||||||
|
UINT32 S21;
|
||||||
|
UINT32 S22;
|
||||||
|
UINT32 S23;
|
||||||
|
UINT32 S24;
|
||||||
|
UINT32 S25;
|
||||||
|
UINT32 S26;
|
||||||
|
UINT32 S27;
|
||||||
|
UINT32 S28;
|
||||||
|
UINT32 S29;
|
||||||
|
UINT32 S30;
|
||||||
|
UINT32 S31;
|
||||||
|
#endif
|
||||||
|
UINT32 uwR4;
|
||||||
|
UINT32 uwR5;
|
||||||
|
UINT32 uwR6;
|
||||||
|
UINT32 uwR7;
|
||||||
|
UINT32 uwR8;
|
||||||
|
UINT32 uwR9;
|
||||||
|
UINT32 uwR10;
|
||||||
|
UINT32 uwR11;
|
||||||
|
UINT32 uwPriMask;
|
||||||
|
/* auto save */
|
||||||
|
UINT32 uwSP;
|
||||||
|
UINT32 uwR0;
|
||||||
|
UINT32 uwR1;
|
||||||
|
UINT32 uwR2;
|
||||||
|
UINT32 uwR3;
|
||||||
|
UINT32 uwR12;
|
||||||
|
UINT32 uwLR;
|
||||||
|
UINT32 uwPC;
|
||||||
|
UINT32 uwxPSR;
|
||||||
|
#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
|
||||||
|
(defined (__FPU_USED) && (__FPU_USED== 1U)))
|
||||||
|
UINT32 S0;
|
||||||
|
UINT32 S1;
|
||||||
|
UINT32 S2;
|
||||||
|
UINT32 S3;
|
||||||
|
UINT32 S4;
|
||||||
|
UINT32 S5;
|
||||||
|
UINT32 S6;
|
||||||
|
UINT32 S7;
|
||||||
|
UINT32 S8;
|
||||||
|
UINT32 S9;
|
||||||
|
UINT32 S10;
|
||||||
|
UINT32 S11;
|
||||||
|
UINT32 S12;
|
||||||
|
UINT32 S13;
|
||||||
|
UINT32 S14;
|
||||||
|
UINT32 S15;
|
||||||
|
UINT32 FPSCR;
|
||||||
|
UINT32 NO_NAME;
|
||||||
|
#endif
|
||||||
|
} EXC_CONTEXT_S;
|
||||||
|
|
||||||
|
typedef VOID (*EXC_PROC_FUNC)(UINT32, EXC_CONTEXT_S *);
|
||||||
|
VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr);
|
||||||
|
|
||||||
|
VOID HalExcNMI(VOID);
|
||||||
|
VOID HalExcHardFault(VOID);
|
||||||
|
VOID HalExcMemFault(VOID);
|
||||||
|
VOID HalExcBusFault(VOID);
|
||||||
|
VOID HalExcUsageFault(VOID);
|
||||||
|
VOID HalSVCHandler(VOID);
|
||||||
|
VOID HalHwiInit(VOID);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup los_exc
|
||||||
|
* Cortex-M exception types: An error occurred while the bus status register was being pushed.
|
||||||
|
*/
|
||||||
|
#define OS_EXC_BF_STKERR 1
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup los_exc
|
||||||
|
* Cortex-M exception types: An error occurred while the bus status register was out of the stack.
|
||||||
|
*/
|
||||||
|
#define OS_EXC_BF_UNSTKERR 2
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup los_exc
|
||||||
|
* Cortex-M exception types: Bus status register imprecise data access violation.
|
||||||
|
*/
|
||||||
|
#define OS_EXC_BF_IMPRECISERR 3
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup los_exc
|
||||||
|
* Cortex-M exception types: Bus status register exact data access violation.
|
||||||
|
*/
|
||||||
|
#define OS_EXC_BF_PRECISERR 4
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup los_exc
|
||||||
|
* Cortex-M exception types: Bus status register access violation while pointing.
|
||||||
|
*/
|
||||||
|
#define OS_EXC_BF_IBUSERR 5
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup los_exc
|
||||||
|
* Cortex-M exception types: An error occurred while the memory management status register was being pushed.
|
||||||
|
*/
|
||||||
|
#define OS_EXC_MF_MSTKERR 6
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup los_exc
|
||||||
|
* Cortex-M exception types: An error occurred while the memory management status register was out of the stack.
|
||||||
|
*/
|
||||||
|
#define OS_EXC_MF_MUNSTKERR 7
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup los_exc
|
||||||
|
* Cortex-M exception types: Memory management status register data access violation.
|
||||||
|
*/
|
||||||
|
#define OS_EXC_MF_DACCVIOL 8
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup los_exc
|
||||||
|
* Cortex-M exception types: Memory management status register access violation.
|
||||||
|
*/
|
||||||
|
#define OS_EXC_MF_IACCVIOL 9
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup los_exc
|
||||||
|
* Cortex-M exception types: Incorrect usage indicating that the divisor is zero during the division operation.
|
||||||
|
*/
|
||||||
|
#define OS_EXC_UF_DIVBYZERO 10
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup los_exc
|
||||||
|
* Cortex-M exception types: Usage error, error caused by unaligned access.
|
||||||
|
*/
|
||||||
|
#define OS_EXC_UF_UNALIGNED 11
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup los_exc
|
||||||
|
* Cortex-M exception types: Incorrect usage attempting to execute coprocessor related instruction.
|
||||||
|
*/
|
||||||
|
#define OS_EXC_UF_NOCP 12
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup los_exc
|
||||||
|
* Cortex-M exception types: Usage error attempting to load EXC_RETURN to PC illegally on exception return.
|
||||||
|
*/
|
||||||
|
#define OS_EXC_UF_INVPC 13
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup los_exc
|
||||||
|
* Cortex-M exception types: Incorrect usage, attempting to cut to ARM state.
|
||||||
|
*/
|
||||||
|
#define OS_EXC_UF_INVSTATE 14
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup los_exc
|
||||||
|
* Cortex-M exception types: Incorrect usage. Executed instruction whose code is undefined.
|
||||||
|
*/
|
||||||
|
#define OS_EXC_UF_UNDEFINSTR 15
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup los_exc
|
||||||
|
* Cortex-M exception types: NMI
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define OS_EXC_CAUSE_NMI 16
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup los_exc
|
||||||
|
* Cortex-M exception types: hard fault
|
||||||
|
*/
|
||||||
|
#define OS_EXC_CAUSE_HARDFAULT 17
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup los_exc
|
||||||
|
* Cortex-M exception types: The task handler exits.
|
||||||
|
*/
|
||||||
|
#define OS_EXC_CAUSE_TASK_EXIT 18
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup los_exc
|
||||||
|
* Cortex-M exception types: A fatal error.
|
||||||
|
*/
|
||||||
|
#define OS_EXC_CAUSE_FATAL_ERR 19
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup los_exc
|
||||||
|
* Cortex-M exception types: Hard Fault caused by a debug event.
|
||||||
|
*/
|
||||||
|
#define OS_EXC_CAUSE_DEBUGEVT 20
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup los_exc
|
||||||
|
* Cortex-M exception types: A hard fault that occurs when a quantity is oriented.
|
||||||
|
*/
|
||||||
|
#define OS_EXC_CAUSE_VECTBL 21
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup los_exc
|
||||||
|
* Exception information structure
|
||||||
|
*
|
||||||
|
* Description: Exception information saved when an exception is triggered on the Cortex-M33 platform.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
typedef struct TagExcInfo {
|
||||||
|
/**< Exception occurrence phase: 0 means that an exception occurs in initialization,
|
||||||
|
* 1 means that an exception occurs in a task, and 2 means that an exception occurs in an interrupt */
|
||||||
|
UINT16 phase;
|
||||||
|
/**< Exception type. When exceptions occur, check the numbers 1 - 21 listed above */
|
||||||
|
UINT16 type;
|
||||||
|
/**< If the exact address access error indicates the wrong access address when the exception occurred */
|
||||||
|
UINT32 faultAddr;
|
||||||
|
/**< An exception occurs in an interrupt, indicating the interrupt number.
|
||||||
|
* An exception occurs in the task, indicating the task ID, or 0xFFFFFFFF if it occurs during initialization */
|
||||||
|
UINT32 thrdPid;
|
||||||
|
/**< Number of nested exceptions. Currently only registered hook functions are supported
|
||||||
|
* when an exception is entered for the first time */
|
||||||
|
UINT16 nestCnt;
|
||||||
|
/**< reserve */
|
||||||
|
UINT16 reserved;
|
||||||
|
/**< Hardware context at the time an exception to the automatic stack floating-point register occurs */
|
||||||
|
EXC_CONTEXT_S *context;
|
||||||
|
} ExcInfo;
|
||||||
|
|
||||||
|
extern UINT32 g_curNestCount;
|
||||||
|
extern UINT32 g_intCount;
|
||||||
|
extern UINT8 g_uwExcTbl[32];
|
||||||
|
extern ExcInfo g_excInfo;
|
||||||
|
|
||||||
|
#define MAX_INT_INFO_SIZE (8 + 0x164)
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#if __cplusplus
|
||||||
|
}
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
#endif /* _LOS_ARCH_INTERRUPT_H */
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||||
|
* Copyright (c) 2020-2021 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _LOS_ARCH_TIMER_H
|
||||||
|
#define _LOS_ARCH_TIMER_H
|
||||||
|
|
||||||
|
#include "los_config.h"
|
||||||
|
#include "los_compiler.h"
|
||||||
|
#include "los_timer.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#if __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#if __cplusplus
|
||||||
|
}
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
#endif /* _LOS_ARCH_TIMER_H */
|
||||||
@@ -0,0 +1,163 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||||
|
* Copyright (c) 2020-2021 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "los_context.h"
|
||||||
|
#include "securec.h"
|
||||||
|
#include "los_arch_context.h"
|
||||||
|
#include "los_arch_interrupt.h"
|
||||||
|
#include "los_task.h"
|
||||||
|
#include "los_sched.h"
|
||||||
|
#include "los_interrupt.h"
|
||||||
|
#include "los_debug.h"
|
||||||
|
|
||||||
|
/* ****************************************************************************
|
||||||
|
Function : ArchInit
|
||||||
|
Description : arch init function
|
||||||
|
Input : None
|
||||||
|
Output : None
|
||||||
|
Return : None
|
||||||
|
**************************************************************************** */
|
||||||
|
LITE_OS_SEC_TEXT_INIT VOID ArchInit(VOID)
|
||||||
|
{
|
||||||
|
HalHwiInit();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ****************************************************************************
|
||||||
|
Function : ArchSysExit
|
||||||
|
Description : Task exit function
|
||||||
|
Input : None
|
||||||
|
Output : None
|
||||||
|
Return : None
|
||||||
|
**************************************************************************** */
|
||||||
|
LITE_OS_SEC_TEXT_MINOR VOID ArchSysExit(VOID)
|
||||||
|
{
|
||||||
|
(VOID)LOS_IntLock();
|
||||||
|
while (1) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ****************************************************************************
|
||||||
|
Function : ArchTskStackInit
|
||||||
|
Description : Task stack initialization function
|
||||||
|
Input : taskID --- TaskID
|
||||||
|
stackSize --- Total size of the stack
|
||||||
|
topStack --- Top of task's stack
|
||||||
|
Output : None
|
||||||
|
Return : Context pointer
|
||||||
|
**************************************************************************** */
|
||||||
|
LITE_OS_SEC_TEXT_INIT VOID *ArchTskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack)
|
||||||
|
{
|
||||||
|
TaskContext *context = (TaskContext *)((UINTPTR)topStack + stackSize - sizeof(TaskContext));
|
||||||
|
|
||||||
|
#if ((defined(__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
|
||||||
|
(defined(__FPU_USED) && (__FPU_USED == 1U)))
|
||||||
|
context->S16 = 0xAA000010;
|
||||||
|
context->S17 = 0xAA000011;
|
||||||
|
context->S18 = 0xAA000012;
|
||||||
|
context->S19 = 0xAA000013;
|
||||||
|
context->S20 = 0xAA000014;
|
||||||
|
context->S21 = 0xAA000015;
|
||||||
|
context->S22 = 0xAA000016;
|
||||||
|
context->S23 = 0xAA000017;
|
||||||
|
context->S24 = 0xAA000018;
|
||||||
|
context->S25 = 0xAA000019;
|
||||||
|
context->S26 = 0xAA00001A;
|
||||||
|
context->S27 = 0xAA00001B;
|
||||||
|
context->S28 = 0xAA00001C;
|
||||||
|
context->S29 = 0xAA00001D;
|
||||||
|
context->S30 = 0xAA00001E;
|
||||||
|
context->S31 = 0xAA00001F;
|
||||||
|
context->S0 = 0xAA000000;
|
||||||
|
context->S1 = 0xAA000001;
|
||||||
|
context->S2 = 0xAA000002;
|
||||||
|
context->S3 = 0xAA000003;
|
||||||
|
context->S4 = 0xAA000004;
|
||||||
|
context->S5 = 0xAA000005;
|
||||||
|
context->S6 = 0xAA000006;
|
||||||
|
context->S7 = 0xAA000007;
|
||||||
|
context->S8 = 0xAA000008;
|
||||||
|
context->S9 = 0xAA000009;
|
||||||
|
context->S10 = 0xAA00000A;
|
||||||
|
context->S11 = 0xAA00000B;
|
||||||
|
context->S12 = 0xAA00000C;
|
||||||
|
context->S13 = 0xAA00000D;
|
||||||
|
context->S14 = 0xAA00000E;
|
||||||
|
context->S15 = 0xAA00000F;
|
||||||
|
context->FPSCR = 0x00000000;
|
||||||
|
context->NO_NAME = 0xAA000011;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
context->secureContext = 0UL;
|
||||||
|
context->stackLimit = (UINT32)topStack;
|
||||||
|
context->excReturn = 0xFFFFFFBC;
|
||||||
|
|
||||||
|
context->uwR4 = 0x04040404L;
|
||||||
|
context->uwR5 = 0x05050505L;
|
||||||
|
context->uwR6 = 0x06060606L;
|
||||||
|
context->uwR7 = 0x07070707L;
|
||||||
|
context->uwR8 = 0x08080808L;
|
||||||
|
context->uwR9 = 0x09090909L;
|
||||||
|
context->uwR10 = 0x10101010L;
|
||||||
|
context->uwR11 = 0x11111111L;
|
||||||
|
context->uwPriMask = 0;
|
||||||
|
context->uwR0 = taskID;
|
||||||
|
context->uwR1 = 0x01010101L;
|
||||||
|
context->uwR2 = 0x02020202L;
|
||||||
|
context->uwR3 = 0x03030303L;
|
||||||
|
context->uwR12 = 0x12121212L;
|
||||||
|
context->uwLR = (UINT32)(UINTPTR)ArchSysExit;
|
||||||
|
context->uwPC = (UINT32)(UINTPTR)OsTaskEntry;
|
||||||
|
context->uwxPSR = 0x01000000L;
|
||||||
|
|
||||||
|
return (VOID *)context;
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID *ArchSignalContextInit(VOID *stackPointer, VOID *stackTop, UINTPTR sigHandler, UINT32 param)
|
||||||
|
{
|
||||||
|
TaskContext *context = (TaskContext *)((UINTPTR)stackPointer - sizeof(TaskContext));
|
||||||
|
(VOID)memset_s((VOID *)context, sizeof(TaskContext), 0, sizeof(TaskContext));
|
||||||
|
|
||||||
|
context->uwR0 = param;
|
||||||
|
context->uwPC = sigHandler;
|
||||||
|
context->stackLimit = (UINT32)stackTop;
|
||||||
|
context->excReturn = 0xFFFFFFBC;
|
||||||
|
context->uwxPSR = 0x01000000L; /* Thumb flag, always set 1 */
|
||||||
|
|
||||||
|
return (VOID *)context;
|
||||||
|
}
|
||||||
|
|
||||||
|
LITE_OS_SEC_TEXT_INIT UINT32 ArchStartSchedule(VOID)
|
||||||
|
{
|
||||||
|
(VOID)LOS_IntLock();
|
||||||
|
OsSchedStart();
|
||||||
|
HalStartToRun();
|
||||||
|
return LOS_OK; /* never return */
|
||||||
|
}
|
||||||
@@ -0,0 +1,270 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||||
|
* Copyright (c) 2020-2021 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
.syntax unified
|
||||||
|
.arch armv8.1-m.main
|
||||||
|
.fpu vfpv3-d16-fp16
|
||||||
|
.thumb
|
||||||
|
|
||||||
|
.equ OS_FPU_CPACR, 0xE000ED88
|
||||||
|
.equ OS_FPU_CPACR_ENABLE, 0x00F00000
|
||||||
|
.equ OS_NVIC_INT_CTRL, 0xE000ED04
|
||||||
|
.equ OS_NVIC_SYSPRI2, 0xE000ED20
|
||||||
|
.equ OS_NVIC_PENDSV_PRI, 0xF0F00000
|
||||||
|
.equ OS_NVIC_PENDSVSET, 0x10000000
|
||||||
|
.equ OS_TASK_STATUS_RUNNING, 0x0010
|
||||||
|
|
||||||
|
.section .text
|
||||||
|
.thumb
|
||||||
|
|
||||||
|
.macro SIGNAL_CONTEXT_RESTORE
|
||||||
|
PUSH {R12, LR}
|
||||||
|
BLX OsSignalTaskContextRestore
|
||||||
|
POP {R12, LR}
|
||||||
|
CMP R0, #0
|
||||||
|
MOV R1, R0
|
||||||
|
BNE SignalContextRestore
|
||||||
|
.endm
|
||||||
|
|
||||||
|
.type HalStartFirstTask, %function
|
||||||
|
.global HalStartFirstTask
|
||||||
|
HalStartFirstTask:
|
||||||
|
MOV R0, #2
|
||||||
|
MSR CONTROL, R0
|
||||||
|
|
||||||
|
LDR R1, =g_losTask
|
||||||
|
LDR R0, [R1, #4]
|
||||||
|
|
||||||
|
LDR R12, [R0] /* Get the stack pointer of the current task. */
|
||||||
|
LDMFD R12!, {R1-R3} /* Read from stack: R1 = secureContext, R2 = stackLmit and R3 = excReturn.*/
|
||||||
|
LDR R4, =g_secureContext
|
||||||
|
STR R1, [R4] /* Set the secureContext to g_secureContext handler. */
|
||||||
|
MSR PSPLIM, R2 /* Set the stackLmit for the PSPLIM about current task. */
|
||||||
|
ISB
|
||||||
|
|
||||||
|
LDR.W R1, =OS_FPU_CPACR
|
||||||
|
LDR R1, [R1]
|
||||||
|
AND R1, R1, #OS_FPU_CPACR_ENABLE
|
||||||
|
CMP R1, #OS_FPU_CPACR_ENABLE
|
||||||
|
BNE __DisabledFPU1
|
||||||
|
ADD R12, R12, #64
|
||||||
|
VPUSH {S0}
|
||||||
|
VPOP {S0}
|
||||||
|
|
||||||
|
__DisabledFPU1:
|
||||||
|
ADD R12, R12, #36
|
||||||
|
MSR PSP, R12
|
||||||
|
CPSIE I
|
||||||
|
BX R3
|
||||||
|
|
||||||
|
.type ArchIntLock, %function
|
||||||
|
.global ArchIntLock
|
||||||
|
ArchIntLock:
|
||||||
|
.fnstart
|
||||||
|
.cantunwind
|
||||||
|
|
||||||
|
MRS R0, PRIMASK
|
||||||
|
CPSID I
|
||||||
|
BX LR
|
||||||
|
.fnend
|
||||||
|
|
||||||
|
.type ArchIntUnLock, %function
|
||||||
|
.global ArchIntUnLock
|
||||||
|
ArchIntUnLock:
|
||||||
|
.fnstart
|
||||||
|
.cantunwind
|
||||||
|
|
||||||
|
MRS R0, PRIMASK
|
||||||
|
CPSIE I
|
||||||
|
BX LR
|
||||||
|
.fnend
|
||||||
|
|
||||||
|
.type ArchIntRestore, %function
|
||||||
|
.global ArchIntRestore
|
||||||
|
ArchIntRestore:
|
||||||
|
.fnstart
|
||||||
|
.cantunwind
|
||||||
|
|
||||||
|
MSR PRIMASK, R0
|
||||||
|
BX LR
|
||||||
|
.fnend
|
||||||
|
|
||||||
|
.type ArchTaskSchedule, %function
|
||||||
|
.global ArchTaskSchedule
|
||||||
|
ArchTaskSchedule:
|
||||||
|
.fnstart
|
||||||
|
.cantunwind
|
||||||
|
|
||||||
|
ldr r0, =OS_NVIC_INT_CTRL
|
||||||
|
ldr r1, =OS_NVIC_PENDSVSET
|
||||||
|
str r1, [r0]
|
||||||
|
dsb
|
||||||
|
isb
|
||||||
|
bx lr
|
||||||
|
.fnend
|
||||||
|
|
||||||
|
.type HalPendSV, %function
|
||||||
|
.global HalPendSV
|
||||||
|
HalPendSV:
|
||||||
|
.fnstart
|
||||||
|
.cantunwind
|
||||||
|
|
||||||
|
mrs r12, PRIMASK
|
||||||
|
cpsid I
|
||||||
|
|
||||||
|
HalTaskSwitch:
|
||||||
|
SIGNAL_CONTEXT_RESTORE
|
||||||
|
|
||||||
|
push {r12, lr}
|
||||||
|
blx OsSchedTaskSwitch
|
||||||
|
pop {r12, lr}
|
||||||
|
cmp r0, #0
|
||||||
|
mov r0, lr
|
||||||
|
bne TaskContextSwitch
|
||||||
|
msr PRIMASK, r12
|
||||||
|
bx lr
|
||||||
|
|
||||||
|
TaskContextSwitch:
|
||||||
|
mov lr, r0
|
||||||
|
mrs r0, psp
|
||||||
|
|
||||||
|
LDR R2, =g_secureContext
|
||||||
|
LDR R1, [R2]
|
||||||
|
CBZ R1, __SaveNSContext /* If the g_secureContext is NULL, so no secure context to save. */
|
||||||
|
|
||||||
|
PUSH {R0-R1, R12, R14} /* Store registers, include LR, PRIMASK. */
|
||||||
|
BL HalSecureContextSave /* Store the secure context to g_secureContext->curStackPointer. */
|
||||||
|
POP {R0-R3}
|
||||||
|
MOV LR, R3
|
||||||
|
MOV R12, R2 /* R2 = PRIMASK. */
|
||||||
|
|
||||||
|
__SaveNSContext:
|
||||||
|
STMFD R0!, {R4-R12}
|
||||||
|
LDR.W R3, =OS_FPU_CPACR
|
||||||
|
LDR R3, [R3]
|
||||||
|
AND R3, R3, #OS_FPU_CPACR_ENABLE
|
||||||
|
CMP R3, #OS_FPU_CPACR_ENABLE
|
||||||
|
BNE __DisabledFPU2
|
||||||
|
VSTMDB R0!, {D8-D15}
|
||||||
|
|
||||||
|
__DisabledFPU2:
|
||||||
|
LDR R5, =g_losTask
|
||||||
|
LDR R6, [R5] /* Get the stackPointer handler of the current task. */
|
||||||
|
SUBS R0, R0, #12
|
||||||
|
STR R0, [R6] /* Save the new top of stack in TCB. */
|
||||||
|
MRS R2, PSPLIM
|
||||||
|
MOV R3, LR
|
||||||
|
STMIA R0!, {R1, R2-R3} /* Store g_secureContext, PSPLIM and LR on the stack of current task. */
|
||||||
|
|
||||||
|
LDR R0, [R5, #4]
|
||||||
|
STR R0, [R5]
|
||||||
|
LDR R1, [R0]
|
||||||
|
|
||||||
|
SignalContextRestore:
|
||||||
|
LDMIA R1!, {R0, R2-R3} /* Restore secureContext, PSPLIM and LR from the current task stack. */
|
||||||
|
MSR PSPLIM, R2
|
||||||
|
MOV LR, R3
|
||||||
|
LDR R2, =g_secureContext
|
||||||
|
STR R0, [R2] /* Set the secureContext of the new task to g_secureContext. */
|
||||||
|
CBZ R0, __RestoreNSContext /* If there is no secure context for the new task, so restore from the non-secure context. */
|
||||||
|
PUSH {R1, R3}
|
||||||
|
BL HalSecureContextLoad /* Restore the secure context. */
|
||||||
|
POP {R1, R3}
|
||||||
|
MOV LR, R3
|
||||||
|
|
||||||
|
__RestoreNSContext:
|
||||||
|
LDR.W R3, =OS_FPU_CPACR
|
||||||
|
LDR R3, [R3]
|
||||||
|
AND R3, R3, #OS_FPU_CPACR_ENABLE
|
||||||
|
CMP R3, #OS_FPU_CPACR_ENABLE
|
||||||
|
BNE __DisabledFPU3
|
||||||
|
VLDMIA R1!, {D8-D15}
|
||||||
|
|
||||||
|
__DisabledFPU3:
|
||||||
|
LDMFD R1!, {R4-R12}
|
||||||
|
MSR PSP, R1
|
||||||
|
|
||||||
|
MSR PRIMASK, R12
|
||||||
|
BX LR
|
||||||
|
.fnend
|
||||||
|
|
||||||
|
.type HalSVCStartSchedule, %function
|
||||||
|
.global HalSVCStartSchedule
|
||||||
|
HalSVCStartSchedule:
|
||||||
|
.fnstart
|
||||||
|
.cantunwind
|
||||||
|
LDR R4, =OS_NVIC_SYSPRI2
|
||||||
|
LDR R5, =OS_NVIC_PENDSV_PRI
|
||||||
|
STR R5, [R4]
|
||||||
|
CPSIE I
|
||||||
|
DSB
|
||||||
|
ISB
|
||||||
|
SVC 2
|
||||||
|
.fnend
|
||||||
|
|
||||||
|
.type HalSVCSecureContextAlloc, %function
|
||||||
|
.global HalSVCSecureContextAlloc
|
||||||
|
HalSVCSecureContextAlloc:
|
||||||
|
.fnstart
|
||||||
|
.cantunwind
|
||||||
|
SVC 0
|
||||||
|
BX LR
|
||||||
|
.fnend
|
||||||
|
|
||||||
|
.type HalSVCSecureContextFree, %function
|
||||||
|
.global HalSVCSecureContextFree
|
||||||
|
HalSVCSecureContextFree:
|
||||||
|
.fnstart
|
||||||
|
.cantunwind
|
||||||
|
SVC 1
|
||||||
|
BX LR
|
||||||
|
.fnend
|
||||||
|
|
||||||
|
.type HalSVCHandler, %function
|
||||||
|
.global HalSVCHandler
|
||||||
|
HalSVCHandler:
|
||||||
|
.fnstart
|
||||||
|
.cantunwind
|
||||||
|
TST LR, #0x04
|
||||||
|
ITE EQ
|
||||||
|
MRSEQ R1, MSP
|
||||||
|
MRSNE R1, PSP
|
||||||
|
LDR R0, [R1, #24]
|
||||||
|
LDRB R0, [R0, #-2] /* Get the SVC number. */
|
||||||
|
|
||||||
|
PUSH {LR}
|
||||||
|
MOV R2, R1 /* Get the stack for R2. */
|
||||||
|
LDMFD R2!, {R1} /* Get the input arg for HalSecureSVCHandler. */
|
||||||
|
STMFD R2!, {R1}
|
||||||
|
BL HalSecureSVCHandler
|
||||||
|
POP {LR}
|
||||||
|
BX LR
|
||||||
|
.fnend
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user