Compare commits
32 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c70295cc30 | |||
| c19dc1bc94 | |||
| d2bf535696 | |||
| bda25829af | |||
| a1e215f16a | |||
| 5e36b8b599 | |||
| 954aa6fb70 | |||
| 64a73724b3 | |||
| 2a49ac7323 | |||
| cde26d8d68 | |||
| 4140bd673e | |||
| 2b81e524a1 | |||
| 1dae9259ef | |||
| 3ce50a610c | |||
| cf980647d6 | |||
| ab131703be | |||
| f42c36ac8e | |||
| f2ddeaebfd | |||
| 5d5e155f31 | |||
| 0c3dbb4c01 | |||
| 873255af51 | |||
| 22702a27fc | |||
| b37358cb47 | |||
| b73eb72ba6 | |||
| e98de4489f | |||
| 4cfb20d7e9 | |||
| 9248d46457 | |||
| 808b9de5b8 | |||
| cfdad0f44b | |||
| 81c25c6d54 | |||
| 222960f6de | |||
| eb7e307355 |
@@ -44,6 +44,10 @@ if (defined(LOSCFG_COMPILER_ICCARM)) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
declare_args() {
|
||||||
|
liteos_build_asm = true
|
||||||
|
}
|
||||||
|
|
||||||
config("arch_config") {
|
config("arch_config") {
|
||||||
cflags = arch_config_cflags
|
cflags = arch_config_cflags
|
||||||
asmflags = arch_config_asmflags
|
asmflags = arch_config_asmflags
|
||||||
@@ -215,4 +219,7 @@ build_ext_component("build_kernel_image") {
|
|||||||
exec_path = rebase_path(root_out_dir)
|
exec_path = rebase_path(root_out_dir)
|
||||||
|
|
||||||
command = toochain_config_command
|
command = toochain_config_command
|
||||||
|
if (liteos_build_asm) {
|
||||||
|
command += toochain_asm_command
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,19 +39,9 @@ choice
|
|||||||
config COMPILER_GCC
|
config COMPILER_GCC
|
||||||
bool "GCC"
|
bool "GCC"
|
||||||
|
|
||||||
config CROSS_COMPILE
|
|
||||||
string "GCC cross-compile toolchain prefix"
|
|
||||||
depends on COMPILER_GCC
|
|
||||||
default "arm-none-eabi-" if ARCH_ARM_AARCH32
|
|
||||||
|
|
||||||
config COMPILER_CLANG_LLVM
|
config COMPILER_CLANG_LLVM
|
||||||
bool "Clang"
|
bool "Clang"
|
||||||
|
|
||||||
config LLVM_TARGET
|
|
||||||
string "Clang LLVM target"
|
|
||||||
depends on COMPILER_CLANG_LLVM
|
|
||||||
default "arm-liteos-ohos" if ARCH_ARM_AARCH32
|
|
||||||
|
|
||||||
config COMPILER_ICCARM
|
config COMPILER_ICCARM
|
||||||
bool "ICCARM"
|
bool "ICCARM"
|
||||||
|
|
||||||
@@ -96,15 +86,6 @@ config PLATFORM
|
|||||||
string
|
string
|
||||||
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
|
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
|
|
||||||
string
|
|
||||||
default "arm_virt" if PRODUCT_QEMU_ARM
|
|
||||||
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 "csky_smartl_e802" if PRODUCT_QEMU_CSKY_SMARTL_E802
|
|
||||||
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 || PLATFORM_QEMU_ARM_VIRT_CM55 || 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
|
||||||
@@ -163,24 +144,9 @@ choice
|
|||||||
help
|
help
|
||||||
Select your target board.
|
Select your target board.
|
||||||
|
|
||||||
config PRODUCT_QEMU_ARM
|
|
||||||
bool "arm_virt" if PLATFORM_QEMU_ARM_VIRT_CM7
|
|
||||||
|
|
||||||
config PRODUCT_QEMU_ARM_MPS2_AN386
|
|
||||||
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
|
||||||
|
|
||||||
config PRODUCT_QEMU_CSKY_SMARTL_E802
|
|
||||||
bool "csky_smartl_e802" if PLATFORM_QEMU_CSKY_SMARTL
|
|
||||||
|
|
||||||
config PRODUCT_QEMU_XTENSA_ESP32
|
|
||||||
bool "xtensa_esp32" if PLATFORM_QEMU_XTENSA_ESP32
|
|
||||||
|
|
||||||
endchoice
|
endchoice
|
||||||
|
|
||||||
|
|
||||||
@@ -219,12 +185,6 @@ endchoice
|
|||||||
|
|
||||||
orsource "../../device/soc/*/Kconfig.liteos_m.soc"
|
orsource "../../device/soc/*/Kconfig.liteos_m.soc"
|
||||||
|
|
||||||
config QUICK_START
|
|
||||||
bool "Enable QUICK_START"
|
|
||||||
default n
|
|
||||||
depends on DRIVERS && FS_VFS
|
|
||||||
help
|
|
||||||
Answer Y to enable LiteOS support quick start.
|
|
||||||
endmenu
|
endmenu
|
||||||
|
|
||||||
######################### config options of kernel #####################
|
######################### config options of kernel #####################
|
||||||
@@ -343,21 +303,6 @@ config KERNEL_PM_IDLE
|
|||||||
Configuration item for low power frame tailoring.
|
Configuration item for low power frame tailoring.
|
||||||
If you wish to build LiteOS with support for power management idle.
|
If you wish to build LiteOS with support for power management idle.
|
||||||
|
|
||||||
config KERNEL_PM_TASK_PTIORITY
|
|
||||||
int "Power Management Task Priority"
|
|
||||||
default 1
|
|
||||||
range 1 31
|
|
||||||
depends on KERNEL_PM
|
|
||||||
help
|
|
||||||
Configuration item for priority of low-power task.
|
|
||||||
|
|
||||||
config KERNEL_PM_TASK_STACKSIZE
|
|
||||||
int "Power Management Task Stack Size"
|
|
||||||
default 1024
|
|
||||||
depends on KERNEL_PM
|
|
||||||
help
|
|
||||||
Configuration item for stack size of low-power task.
|
|
||||||
|
|
||||||
config KERNEL_PM_DEBUG
|
config KERNEL_PM_DEBUG
|
||||||
bool "Power Management Debug"
|
bool "Power Management Debug"
|
||||||
default n
|
default n
|
||||||
@@ -393,17 +338,6 @@ source "components/lms/Kconfig"
|
|||||||
|
|
||||||
endmenu
|
endmenu
|
||||||
|
|
||||||
######################### config options of lib ########################
|
|
||||||
menu "Lib"
|
|
||||||
config LIB_LIBC
|
|
||||||
bool "Enable Libc"
|
|
||||||
default y
|
|
||||||
help
|
|
||||||
Answer Y to enable libc for full code.
|
|
||||||
|
|
||||||
endmenu
|
|
||||||
|
|
||||||
|
|
||||||
######################### config options of compatibility ##############
|
######################### config options of compatibility ##############
|
||||||
menu "Compat"
|
menu "Compat"
|
||||||
|
|
||||||
@@ -436,43 +370,6 @@ endmenu
|
|||||||
|
|
||||||
######################## config options of debug ########################
|
######################## config options of debug ########################
|
||||||
menu "Debug"
|
menu "Debug"
|
||||||
config GDB
|
|
||||||
bool "Enable gdb functions"
|
|
||||||
default n
|
|
||||||
help
|
|
||||||
Answer Y to enable gdb functions.
|
|
||||||
|
|
||||||
config PLATFORM_ADAPT
|
|
||||||
bool "Enable Os_adapt"
|
|
||||||
default y
|
|
||||||
help
|
|
||||||
Answer Y to add os_adapt.c to LiteOS.
|
|
||||||
|
|
||||||
config ENABLE_OOM_LOOP_TASK
|
|
||||||
bool "Enable Oom loop task"
|
|
||||||
default n
|
|
||||||
depends on KERNEL_VM
|
|
||||||
help
|
|
||||||
Answer Y to enable oom loop kthread to check system out of memory.
|
|
||||||
|
|
||||||
config DO_ALIGN
|
|
||||||
bool "Enable do align for hi3518e"
|
|
||||||
default y
|
|
||||||
depends on PLATFORM_HI3518EV200
|
|
||||||
help
|
|
||||||
Answer Y to enable do align for hi3518e.
|
|
||||||
|
|
||||||
|
|
||||||
config ENABLE_MAGICKEY
|
|
||||||
bool "Enable MAGIC KEY"
|
|
||||||
default y
|
|
||||||
help
|
|
||||||
Answer Y to enable LiteOS Magic key.
|
|
||||||
ctrl + r : Magic key check switch;
|
|
||||||
ctrl + z : Show all magic op key;
|
|
||||||
ctrl + t : Show task information;
|
|
||||||
ctrl + p : System panic;
|
|
||||||
ctrl + e : Check system memory pool.
|
|
||||||
|
|
||||||
config THUMB
|
config THUMB
|
||||||
bool "Enable Thumb"
|
bool "Enable Thumb"
|
||||||
@@ -481,20 +378,6 @@ config THUMB
|
|||||||
help
|
help
|
||||||
Answer Y to build thumb version. This will make LiteOS smaller.
|
Answer Y to build thumb version. This will make LiteOS smaller.
|
||||||
|
|
||||||
config PLATFORM_DVFS
|
|
||||||
bool "Enable Dvfs"
|
|
||||||
default n
|
|
||||||
depends on COMPAT_LINUXKPI
|
|
||||||
help
|
|
||||||
Answer Y to enable LiteOS support dynamic voltage and frequency scaling feature for
|
|
||||||
low power consumption.
|
|
||||||
|
|
||||||
config SAVE_EXCINFO
|
|
||||||
bool "Enable Saving Exception Information"
|
|
||||||
default n
|
|
||||||
help
|
|
||||||
Answer Y to enable LiteOS support saving exception information to storage medium.
|
|
||||||
|
|
||||||
config DEBUG_VERSION
|
config DEBUG_VERSION
|
||||||
bool "Enable a Debug Version"
|
bool "Enable a Debug Version"
|
||||||
default y
|
default y
|
||||||
@@ -514,13 +397,6 @@ config DEBUG_KERNEL
|
|||||||
It also means you want to get queue, mutex, semaphore, memory debug information.
|
It also means you want to get queue, mutex, semaphore, memory debug information.
|
||||||
That means you want a opposite behaviour compared to release version.
|
That means you want a opposite behaviour compared to release version.
|
||||||
|
|
||||||
config DEBUG_QUEUE
|
|
||||||
bool "Enable Queue Debugging"
|
|
||||||
default n
|
|
||||||
depends on DEBUG_KERNEL
|
|
||||||
help
|
|
||||||
Answer Y to enable debug queue.
|
|
||||||
|
|
||||||
config MUTEX_CREATE_TRACE
|
config MUTEX_CREATE_TRACE
|
||||||
bool "Enable Mutex Trace Debugging"
|
bool "Enable Mutex Trace Debugging"
|
||||||
default n
|
default n
|
||||||
@@ -529,20 +405,6 @@ config MUTEX_CREATE_TRACE
|
|||||||
help
|
help
|
||||||
Answer Y to enable debug mutex trace.
|
Answer Y to enable debug mutex trace.
|
||||||
|
|
||||||
config DEBUG_DEADLOCK
|
|
||||||
bool "Enable Mutex Deadlock Debugging"
|
|
||||||
default n
|
|
||||||
depends on DEBUG_KERNEL
|
|
||||||
help
|
|
||||||
Answer Y to enable debug mutex deadlock.
|
|
||||||
|
|
||||||
config DEBUG_SEMAPHORE
|
|
||||||
bool "Enable Semaphore Debugging"
|
|
||||||
default n
|
|
||||||
depends on DEBUG_KERNEL
|
|
||||||
help
|
|
||||||
Answer Y to enable debug semaphore.
|
|
||||||
|
|
||||||
config NET_LWIP_SACK_TFTP
|
config NET_LWIP_SACK_TFTP
|
||||||
bool "Enable Tftp"
|
bool "Enable Tftp"
|
||||||
default y
|
default y
|
||||||
@@ -557,18 +419,6 @@ config DEBUG_HOOK
|
|||||||
help
|
help
|
||||||
Enable the kernel hook framework to support customized trace information capture.
|
Enable the kernel hook framework to support customized trace information capture.
|
||||||
|
|
||||||
config SCHED_DEBUG
|
|
||||||
bool "Enable sched debug Feature"
|
|
||||||
default n
|
|
||||||
depends on DEBUG_VERSION
|
|
||||||
help
|
|
||||||
If you wish to build LiteOS with support for sched debug.
|
|
||||||
|
|
||||||
config USER_INIT_DEBUG
|
|
||||||
bool "Enable user init Debug"
|
|
||||||
default n
|
|
||||||
depends on DEBUG_VERSION
|
|
||||||
|
|
||||||
config SHELL_CMD_DEBUG
|
config SHELL_CMD_DEBUG
|
||||||
bool "Enable shell cmd Debug"
|
bool "Enable shell cmd Debug"
|
||||||
default n
|
default n
|
||||||
@@ -581,13 +431,6 @@ config DEBUG_TOOLS
|
|||||||
help
|
help
|
||||||
Answer Y to enable LiteOS debug tools, include stackdump, hwidump, tasktrack.
|
Answer Y to enable LiteOS debug tools, include stackdump, hwidump, tasktrack.
|
||||||
|
|
||||||
config USB_DEBUG
|
|
||||||
bool "Enable USB Debug"
|
|
||||||
default n
|
|
||||||
depends on SHELL && DRIVERS_USB && DEBUG_VERSION
|
|
||||||
help
|
|
||||||
Answer Y to enable LiteOS support usb debug.
|
|
||||||
use shell command to open the specified debug level print.
|
|
||||||
config MEM_DEBUG
|
config MEM_DEBUG
|
||||||
bool "Enable MEM Debug"
|
bool "Enable MEM Debug"
|
||||||
default n
|
default n
|
||||||
@@ -611,13 +454,6 @@ config MEM_WATERLINE
|
|||||||
default n
|
default n
|
||||||
depends on DEBUG_VERSION && MEM_DEBUG
|
depends on DEBUG_VERSION && MEM_DEBUG
|
||||||
|
|
||||||
config VM_OVERLAP_CHECK
|
|
||||||
bool "Enable VM overlap check or not"
|
|
||||||
default n
|
|
||||||
depends on DEBUG_VERSION && MEM_DEBUG
|
|
||||||
help
|
|
||||||
Answer Y to enable vm overlap check.
|
|
||||||
|
|
||||||
config TASK_MEM_USED
|
config TASK_MEM_USED
|
||||||
bool "Enable show task mem used or not"
|
bool "Enable show task mem used or not"
|
||||||
default n
|
default n
|
||||||
@@ -643,12 +479,6 @@ config SECURE_HEAP_SIZE
|
|||||||
int "TrustZone Heap Size (bytes)"
|
int "TrustZone Heap Size (bytes)"
|
||||||
default 2048
|
default 2048
|
||||||
depends on SECURE_TRUSTZONE
|
depends on SECURE_TRUSTZONE
|
||||||
config SECURE_STACK_DEFAULT_SIZE
|
|
||||||
int "TrustZone Stack Size (bytes)"
|
|
||||||
default 512
|
|
||||||
depends on SECURE_TRUSTZONE
|
|
||||||
help
|
|
||||||
The secure stack must be allocated before the task calls non-secure functions.
|
|
||||||
config SECURE
|
config SECURE
|
||||||
bool "Enable Security"
|
bool "Enable Security"
|
||||||
default n
|
default n
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ The directory structure is as follows. For more details, see [arch_spec.md](arch
|
|||||||
│ ├── include # APIs exposed externally
|
│ ├── include # APIs exposed externally
|
||||||
│ ├── risc-v # Code of the risc-v architecture
|
│ ├── risc-v # Code of the risc-v architecture
|
||||||
│ │ ├── nuclei # Code of the nuclei system technology risc-v architecture
|
│ │ ├── nuclei # Code of the nuclei system technology risc-v architecture
|
||||||
│ │ └── riscv32 # Code of the risc-v architecture
|
│ │ └── riscv32 # Code of the risc-v official common architecture
|
||||||
│ └── xtensa # Code of the xtensa architecture
|
│ └── xtensa # Code of the xtensa architecture
|
||||||
│ └── lx6 # Code of the lx6 xtensa architecture
|
│ └── lx6 # Code of the lx6 xtensa architecture
|
||||||
├── components # Optional components
|
├── components # Optional components
|
||||||
|
|||||||
@@ -24,27 +24,6 @@ config ARCH_FPU_DISABLE
|
|||||||
help
|
help
|
||||||
This option will bypass floating procedure in system.
|
This option will bypass floating procedure in system.
|
||||||
|
|
||||||
config ARCH_SECURE_MONITOR_MODE
|
|
||||||
bool "Run On Secure Monitor Mode"
|
|
||||||
default n
|
|
||||||
depends on ARCH_ARM_AARCH64
|
|
||||||
help
|
|
||||||
This option will make the system run on EL3.
|
|
||||||
|
|
||||||
config ARCH_INTERRUPT_PREEMPTION
|
|
||||||
bool "Enable Interrupt Preemption"
|
|
||||||
default n
|
|
||||||
depends on ARCH_ARM_AARCH64
|
|
||||||
help
|
|
||||||
This option will support high priority interrupt preemption.
|
|
||||||
|
|
||||||
config IRQ_USE_STANDALONE_STACK
|
|
||||||
bool "Use Interrupt Stack"
|
|
||||||
default y
|
|
||||||
depends on ARCH_ARM_AARCH64 || ARCH_ARM_AARCH32
|
|
||||||
help
|
|
||||||
This option will support using standalone interrupt stack.
|
|
||||||
|
|
||||||
config ARCH_UNALIGNED_EXC
|
config ARCH_UNALIGNED_EXC
|
||||||
bool "Enable Unaligned Exception"
|
bool "Enable Unaligned Exception"
|
||||||
default y
|
default y
|
||||||
|
|||||||
+4
-3
@@ -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-2022 Huawei Device Co., Ltd. All rights reserved.
|
# Copyright (c) 2020-2023 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,10 +34,11 @@ config("arm_config") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
module_group("arm") {
|
module_group("arm") {
|
||||||
|
modules = [ "common" ]
|
||||||
if (defined(LOSCFG_COMPILER_ICCARM)) {
|
if (defined(LOSCFG_COMPILER_ICCARM)) {
|
||||||
modules = [ "$board_cpu/iar" ]
|
modules += [ "$board_cpu/iar" ]
|
||||||
} else {
|
} else {
|
||||||
modules = [ "$board_cpu/gcc" ]
|
modules += [ "$board_cpu/gcc" ]
|
||||||
}
|
}
|
||||||
configs = [ ":arm_config" ]
|
configs = [ ":arm_config" ]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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-2023 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:
|
||||||
@@ -32,9 +32,7 @@
|
|||||||
#ifndef _LOS_ARCH_INTERRUPT_H
|
#ifndef _LOS_ARCH_INTERRUPT_H
|
||||||
#define _LOS_ARCH_INTERRUPT_H
|
#define _LOS_ARCH_INTERRUPT_H
|
||||||
|
|
||||||
#include "los_config.h"
|
#include "los_common_interrupt.h"
|
||||||
#include "los_compiler.h"
|
|
||||||
#include "los_interrupt.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
@@ -42,14 +40,6 @@ extern "C" {
|
|||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
#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
|
* @ingroup los_arch_interrupt
|
||||||
* Highest priority of a hardware interrupt.
|
* Highest priority of a hardware interrupt.
|
||||||
@@ -66,19 +56,6 @@ extern "C" {
|
|||||||
#define OS_HWI_PRIO_LOWEST 7
|
#define OS_HWI_PRIO_LOWEST 7
|
||||||
#endif
|
#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
|
* @ingroup los_arch_interrupt
|
||||||
* Count of arm9 system interrupt vector.
|
* Count of arm9 system interrupt vector.
|
||||||
@@ -174,19 +151,15 @@ extern UINT32 g_intCount;
|
|||||||
*/
|
*/
|
||||||
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
|
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
|
||||||
|
|
||||||
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Set interrupt vector table.
|
* Hardware interrupt error code: Invalid interrupt operation function.
|
||||||
|
*
|
||||||
|
* Value: 0x0200090c
|
||||||
|
*
|
||||||
|
* Solution: Set a valid interrupt operation function
|
||||||
*/
|
*/
|
||||||
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg);
|
#define OS_ERRNO_HWI_OPS_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x0c)
|
||||||
#else
|
|
||||||
/* *
|
|
||||||
* @ingroup los_hwi
|
|
||||||
* Set interrupt vector table.
|
|
||||||
*/
|
|
||||||
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_arch_interrupt
|
* @ingroup los_arch_interrupt
|
||||||
@@ -207,35 +180,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
|
|||||||
*/
|
*/
|
||||||
extern VOID HalInterrupt(VOID);
|
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);
|
|
||||||
|
|
||||||
#define OS_EXC_IN_INIT 0
|
|
||||||
#define OS_EXC_IN_TASK 1
|
|
||||||
#define OS_EXC_IN_HWI 2
|
|
||||||
|
|
||||||
#define OS_EXC_FLAG_FAULTADDR_VALID 0x01
|
|
||||||
#define OS_EXC_FLAG_IN_HWI 0x02
|
|
||||||
|
|
||||||
#define OS_EXC_IMPRECISE_ACCESS_ADDR 0xABABABAB
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ingroup los_exc
|
* @ingroup los_exc
|
||||||
* the struct of register files
|
* the struct of register files
|
||||||
@@ -325,7 +269,6 @@ typedef struct TagExcInfo {
|
|||||||
EXC_CONTEXT_S *context;
|
EXC_CONTEXT_S *context;
|
||||||
} ExcInfo;
|
} ExcInfo;
|
||||||
|
|
||||||
extern UINT32 g_intCount;
|
|
||||||
extern ExcInfo g_excInfo;
|
extern ExcInfo g_excInfo;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
@@ -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-2023 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:
|
||||||
@@ -28,12 +28,10 @@
|
|||||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
#include "los_interrupt.h"
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include "securec.h"
|
#include "securec.h"
|
||||||
#include "los_context.h"
|
#include "los_context.h"
|
||||||
#include "los_arch_interrupt.h"
|
#include "los_arch_interrupt.h"
|
||||||
#include "los_debug.h"
|
|
||||||
#include "los_hook.h"
|
#include "los_hook.h"
|
||||||
#include "los_task.h"
|
#include "los_task.h"
|
||||||
#include "los_sched.h"
|
#include "los_sched.h"
|
||||||
@@ -42,7 +40,6 @@
|
|||||||
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
|
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
|
||||||
#include "los_cpup.h"
|
#include "los_cpup.h"
|
||||||
#endif
|
#endif
|
||||||
#include "los_reg.h"
|
|
||||||
|
|
||||||
#define OS_INT_IRQ_ENABLE (1U << 0)
|
#define OS_INT_IRQ_ENABLE (1U << 0)
|
||||||
#define OS_INT_FIQ_ENABLE (1U << 1)
|
#define OS_INT_FIQ_ENABLE (1U << 1)
|
||||||
@@ -55,86 +52,8 @@
|
|||||||
#define OS_ARM_INSTR_LEN 4
|
#define OS_ARM_INSTR_LEN 4
|
||||||
#define OS_THUMB_INSTR_LEN 2
|
#define OS_THUMB_INSTR_LEN 2
|
||||||
|
|
||||||
UINT32 g_intCount = 0;
|
|
||||||
ExcInfo g_excInfo = {0};
|
ExcInfo g_excInfo = {0};
|
||||||
|
|
||||||
/* *
|
|
||||||
* @ingroup los_hwi
|
|
||||||
* hardware interrupt form mapping handling function array.
|
|
||||||
*/
|
|
||||||
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)
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
/* ****************************************************************************
|
/* ****************************************************************************
|
||||||
Function : HwiNumGet
|
Function : HwiNumGet
|
||||||
Description : Get an interrupt number
|
Description : Get an interrupt number
|
||||||
@@ -153,10 +72,6 @@ STATIC UINT32 HwiNumGet(VOID)
|
|||||||
|
|
||||||
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
|
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));
|
*((volatile UINT32 *)OS_INT_ENABLE_ADDR) |= (1U << (hwiNum));
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
@@ -164,48 +79,28 @@ STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
|
|||||||
|
|
||||||
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
|
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));
|
*((volatile UINT32 *)OS_INT_ENABLE_ADDR) &= ~(1U << (hwiNum));
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
HwiControllerOps g_archHwiOps = {
|
STATIC UINT32 HwiCreate(HWI_HANDLE_T hwiNum, HWI_PRIOR_T hwiPrio)
|
||||||
|
{
|
||||||
|
(VOID)hwiPrio;
|
||||||
|
HwiUnmask(hwiNum);
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC HwiControllerOps g_archHwiOps = {
|
||||||
.enableIrq = HwiUnmask,
|
.enableIrq = HwiUnmask,
|
||||||
.disableIrq = HwiMask,
|
.disableIrq = HwiMask,
|
||||||
.getCurIrqNum = HwiNumGet,
|
.getCurIrqNum = HwiNumGet,
|
||||||
|
.createIrq = HwiCreate,
|
||||||
};
|
};
|
||||||
|
|
||||||
inline UINT32 ArchIsIntActive(VOID)
|
HwiControllerOps *ArchIntOpsGet(VOID)
|
||||||
{
|
{
|
||||||
return (g_intCount > 0);
|
return &g_archHwiOps;
|
||||||
}
|
|
||||||
/* ****************************************************************************
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ****************************************************************************
|
/* ****************************************************************************
|
||||||
@@ -264,87 +159,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
|
|||||||
LOS_IntRestore(intSave);
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
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(hwiNum);
|
|
||||||
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(hwiNum);
|
|
||||||
|
|
||||||
intSave = LOS_IntLock();
|
|
||||||
g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
|
|
||||||
LOS_IntRestore(intSave);
|
|
||||||
|
|
||||||
return LOS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if (LOSCFG_KERNEL_PRINTF != 0)
|
#if (LOSCFG_KERNEL_PRINTF != 0)
|
||||||
STATIC VOID OsExcTypeInfo(const ExcInfo *excInfo)
|
STATIC VOID OsExcTypeInfo(const ExcInfo *excInfo)
|
||||||
{
|
{
|
||||||
@@ -511,13 +325,14 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
|
|||||||
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
|
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
|
||||||
UINT32 reg;
|
UINT32 reg;
|
||||||
UINT32 val;
|
UINT32 val;
|
||||||
|
HWI_PROC_FUNC *hwiForm = (HWI_PROC_FUNC *)ArchGetHwiFrom();
|
||||||
|
|
||||||
for (val = OS_SYS_VECTOR_CNT; val < OS_VECTOR_CNT; val++) {
|
for (val = OS_SYS_VECTOR_CNT; val < OS_VECTOR_CNT; val++) {
|
||||||
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
|
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
|
||||||
g_hwiForm[val].pfnHook = HalHwiDefaultHandler;
|
hwiForm[val].pfnHook = HalHwiDefaultHandler;
|
||||||
g_hwiForm[val].uwParam = 0;
|
hwiForm[val].uwParam = 0;
|
||||||
#else
|
#else
|
||||||
g_hwiForm[val] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
|
hwiForm[val] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -560,4 +375,3 @@ UINT32 ArchIntUnLock(VOID)
|
|||||||
: "memory");
|
: "memory");
|
||||||
return intSave;
|
return intSave;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
# Copyright (c) 2023-2023 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 = "common"
|
||||||
|
kernel_module(module_name) {
|
||||||
|
sources = [ "los_common_interrupt.c" ]
|
||||||
|
configs += [ "$LITEOSTOPDIR:warn_config" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
config("public") {
|
||||||
|
include_dirs = [ "." ]
|
||||||
|
}
|
||||||
@@ -0,0 +1,328 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2023-2023 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_arch_interrupt.h"
|
||||||
|
#include "los_debug.h"
|
||||||
|
|
||||||
|
#ifdef __ICCARM__
|
||||||
|
#pragma location = ".data.vector"
|
||||||
|
#pragma data_alignment = LOSCFG_ARCH_HWI_VECTOR_ALIGN
|
||||||
|
/* *
|
||||||
|
* @ingroup los_hwi
|
||||||
|
* Hardware interrupt form mapping handling function array.
|
||||||
|
*/
|
||||||
|
HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT] = {0};
|
||||||
|
#elif defined(__CC_ARM) || defined(__GNUC__)
|
||||||
|
LITE_OS_SEC_VEC
|
||||||
|
/* *
|
||||||
|
* @ingroup los_hwi
|
||||||
|
* Hardware interrupt form mapping handling function array.
|
||||||
|
*/
|
||||||
|
HWI_PROC_FUNC __attribute__((aligned(LOSCFG_ARCH_HWI_VECTOR_ALIGN))) g_hwiForm[OS_VECTOR_CNT] = {0};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
VOID *ArchGetHwiFrom(VOID)
|
||||||
|
{
|
||||||
|
return g_hwiForm;
|
||||||
|
}
|
||||||
|
|
||||||
|
UINT32 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__, ArchIntCurIrqNum());
|
||||||
|
while (1) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
WEAK VOID HalPreInterruptHandler(UINT32 arg)
|
||||||
|
{
|
||||||
|
(VOID)arg;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
WEAK VOID HalAftInterruptHandler(UINT32 arg)
|
||||||
|
{
|
||||||
|
(VOID)arg;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
#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 OsHwiIsCreated(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.
|
||||||
|
*/
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
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
|
||||||
|
|
||||||
|
UINT32 ArchIntTrigger(HWI_HANDLE_T hwiNum)
|
||||||
|
{
|
||||||
|
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||||
|
return OS_ERRNO_HWI_NUM_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
HwiControllerOps *hwiOps = ArchIntOpsGet();
|
||||||
|
if (hwiOps->triggerIrq == NULL) {
|
||||||
|
return OS_ERRNO_HWI_OPS_FUNC_NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return hwiOps->triggerIrq(hwiNum);
|
||||||
|
}
|
||||||
|
|
||||||
|
UINT32 ArchIntEnable(HWI_HANDLE_T hwiNum)
|
||||||
|
{
|
||||||
|
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||||
|
return OS_ERRNO_HWI_NUM_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
HwiControllerOps *hwiOps = ArchIntOpsGet();
|
||||||
|
if (hwiOps->enableIrq == NULL) {
|
||||||
|
return OS_ERRNO_HWI_OPS_FUNC_NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return hwiOps->enableIrq(hwiNum);
|
||||||
|
}
|
||||||
|
|
||||||
|
UINT32 ArchIntDisable(HWI_HANDLE_T hwiNum)
|
||||||
|
{
|
||||||
|
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||||
|
return OS_ERRNO_HWI_NUM_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
HwiControllerOps *hwiOps = ArchIntOpsGet();
|
||||||
|
if (hwiOps->disableIrq == NULL) {
|
||||||
|
return OS_ERRNO_HWI_OPS_FUNC_NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return hwiOps->disableIrq(hwiNum);
|
||||||
|
}
|
||||||
|
|
||||||
|
UINT32 ArchIntClear(HWI_HANDLE_T hwiNum)
|
||||||
|
{
|
||||||
|
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||||
|
return OS_ERRNO_HWI_NUM_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
HwiControllerOps *hwiOps = ArchIntOpsGet();
|
||||||
|
if (hwiOps->clearIrq == NULL) {
|
||||||
|
return OS_ERRNO_HWI_OPS_FUNC_NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return hwiOps->clearIrq(hwiNum);
|
||||||
|
}
|
||||||
|
|
||||||
|
UINT32 ArchIntSetPriority(HWI_HANDLE_T hwiNum, HWI_PRIOR_T 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
HwiControllerOps *hwiOps = ArchIntOpsGet();
|
||||||
|
if (hwiOps->setIrqPriority == NULL) {
|
||||||
|
return OS_ERRNO_HWI_OPS_FUNC_NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return hwiOps->setIrqPriority(hwiNum, priority);
|
||||||
|
}
|
||||||
|
|
||||||
|
UINT32 ArchIntCurIrqNum(VOID)
|
||||||
|
{
|
||||||
|
HwiControllerOps *hwiOps = ArchIntOpsGet();
|
||||||
|
return hwiOps->getCurIrqNum();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ****************************************************************************
|
||||||
|
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
|
||||||
|
|
||||||
|
HwiControllerOps *hwiOps = ArchIntOpsGet();
|
||||||
|
if (hwiOps->createIrq == NULL) {
|
||||||
|
LOS_IntRestore(intSave);
|
||||||
|
return OS_ERRNO_HWI_OPS_FUNC_NULL;
|
||||||
|
}
|
||||||
|
hwiOps->createIrq(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;
|
||||||
|
}
|
||||||
|
|
||||||
|
ArchIntDisable((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
|
intSave = LOS_IntLock();
|
||||||
|
|
||||||
|
g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
|
||||||
|
|
||||||
|
LOS_IntRestore(intSave);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
INLINE UINT32 ArchIsIntActive(VOID)
|
||||||
|
{
|
||||||
|
return (g_intCount > 0);
|
||||||
|
}
|
||||||
@@ -0,0 +1,118 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2023-2023 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_COMMON_INTERRUPT_H
|
||||||
|
#define _LOS_COMMON_INTERRUPT_H
|
||||||
|
|
||||||
|
#include "los_config.h"
|
||||||
|
#include "los_compiler.h"
|
||||||
|
#include "los_interrupt.h"
|
||||||
|
#include "los_error.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#if __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @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
|
||||||
|
* Maximum number of used hardware interrupts.
|
||||||
|
*/
|
||||||
|
#ifndef OS_HWI_MAX_NUM
|
||||||
|
#define OS_HWI_MAX_NUM LOSCFG_PLATFORM_HWI_LIMIT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#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);
|
||||||
|
extern HWI_HANDLER_FUNC g_hwiHandlerForm[];
|
||||||
|
#else
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Set interrupt vector table.
|
||||||
|
*/
|
||||||
|
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
|
||||||
|
extern HWI_PROC_FUNC g_hwiHandlerForm[];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define OS_EXC_IN_INIT 0
|
||||||
|
#define OS_EXC_IN_TASK 1
|
||||||
|
#define OS_EXC_IN_HWI 2
|
||||||
|
#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_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);
|
||||||
|
|
||||||
|
VOID HalPreInterruptHandler(UINT32 arg);
|
||||||
|
VOID HalAftInterruptHandler(UINT32 arg);
|
||||||
|
VOID *ArchGetHwiFrom(VOID);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#if __cplusplus
|
||||||
|
}
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
#endif /* _LOS_COMMON_INTERRUPT_H */
|
||||||
@@ -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-2023 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:
|
||||||
@@ -42,14 +42,6 @@ extern "C" {
|
|||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
#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
|
* @ingroup los_arch_interrupt
|
||||||
* Highest priority of a hardware interrupt.
|
* Highest priority of a hardware interrupt.
|
||||||
@@ -66,19 +58,6 @@ extern "C" {
|
|||||||
#define OS_HWI_PRIO_LOWEST 7
|
#define OS_HWI_PRIO_LOWEST 7
|
||||||
#endif
|
#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
|
* @ingroup los_arch_interrupt
|
||||||
* Count of M-Core system interrupt vector.
|
* Count of M-Core system interrupt vector.
|
||||||
@@ -186,6 +165,16 @@ extern UINT32 _BootVectors[];
|
|||||||
*/
|
*/
|
||||||
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
|
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Hardware interrupt error code: Invalid interrupt operation function.
|
||||||
|
*
|
||||||
|
* Value: 0x0200090c
|
||||||
|
*
|
||||||
|
* Solution: Set a valid interrupt operation function
|
||||||
|
*/
|
||||||
|
#define OS_ERRNO_HWI_OPS_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x0c)
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_arch_interrupt
|
* @ingroup los_arch_interrupt
|
||||||
* SysTick control and status register.
|
* SysTick control and status register.
|
||||||
@@ -312,20 +301,6 @@ extern UINT32 _BootVectors[];
|
|||||||
*/
|
*/
|
||||||
#define OS_EXC_SYS_TICK 15
|
#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
|
* @ingroup los_arch_interrupt
|
||||||
* @brief: Hardware interrupt entry function.
|
* @brief: Hardware interrupt entry function.
|
||||||
@@ -345,25 +320,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
|
|||||||
*/
|
*/
|
||||||
extern VOID HalInterrupt(VOID);
|
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
|
* @ingroup los_arch_interrupt
|
||||||
* @brief: Reset the vector table.
|
* @brief: Reset the vector table.
|
||||||
@@ -403,17 +359,12 @@ extern VOID Reset_Handler(VOID);
|
|||||||
*/
|
*/
|
||||||
extern VOID HalPendSV(VOID);
|
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_BUF_LEN 25
|
||||||
#define OS_EXC_MAX_NEST_DEPTH 1
|
#define OS_EXC_MAX_NEST_DEPTH 1
|
||||||
|
#define OS_EXC_FLAG_NO_FLOAT 0x10000000
|
||||||
|
|
||||||
#define OS_NVIC_SHCSR 0xE000ED24
|
#define OS_NVIC_SHCSR 0xE000ED24
|
||||||
#define OS_NVIC_CCR 0xE000ED14
|
#define OS_NVIC_CCR 0xE000ED14
|
||||||
|
|
||||||
#define OS_NVIC_INT_ENABLE_SIZE 0x20
|
#define OS_NVIC_INT_ENABLE_SIZE 0x20
|
||||||
#define OS_NVIC_INT_PRI_SIZE 0xF0
|
#define OS_NVIC_INT_PRI_SIZE 0xF0
|
||||||
#define OS_NVIC_EXCPRI_SIZE 0xC
|
#define OS_NVIC_EXCPRI_SIZE 0xC
|
||||||
@@ -423,14 +374,6 @@ extern VOID HalPendSV(VOID);
|
|||||||
#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
|
#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
|
||||||
#define OS_NVIC_INT_ACT_SIZE OS_NVIC_INT_ENABLE_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
|
* @ingroup los_exc
|
||||||
* the struct of register files
|
* the struct of register files
|
||||||
@@ -503,7 +446,6 @@ typedef struct TagExcContext {
|
|||||||
|
|
||||||
typedef VOID (*EXC_PROC_FUNC)(UINT32, 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 HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr);
|
||||||
|
|
||||||
VOID HalExcNMI(VOID);
|
VOID HalExcNMI(VOID);
|
||||||
VOID HalExcHardFault(VOID);
|
VOID HalExcHardFault(VOID);
|
||||||
VOID HalExcMemFault(VOID);
|
VOID HalExcMemFault(VOID);
|
||||||
@@ -668,7 +610,6 @@ typedef struct TagExcInfo {
|
|||||||
} ExcInfo;
|
} ExcInfo;
|
||||||
|
|
||||||
extern UINT32 g_curNestCount;
|
extern UINT32 g_curNestCount;
|
||||||
extern UINT32 g_intCount;
|
|
||||||
extern UINT8 g_uwExcTbl[32];
|
extern UINT8 g_uwExcTbl[32];
|
||||||
extern ExcInfo g_excInfo;
|
extern ExcInfo g_excInfo;
|
||||||
|
|
||||||
|
|||||||
@@ -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-2023 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:
|
||||||
@@ -28,12 +28,10 @@
|
|||||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
#include "los_interrupt.h"
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include "securec.h"
|
#include "securec.h"
|
||||||
#include "los_context.h"
|
#include "los_context.h"
|
||||||
#include "los_arch_interrupt.h"
|
#include "los_arch_interrupt.h"
|
||||||
#include "los_debug.h"
|
|
||||||
#include "los_hook.h"
|
#include "los_hook.h"
|
||||||
#include "los_task.h"
|
#include "los_task.h"
|
||||||
#include "los_sched.h"
|
#include "los_sched.h"
|
||||||
@@ -43,95 +41,6 @@
|
|||||||
#include "los_cpup.h"
|
#include "los_cpup.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
UINT32 g_intCount = 0;
|
|
||||||
|
|
||||||
#ifdef __ICCARM__
|
|
||||||
#pragma location = ".data.vector"
|
|
||||||
#elif defined(__CC_ARM) || defined(__GNUC__)
|
|
||||||
#pragma data_alignment = LOSCFG_ARCH_HWI_VECTOR_ALIGN
|
|
||||||
LITE_OS_SEC_VEC
|
|
||||||
#endif
|
|
||||||
/* *
|
|
||||||
* @ingroup los_hwi
|
|
||||||
* Hardware interrupt form mapping handling function array.
|
|
||||||
*/
|
|
||||||
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)
|
|
||||||
|
|
||||||
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
|
Function : HwiNumGet
|
||||||
Description : Get an interrupt number
|
Description : Get an interrupt number
|
||||||
@@ -146,99 +55,54 @@ STATIC UINT32 HwiNumGet(VOID)
|
|||||||
|
|
||||||
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
|
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
|
||||||
{
|
{
|
||||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
|
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
|
||||||
{
|
{
|
||||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
NVIC_DisableIRQ((IRQn_Type)hwiNum);
|
NVIC_DisableIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority)
|
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);
|
NVIC_SetPriority((IRQn_Type)hwiNum, priority);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
|
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
|
||||||
{
|
{
|
||||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
|
NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
|
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
|
||||||
{
|
{
|
||||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
|
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
HwiControllerOps g_archHwiOps = {
|
STATIC UINT32 HwiCreate(HWI_HANDLE_T hwiNum, HWI_PRIOR_T hwiPrio)
|
||||||
|
{
|
||||||
|
HwiSetPriority(hwiNum, hwiPrio);
|
||||||
|
HwiUnmask(hwiNum);
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC HwiControllerOps g_archHwiOps = {
|
||||||
.enableIrq = HwiUnmask,
|
.enableIrq = HwiUnmask,
|
||||||
.disableIrq = HwiMask,
|
.disableIrq = HwiMask,
|
||||||
.setIrqPriority = HwiSetPriority,
|
.setIrqPriority = HwiSetPriority,
|
||||||
.getCurIrqNum = HwiNumGet,
|
.getCurIrqNum = HwiNumGet,
|
||||||
.triggerIrq = HwiPending,
|
.triggerIrq = HwiPending,
|
||||||
.clearIrq = HwiClear,
|
.clearIrq = HwiClear,
|
||||||
|
.createIrq = HwiCreate,
|
||||||
};
|
};
|
||||||
|
|
||||||
inline UINT32 ArchIsIntActive(VOID)
|
HwiControllerOps *ArchIntOpsGet(VOID)
|
||||||
{
|
{
|
||||||
return (g_intCount > 0);
|
return &g_archHwiOps;
|
||||||
}
|
|
||||||
/* ****************************************************************************
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ****************************************************************************
|
/* ****************************************************************************
|
||||||
@@ -297,97 +161,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
|
|||||||
LOS_IntRestore(intSave);
|
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 FAULT_STATUS_REG_BIT 32
|
||||||
#define USGFAULT (1 << 18)
|
#define USGFAULT (1 << 18)
|
||||||
#define BUSFAULT (1 << 17)
|
#define BUSFAULT (1 << 17)
|
||||||
@@ -610,6 +383,11 @@ LITE_OS_SEC_TEXT_INIT VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, U
|
|||||||
ArchSysExit();
|
ArchSysExit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WEAK VOID SysTick_Handler(VOID)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* ****************************************************************************
|
/* ****************************************************************************
|
||||||
Function : HalHwiInit
|
Function : HalHwiInit
|
||||||
Description : initialization of the hardware interrupt
|
Description : initialization of the hardware interrupt
|
||||||
@@ -621,23 +399,24 @@ 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 */
|
HWI_PROC_FUNC *hwiForm = (HWI_PROC_FUNC *)ArchGetHwiFrom();
|
||||||
g_hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */
|
hwiForm[0] = 0; /* [0] Top of Stack */
|
||||||
|
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;
|
hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
|
||||||
}
|
}
|
||||||
/* Exception handler register */
|
/* Exception handler register */
|
||||||
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
|
hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
|
||||||
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
|
hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
|
||||||
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
|
hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
|
||||||
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
|
hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
|
||||||
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
|
hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
|
||||||
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcSvcCall;
|
hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcSvcCall;
|
||||||
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
|
hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
|
||||||
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
|
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)hwiForm;
|
||||||
#endif
|
#endif
|
||||||
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
|
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
|
||||||
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
|
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
|
||||||
@@ -655,4 +434,3 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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-2023 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:
|
||||||
@@ -32,9 +32,7 @@
|
|||||||
#ifndef _LOS_ARCH_INTERRUPT_H
|
#ifndef _LOS_ARCH_INTERRUPT_H
|
||||||
#define _LOS_ARCH_INTERRUPT_H
|
#define _LOS_ARCH_INTERRUPT_H
|
||||||
|
|
||||||
#include "los_config.h"
|
#include "los_common_interrupt.h"
|
||||||
#include "los_compiler.h"
|
|
||||||
#include "los_interrupt.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
@@ -42,14 +40,6 @@ extern "C" {
|
|||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
#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
|
* @ingroup los_arch_interrupt
|
||||||
* Highest priority of a hardware interrupt.
|
* Highest priority of a hardware interrupt.
|
||||||
@@ -66,18 +56,17 @@ extern "C" {
|
|||||||
#define OS_HWI_PRIO_LOWEST 7
|
#define OS_HWI_PRIO_LOWEST 7
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_arch_interrupt
|
* @ingroup los_arch_interrupt
|
||||||
* Define the type of a hardware interrupt vector table function.
|
* AIRCR register priority group parameter .
|
||||||
*/
|
*/
|
||||||
typedef VOID (**HWI_VECTOR_FUNC)(void);
|
#define OS_NVIC_AIRCR_PRIGROUP 7
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_arch_interrupt
|
* @ingroup los_arch_interrupt
|
||||||
* Count of interrupts.
|
* Boot interrupt vector table.
|
||||||
*/
|
*/
|
||||||
extern UINT32 g_intCount;
|
extern UINT32 _BootVectors[];
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_arch_interrupt
|
* @ingroup los_arch_interrupt
|
||||||
@@ -91,18 +80,6 @@ extern UINT32 g_intCount;
|
|||||||
*/
|
*/
|
||||||
#define OS_VECTOR_CNT (OS_SYS_VECTOR_CNT + OS_HWI_MAX_NUM)
|
#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
|
* @ingroup los_arch_interrupt
|
||||||
* Hardware interrupt error code: Invalid interrupt number.
|
* Hardware interrupt error code: Invalid interrupt number.
|
||||||
@@ -110,7 +87,7 @@ extern UINT32 _BootVectors[];
|
|||||||
* Value: 0x02000900
|
* Value: 0x02000900
|
||||||
*
|
*
|
||||||
* Solution: Ensure that the interrupt number is valid.
|
* 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].
|
* 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)
|
||||||
|
|
||||||
@@ -186,6 +163,16 @@ extern UINT32 _BootVectors[];
|
|||||||
*/
|
*/
|
||||||
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
|
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Hardware interrupt error code: Invalid interrupt operation function.
|
||||||
|
*
|
||||||
|
* Value: 0x0200090c
|
||||||
|
*
|
||||||
|
* Solution: Set a valid interrupt operation function
|
||||||
|
*/
|
||||||
|
#define OS_ERRNO_HWI_OPS_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x0c)
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_arch_interrupt
|
* @ingroup los_arch_interrupt
|
||||||
* SysTick control and status register.
|
* SysTick control and status register.
|
||||||
@@ -312,20 +299,6 @@ extern UINT32 _BootVectors[];
|
|||||||
*/
|
*/
|
||||||
#define OS_EXC_SYS_TICK 15
|
#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
|
* @ingroup los_arch_interrupt
|
||||||
* @brief: Hardware interrupt entry function.
|
* @brief: Hardware interrupt entry function.
|
||||||
@@ -345,25 +318,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
|
|||||||
*/
|
*/
|
||||||
extern VOID HalInterrupt(VOID);
|
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
|
* @ingroup los_arch_interrupt
|
||||||
* @brief: Reset the vector table.
|
* @brief: Reset the vector table.
|
||||||
@@ -403,34 +357,20 @@ extern VOID Reset_Handler(VOID);
|
|||||||
*/
|
*/
|
||||||
extern VOID HalPendSV(VOID);
|
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_BUF_LEN 25
|
||||||
#define OS_EXC_MAX_NEST_DEPTH 1
|
#define OS_EXC_MAX_NEST_DEPTH 1
|
||||||
|
#define OS_EXC_FLAG_NO_FLOAT 0x10000000
|
||||||
|
|
||||||
#define OS_NVIC_SHCSR 0xE000ED24
|
#define OS_NVIC_SHCSR 0xE000ED24
|
||||||
#define OS_NVIC_CCR 0xE000ED14
|
#define OS_NVIC_CCR 0xE000ED14
|
||||||
|
|
||||||
#define OS_NVIC_INT_ENABLE_SIZE 0x20
|
#define OS_NVIC_INT_ENABLE_SIZE 0x20
|
||||||
#define OS_NVIC_INT_PRI_SIZE 0xF0
|
#define OS_NVIC_INT_PRI_SIZE 0xF0
|
||||||
#define OS_NVIC_EXCPRI_SIZE 0xC
|
#define OS_NVIC_EXCPRI_SIZE 0xC
|
||||||
#define OS_NVIC_INT_CTRL_SIZE 4
|
#define OS_NVIC_INT_CTRL_SIZE 4
|
||||||
#define OS_NVIC_SHCSR_SIZE 4
|
#define OS_NVIC_SHCSR_SIZE 4
|
||||||
|
|
||||||
#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
|
#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
|
||||||
#define OS_NVIC_INT_ACT_SIZE OS_NVIC_INT_ENABLE_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
|
* @ingroup los_exc
|
||||||
* the struct of register files
|
* the struct of register files
|
||||||
@@ -503,7 +443,6 @@ typedef struct TagExcContext {
|
|||||||
|
|
||||||
typedef VOID (*EXC_PROC_FUNC)(UINT32, 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 HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr);
|
||||||
|
|
||||||
VOID HalExcNMI(VOID);
|
VOID HalExcNMI(VOID);
|
||||||
VOID HalExcHardFault(VOID);
|
VOID HalExcHardFault(VOID);
|
||||||
VOID HalExcMemFault(VOID);
|
VOID HalExcMemFault(VOID);
|
||||||
@@ -667,10 +606,9 @@ typedef struct TagExcInfo {
|
|||||||
EXC_CONTEXT_S *context;
|
EXC_CONTEXT_S *context;
|
||||||
} ExcInfo;
|
} ExcInfo;
|
||||||
|
|
||||||
extern UINT32 g_curNestCount;
|
|
||||||
extern UINT32 g_intCount;
|
|
||||||
extern UINT8 g_uwExcTbl[32];
|
|
||||||
extern ExcInfo g_excInfo;
|
extern ExcInfo g_excInfo;
|
||||||
|
extern UINT32 g_curNestCount;
|
||||||
|
extern UINT8 g_uwExcTbl[32];
|
||||||
|
|
||||||
#define MAX_INT_INFO_SIZE (8 + 0x164)
|
#define MAX_INT_INFO_SIZE (8 + 0x164)
|
||||||
|
|
||||||
|
|||||||
@@ -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-2023 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:
|
||||||
@@ -28,12 +28,10 @@
|
|||||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
#include "los_interrupt.h"
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include "securec.h"
|
#include "securec.h"
|
||||||
#include "los_context.h"
|
#include "los_context.h"
|
||||||
#include "los_arch_interrupt.h"
|
#include "los_arch_interrupt.h"
|
||||||
#include "los_debug.h"
|
|
||||||
#include "los_hook.h"
|
#include "los_hook.h"
|
||||||
#include "los_task.h"
|
#include "los_task.h"
|
||||||
#include "los_sched.h"
|
#include "los_sched.h"
|
||||||
@@ -44,84 +42,6 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define DEF_HANDLER_START_INDEX 2
|
#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
|
|
||||||
|
|
||||||
/* ****************************************************************************
|
/* ****************************************************************************
|
||||||
Function : HwiNumGet
|
Function : HwiNumGet
|
||||||
@@ -137,99 +57,54 @@ STATIC UINT32 HwiNumGet(VOID)
|
|||||||
|
|
||||||
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
|
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
|
||||||
{
|
{
|
||||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
|
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
|
||||||
{
|
{
|
||||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
NVIC_DisableIRQ((IRQn_Type)hwiNum);
|
NVIC_DisableIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority)
|
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);
|
NVIC_SetPriority((IRQn_Type)hwiNum, priority);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
|
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
|
||||||
{
|
{
|
||||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
|
NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
|
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
|
||||||
{
|
{
|
||||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
|
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
HwiControllerOps g_archHwiOps = {
|
STATIC UINT32 HwiCreate(HWI_HANDLE_T hwiNum, HWI_PRIOR_T hwiPrio)
|
||||||
|
{
|
||||||
|
HwiSetPriority(hwiNum, hwiPrio);
|
||||||
|
HwiUnmask(hwiNum);
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC HwiControllerOps g_archHwiOps = {
|
||||||
.enableIrq = HwiUnmask,
|
.enableIrq = HwiUnmask,
|
||||||
.disableIrq = HwiMask,
|
.disableIrq = HwiMask,
|
||||||
.setIrqPriority = HwiSetPriority,
|
.setIrqPriority = HwiSetPriority,
|
||||||
.getCurIrqNum = HwiNumGet,
|
.getCurIrqNum = HwiNumGet,
|
||||||
.triggerIrq = HwiPending,
|
.triggerIrq = HwiPending,
|
||||||
.clearIrq = HwiClear,
|
.clearIrq = HwiClear,
|
||||||
|
.createIrq = HwiCreate,
|
||||||
};
|
};
|
||||||
|
|
||||||
inline UINT32 ArchIsIntActive(VOID)
|
HwiControllerOps *ArchIntOpsGet(VOID)
|
||||||
{
|
{
|
||||||
return (g_intCount > 0);
|
return &g_archHwiOps;
|
||||||
}
|
|
||||||
/* ****************************************************************************
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ****************************************************************************
|
/* ****************************************************************************
|
||||||
@@ -288,97 +163,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
|
|||||||
LOS_IntRestore(intSave);
|
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 FAULT_STATUS_REG_BIT 32
|
||||||
#define USGFAULT (1 << 18)
|
#define USGFAULT (1 << 18)
|
||||||
#define BUSFAULT (1 << 17)
|
#define BUSFAULT (1 << 17)
|
||||||
@@ -612,23 +396,24 @@ 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 */
|
HWI_PROC_FUNC *hwiForm = (HWI_PROC_FUNC *)ArchGetHwiFrom();
|
||||||
g_hwiForm[1] = 0; /* [1] reset */
|
hwiForm[0] = 0; /* [0] Top of Stack */
|
||||||
|
hwiForm[1] = 0; /* [1] reset */
|
||||||
for (index = DEF_HANDLER_START_INDEX; index < OS_VECTOR_CNT; index++) {
|
for (index = DEF_HANDLER_START_INDEX; index < OS_VECTOR_CNT; index++) {
|
||||||
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
|
hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
|
||||||
}
|
}
|
||||||
/* Exception handler register */
|
/* Exception handler register */
|
||||||
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
|
hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
|
||||||
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
|
hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
|
||||||
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
|
hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
|
||||||
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
|
hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
|
||||||
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
|
hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
|
||||||
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
|
hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
|
||||||
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
|
hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
|
||||||
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)OsTickHandler;
|
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)hwiForm;
|
||||||
#endif
|
#endif
|
||||||
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
|
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
|
||||||
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
|
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
|
||||||
@@ -646,4 +431,3 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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-2023 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:
|
||||||
@@ -32,9 +32,7 @@
|
|||||||
#ifndef _LOS_ARCH_INTERRUPT_H
|
#ifndef _LOS_ARCH_INTERRUPT_H
|
||||||
#define _LOS_ARCH_INTERRUPT_H
|
#define _LOS_ARCH_INTERRUPT_H
|
||||||
|
|
||||||
#include "los_config.h"
|
#include "los_common_interrupt.h"
|
||||||
#include "los_compiler.h"
|
|
||||||
#include "los_interrupt.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
@@ -42,14 +40,6 @@ extern "C" {
|
|||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
#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
|
* @ingroup los_arch_interrupt
|
||||||
* Highest priority of a hardware interrupt.
|
* Highest priority of a hardware interrupt.
|
||||||
@@ -66,18 +56,17 @@ extern "C" {
|
|||||||
#define OS_HWI_PRIO_LOWEST 7
|
#define OS_HWI_PRIO_LOWEST 7
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_arch_interrupt
|
* @ingroup los_arch_interrupt
|
||||||
* Define the type of a hardware interrupt vector table function.
|
* AIRCR register priority group parameter .
|
||||||
*/
|
*/
|
||||||
typedef VOID (**HWI_VECTOR_FUNC)(void);
|
#define OS_NVIC_AIRCR_PRIGROUP 7
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_arch_interrupt
|
* @ingroup los_arch_interrupt
|
||||||
* Count of interrupts.
|
* Boot interrupt vector table.
|
||||||
*/
|
*/
|
||||||
extern UINT32 g_intCount;
|
extern UINT32 _BootVectors[];
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_arch_interrupt
|
* @ingroup los_arch_interrupt
|
||||||
@@ -91,18 +80,6 @@ extern UINT32 g_intCount;
|
|||||||
*/
|
*/
|
||||||
#define OS_VECTOR_CNT (OS_SYS_VECTOR_CNT + OS_HWI_MAX_NUM)
|
#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
|
* @ingroup los_arch_interrupt
|
||||||
* Hardware interrupt error code: Invalid interrupt number.
|
* Hardware interrupt error code: Invalid interrupt number.
|
||||||
@@ -110,7 +87,7 @@ extern UINT32 _BootVectors[];
|
|||||||
* Value: 0x02000900
|
* Value: 0x02000900
|
||||||
*
|
*
|
||||||
* Solution: Ensure that the interrupt number is valid.
|
* 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].
|
* 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)
|
||||||
|
|
||||||
@@ -186,6 +163,16 @@ extern UINT32 _BootVectors[];
|
|||||||
*/
|
*/
|
||||||
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
|
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Hardware interrupt error code: Invalid interrupt operation function.
|
||||||
|
*
|
||||||
|
* Value: 0x0200090c
|
||||||
|
*
|
||||||
|
* Solution: Set a valid interrupt operation function
|
||||||
|
*/
|
||||||
|
#define OS_ERRNO_HWI_OPS_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x0c)
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_arch_interrupt
|
* @ingroup los_arch_interrupt
|
||||||
* SysTick control and status register.
|
* SysTick control and status register.
|
||||||
@@ -312,20 +299,6 @@ extern UINT32 _BootVectors[];
|
|||||||
*/
|
*/
|
||||||
#define OS_EXC_SYS_TICK 15
|
#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
|
* @ingroup los_arch_interrupt
|
||||||
* @brief: Hardware interrupt entry function.
|
* @brief: Hardware interrupt entry function.
|
||||||
@@ -345,25 +318,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
|
|||||||
*/
|
*/
|
||||||
extern VOID HalInterrupt(VOID);
|
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
|
* @ingroup los_arch_interrupt
|
||||||
* @brief: Reset the vector table.
|
* @brief: Reset the vector table.
|
||||||
@@ -403,34 +357,20 @@ extern VOID Reset_Handler(VOID);
|
|||||||
*/
|
*/
|
||||||
extern VOID HalPendSV(VOID);
|
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_BUF_LEN 25
|
||||||
#define OS_EXC_MAX_NEST_DEPTH 1
|
#define OS_EXC_MAX_NEST_DEPTH 1
|
||||||
|
#define OS_EXC_FLAG_NO_FLOAT 0x10000000
|
||||||
|
|
||||||
#define OS_NVIC_SHCSR 0xE000ED24
|
#define OS_NVIC_SHCSR 0xE000ED24
|
||||||
#define OS_NVIC_CCR 0xE000ED14
|
#define OS_NVIC_CCR 0xE000ED14
|
||||||
|
|
||||||
#define OS_NVIC_INT_ENABLE_SIZE 0x20
|
#define OS_NVIC_INT_ENABLE_SIZE 0x20
|
||||||
#define OS_NVIC_INT_PRI_SIZE 0xF0
|
#define OS_NVIC_INT_PRI_SIZE 0xF0
|
||||||
#define OS_NVIC_EXCPRI_SIZE 0xC
|
#define OS_NVIC_EXCPRI_SIZE 0xC
|
||||||
#define OS_NVIC_INT_CTRL_SIZE 4
|
#define OS_NVIC_INT_CTRL_SIZE 4
|
||||||
#define OS_NVIC_SHCSR_SIZE 4
|
#define OS_NVIC_SHCSR_SIZE 4
|
||||||
|
|
||||||
#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
|
#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
|
||||||
#define OS_NVIC_INT_ACT_SIZE OS_NVIC_INT_ENABLE_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
|
* @ingroup los_exc
|
||||||
* the struct of register files
|
* the struct of register files
|
||||||
@@ -503,7 +443,6 @@ typedef struct TagExcContext {
|
|||||||
|
|
||||||
typedef VOID (*EXC_PROC_FUNC)(UINT32, 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 HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr);
|
||||||
|
|
||||||
VOID HalExcNMI(VOID);
|
VOID HalExcNMI(VOID);
|
||||||
VOID HalExcHardFault(VOID);
|
VOID HalExcHardFault(VOID);
|
||||||
VOID HalExcMemFault(VOID);
|
VOID HalExcMemFault(VOID);
|
||||||
@@ -667,10 +606,9 @@ typedef struct TagExcInfo {
|
|||||||
EXC_CONTEXT_S *context;
|
EXC_CONTEXT_S *context;
|
||||||
} ExcInfo;
|
} ExcInfo;
|
||||||
|
|
||||||
extern UINT32 g_curNestCount;
|
|
||||||
extern UINT32 g_intCount;
|
|
||||||
extern UINT8 g_uwExcTbl[32];
|
|
||||||
extern ExcInfo g_excInfo;
|
extern ExcInfo g_excInfo;
|
||||||
|
extern UINT32 g_curNestCount;
|
||||||
|
extern UINT8 g_uwExcTbl[32];
|
||||||
|
|
||||||
#define MAX_INT_INFO_SIZE (8 + 0x164)
|
#define MAX_INT_INFO_SIZE (8 + 0x164)
|
||||||
|
|
||||||
|
|||||||
@@ -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-2023 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:
|
||||||
@@ -28,12 +28,10 @@
|
|||||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
#include "los_interrupt.h"
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include "securec.h"
|
#include "securec.h"
|
||||||
#include "los_context.h"
|
#include "los_context.h"
|
||||||
#include "los_arch_interrupt.h"
|
#include "los_arch_interrupt.h"
|
||||||
#include "los_debug.h"
|
|
||||||
#include "los_hook.h"
|
#include "los_hook.h"
|
||||||
#include "los_task.h"
|
#include "los_task.h"
|
||||||
#include "los_sched.h"
|
#include "los_sched.h"
|
||||||
@@ -44,83 +42,6 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define DEF_HANDLER_START_INDEX 2
|
#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
|
|
||||||
|
|
||||||
/* ****************************************************************************
|
/* ****************************************************************************
|
||||||
Function : HwiNumGet
|
Function : HwiNumGet
|
||||||
@@ -136,100 +57,54 @@ STATIC UINT32 HwiNumGet(VOID)
|
|||||||
|
|
||||||
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
|
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
|
||||||
{
|
{
|
||||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
|
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
|
||||||
{
|
{
|
||||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
NVIC_DisableIRQ((IRQn_Type)hwiNum);
|
NVIC_DisableIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority)
|
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);
|
NVIC_SetPriority((IRQn_Type)hwiNum, priority);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
|
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
|
||||||
{
|
{
|
||||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
|
NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
|
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
|
||||||
{
|
{
|
||||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
|
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
HwiControllerOps g_archHwiOps = {
|
STATIC UINT32 HwiCreate(HWI_HANDLE_T hwiNum, HWI_PRIOR_T hwiPrio)
|
||||||
|
{
|
||||||
|
HwiSetPriority(hwiNum, hwiPrio);
|
||||||
|
HwiUnmask(hwiNum);
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC HwiControllerOps g_archHwiOps = {
|
||||||
.enableIrq = HwiUnmask,
|
.enableIrq = HwiUnmask,
|
||||||
.disableIrq = HwiMask,
|
.disableIrq = HwiMask,
|
||||||
.setIrqPriority = HwiSetPriority,
|
.setIrqPriority = HwiSetPriority,
|
||||||
.getCurIrqNum = HwiNumGet,
|
.getCurIrqNum = HwiNumGet,
|
||||||
.triggerIrq = HwiPending,
|
.triggerIrq = HwiPending,
|
||||||
.clearIrq = HwiClear,
|
.clearIrq = HwiClear,
|
||||||
|
.createIrq = HwiCreate,
|
||||||
};
|
};
|
||||||
|
|
||||||
inline UINT32 ArchIsIntActive(VOID)
|
HwiControllerOps *ArchIntOpsGet(VOID)
|
||||||
{
|
{
|
||||||
return (g_intCount > 0);
|
return &g_archHwiOps;
|
||||||
}
|
|
||||||
/* ****************************************************************************
|
|
||||||
Function : HalHwiDefaultHandler
|
|
||||||
Description : default handler of the hardware interrupt
|
|
||||||
Input : None
|
|
||||||
Output : None
|
|
||||||
Return : None
|
|
||||||
**************************************************************************** */
|
|
||||||
/*lint -e529*/
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ****************************************************************************
|
/* ****************************************************************************
|
||||||
@@ -288,97 +163,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
|
|||||||
LOS_IntRestore(intSave);
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
NVIC_DisableIRQ((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 FAULT_STATUS_REG_BIT 32
|
||||||
#define USGFAULT (1 << 18)
|
#define USGFAULT (1 << 18)
|
||||||
#define BUSFAULT (1 << 17)
|
#define BUSFAULT (1 << 17)
|
||||||
@@ -612,23 +396,24 @@ 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 */
|
HWI_PROC_FUNC *hwiForm = (HWI_PROC_FUNC *)ArchGetHwiFrom();
|
||||||
g_hwiForm[1] = 0; /* [1] reset */
|
hwiForm[0] = 0; /* [0] Top of Stack */
|
||||||
|
hwiForm[1] = 0; /* [1] reset */
|
||||||
for (index = DEF_HANDLER_START_INDEX; index < OS_VECTOR_CNT; index++) {
|
for (index = DEF_HANDLER_START_INDEX; index < OS_VECTOR_CNT; index++) {
|
||||||
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
|
hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
|
||||||
}
|
}
|
||||||
/* Exception handler register */
|
/* Exception handler register */
|
||||||
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
|
hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
|
||||||
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
|
hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
|
||||||
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
|
hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
|
||||||
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
|
hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
|
||||||
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
|
hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
|
||||||
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
|
hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
|
||||||
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
|
hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
|
||||||
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)OsTickHandler;
|
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)hwiForm;
|
||||||
#endif
|
#endif
|
||||||
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
|
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
|
||||||
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
|
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
|
||||||
@@ -646,4 +431,3 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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-2023 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:
|
||||||
@@ -29,12 +29,10 @@
|
|||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _LOS_EXC_H
|
#ifndef _LOS_ARCH_INTERRUPT_H
|
||||||
#define _LOS_EXC_H
|
#define _LOS_ARCH_INTERRUPT_H
|
||||||
|
|
||||||
#include "los_config.h"
|
#include "los_common_interrupt.h"
|
||||||
#include "los_compiler.h"
|
|
||||||
#include "los_interrupt.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
@@ -43,15 +41,7 @@ extern "C" {
|
|||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @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_hwi
|
|
||||||
* Highest priority of a hardware interrupt.
|
* Highest priority of a hardware interrupt.
|
||||||
*/
|
*/
|
||||||
#ifndef OS_HWI_PRIO_HIGHEST
|
#ifndef OS_HWI_PRIO_HIGHEST
|
||||||
@@ -59,63 +49,50 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Lowest priority of a hardware interrupt.
|
* Lowest priority of a hardware interrupt.
|
||||||
*/
|
*/
|
||||||
#ifndef OS_HWI_PRIO_LOWEST
|
#ifndef OS_HWI_PRIO_LOWEST
|
||||||
#define OS_HWI_PRIO_LOWEST 7
|
#define OS_HWI_PRIO_LOWEST 7
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Define the type of a hardware interrupt vector table function.
|
|
||||||
*/
|
|
||||||
typedef VOID (**HWI_VECTOR_FUNC)(void);
|
|
||||||
|
|
||||||
/* *
|
|
||||||
* @ingroup los_hwi
|
|
||||||
* Count of interrupts.
|
|
||||||
*/
|
|
||||||
extern UINT32 g_intCount;
|
|
||||||
|
|
||||||
/* *
|
|
||||||
* @ingroup los_hwi
|
|
||||||
* Count of M-Core system interrupt vector.
|
|
||||||
*/
|
|
||||||
#define OS_SYS_VECTOR_CNT 16
|
|
||||||
|
|
||||||
/* *
|
|
||||||
* @ingroup los_hwi
|
|
||||||
* Count of M-Core interrupt vector.
|
|
||||||
*/
|
|
||||||
#define OS_VECTOR_CNT (OS_SYS_VECTOR_CNT + OS_HWI_MAX_NUM)
|
|
||||||
|
|
||||||
/* *
|
|
||||||
* @ingroup los_hwi
|
|
||||||
* AIRCR register priority group parameter .
|
* AIRCR register priority group parameter .
|
||||||
*/
|
*/
|
||||||
#define OS_NVIC_AIRCR_PRIGROUP 7
|
#define OS_NVIC_AIRCR_PRIGROUP 7
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Boot interrupt vector table.
|
* Boot interrupt vector table.
|
||||||
*/
|
*/
|
||||||
extern UINT32 _BootVectors[];
|
extern UINT32 _BootVectors[];
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @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
|
||||||
* Hardware interrupt error code: Invalid interrupt number.
|
* Hardware interrupt error code: Invalid interrupt number.
|
||||||
*
|
*
|
||||||
* Value: 0x02000900
|
* Value: 0x02000900
|
||||||
*
|
*
|
||||||
* Solution: Ensure that the interrupt number is valid.
|
* 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].
|
* 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)
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Hardware interrupt error code: Null hardware interrupt handling function.
|
* Hardware interrupt error code: Null hardware interrupt handling function.
|
||||||
*
|
*
|
||||||
* Value: 0x02000901
|
* Value: 0x02000901
|
||||||
@@ -125,7 +102,7 @@ extern UINT32 _BootVectors[];
|
|||||||
#define OS_ERRNO_HWI_PROC_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x01)
|
#define OS_ERRNO_HWI_PROC_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x01)
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Hardware interrupt error code: Insufficient interrupt resources for hardware interrupt creation.
|
* Hardware interrupt error code: Insufficient interrupt resources for hardware interrupt creation.
|
||||||
*
|
*
|
||||||
* Value: 0x02000902
|
* Value: 0x02000902
|
||||||
@@ -135,7 +112,7 @@ extern UINT32 _BootVectors[];
|
|||||||
#define OS_ERRNO_HWI_CB_UNAVAILABLE LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x02)
|
#define OS_ERRNO_HWI_CB_UNAVAILABLE LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x02)
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Hardware interrupt error code: Insufficient memory for hardware interrupt initialization.
|
* Hardware interrupt error code: Insufficient memory for hardware interrupt initialization.
|
||||||
*
|
*
|
||||||
* Value: 0x02000903
|
* Value: 0x02000903
|
||||||
@@ -145,7 +122,7 @@ extern UINT32 _BootVectors[];
|
|||||||
#define OS_ERRNO_HWI_NO_MEMORY LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x03)
|
#define OS_ERRNO_HWI_NO_MEMORY LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x03)
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Hardware interrupt error code: The interrupt has already been created.
|
* Hardware interrupt error code: The interrupt has already been created.
|
||||||
*
|
*
|
||||||
* Value: 0x02000904
|
* Value: 0x02000904
|
||||||
@@ -155,7 +132,7 @@ extern UINT32 _BootVectors[];
|
|||||||
#define OS_ERRNO_HWI_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x04)
|
#define OS_ERRNO_HWI_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x04)
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Hardware interrupt error code: Invalid interrupt priority.
|
* Hardware interrupt error code: Invalid interrupt priority.
|
||||||
*
|
*
|
||||||
* Value: 0x02000905
|
* Value: 0x02000905
|
||||||
@@ -166,7 +143,7 @@ extern UINT32 _BootVectors[];
|
|||||||
#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)
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Hardware interrupt error code: Incorrect interrupt creation mode.
|
* Hardware interrupt error code: Incorrect interrupt creation mode.
|
||||||
*
|
*
|
||||||
* Value: 0x02000906
|
* Value: 0x02000906
|
||||||
@@ -177,7 +154,7 @@ extern UINT32 _BootVectors[];
|
|||||||
#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)
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Hardware interrupt error code: The interrupt has already been created as a fast interrupt.
|
* Hardware interrupt error code: The interrupt has already been created as a fast interrupt.
|
||||||
*
|
*
|
||||||
* Value: 0x02000907
|
* Value: 0x02000907
|
||||||
@@ -187,7 +164,17 @@ extern UINT32 _BootVectors[];
|
|||||||
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
|
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
|
* Hardware interrupt error code: Invalid interrupt operation function.
|
||||||
|
*
|
||||||
|
* Value: 0x0200090c
|
||||||
|
*
|
||||||
|
* Solution: Set a valid interrupt operation function
|
||||||
|
*/
|
||||||
|
#define OS_ERRNO_HWI_OPS_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x0c)
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
* SysTick control and status register.
|
* SysTick control and status register.
|
||||||
*/
|
*/
|
||||||
#define OS_SYSTICK_CONTROL_REG 0xE000E010
|
#define OS_SYSTICK_CONTROL_REG 0xE000E010
|
||||||
@@ -199,133 +186,119 @@ extern UINT32 _BootVectors[];
|
|||||||
#define OS_SYSTICK_CURRENT_REG 0xE000E018
|
#define OS_SYSTICK_CURRENT_REG 0xE000E018
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Interrupt Priority-Level Registers.
|
* Interrupt Priority-Level Registers.
|
||||||
*/
|
*/
|
||||||
#define OS_NVIC_PRI_BASE 0xE000E400
|
#define OS_NVIC_PRI_BASE 0xE000E400
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Interrupt enable register for 0-31.
|
* Interrupt enable register for 0-31.
|
||||||
*/
|
*/
|
||||||
#define OS_NVIC_SETENA_BASE 0xE000E100
|
#define OS_NVIC_SETENA_BASE 0xE000E100
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* interrupt pending register.
|
* interrupt pending register.
|
||||||
*/
|
*/
|
||||||
#define OS_NVIC_SETPEND_BASE 0xE000E200
|
#define OS_NVIC_SETPEND_BASE 0xE000E200
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Interrupt active register.
|
* Interrupt active register.
|
||||||
*/
|
*/
|
||||||
#define OS_NVIC_INT_ACT_BASE 0xE000E300
|
#define OS_NVIC_INT_ACT_BASE 0xE000E300
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Interrupt disable register for 0-31.
|
* Interrupt disable register for 0-31.
|
||||||
*/
|
*/
|
||||||
#define OS_NVIC_CLRENA_BASE 0xE000E180
|
#define OS_NVIC_CLRENA_BASE 0xE000E180
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Interrupt control and status register.
|
* Interrupt control and status register.
|
||||||
*/
|
*/
|
||||||
#define OS_NVIC_INT_CTRL 0xE000ED04
|
#define OS_NVIC_INT_CTRL 0xE000ED04
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Vector table offset register.
|
* Vector table offset register.
|
||||||
*/
|
*/
|
||||||
#define OS_NVIC_VTOR 0xE000ED08
|
#define OS_NVIC_VTOR 0xE000ED08
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Application interrupt and reset control register
|
* Application interrupt and reset control register
|
||||||
*/
|
*/
|
||||||
#define OS_NVIC_AIRCR 0xE000ED0C
|
#define OS_NVIC_AIRCR 0xE000ED0C
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* System exception priority register.
|
* System exception priority register.
|
||||||
*/
|
*/
|
||||||
#define OS_NVIC_EXCPRI_BASE 0xE000ED18
|
#define OS_NVIC_EXCPRI_BASE 0xE000ED18
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Interrupt No. 1 :reset.
|
* Interrupt No. 1 :reset.
|
||||||
*/
|
*/
|
||||||
#define OS_EXC_RESET 1
|
#define OS_EXC_RESET 1
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Interrupt No. 2 :Non-Maskable Interrupt.
|
* Interrupt No. 2 :Non-Maskable Interrupt.
|
||||||
*/
|
*/
|
||||||
#define OS_EXC_NMI 2
|
#define OS_EXC_NMI 2
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Interrupt No. 3 :(hard)fault.
|
* Interrupt No. 3 :(hard)fault.
|
||||||
*/
|
*/
|
||||||
#define OS_EXC_HARD_FAULT 3
|
#define OS_EXC_HARD_FAULT 3
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Interrupt No. 4 :MemManage fault.
|
* Interrupt No. 4 :MemManage fault.
|
||||||
*/
|
*/
|
||||||
#define OS_EXC_MPU_FAULT 4
|
#define OS_EXC_MPU_FAULT 4
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Interrupt No. 5 :Bus fault.
|
* Interrupt No. 5 :Bus fault.
|
||||||
*/
|
*/
|
||||||
#define OS_EXC_BUS_FAULT 5
|
#define OS_EXC_BUS_FAULT 5
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Interrupt No. 6 :Usage fault.
|
* Interrupt No. 6 :Usage fault.
|
||||||
*/
|
*/
|
||||||
#define OS_EXC_USAGE_FAULT 6
|
#define OS_EXC_USAGE_FAULT 6
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Interrupt No. 11 :SVCall.
|
* Interrupt No. 11 :SVCall.
|
||||||
*/
|
*/
|
||||||
#define OS_EXC_SVC_CALL 11
|
#define OS_EXC_SVC_CALL 11
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Interrupt No. 12 :Debug monitor.
|
* Interrupt No. 12 :Debug monitor.
|
||||||
*/
|
*/
|
||||||
#define OS_EXC_DBG_MONITOR 12
|
#define OS_EXC_DBG_MONITOR 12
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Interrupt No. 14 :PendSV.
|
* Interrupt No. 14 :PendSV.
|
||||||
*/
|
*/
|
||||||
#define OS_EXC_PEND_SV 14
|
#define OS_EXC_PEND_SV 14
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Interrupt No. 15 :SysTick.
|
* Interrupt No. 15 :SysTick.
|
||||||
*/
|
*/
|
||||||
#define OS_EXC_SYS_TICK 15
|
#define OS_EXC_SYS_TICK 15
|
||||||
|
|
||||||
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
|
|
||||||
/* *
|
|
||||||
* @ingroup los_hwi
|
|
||||||
* Set interrupt vector table.
|
|
||||||
*/
|
|
||||||
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg);
|
|
||||||
#else
|
|
||||||
/* *
|
|
||||||
* @ingroup los_hwi
|
|
||||||
* Set interrupt vector table.
|
|
||||||
*/
|
|
||||||
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_hwi
|
||||||
* @brief: Hardware interrupt entry function.
|
* @brief: Hardware interrupt entry function.
|
||||||
@@ -346,27 +319,7 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
|
|||||||
extern VOID HalInterrupt(VOID);
|
extern VOID HalInterrupt(VOID);
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @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_hwi.h: the header file that contains the API declaration.</li
|
|
||||||
></ul>
|
|
||||||
* @see None.
|
|
||||||
*/
|
|
||||||
extern VOID HalHwiDefaultHandler(VOID);
|
|
||||||
|
|
||||||
/* *
|
|
||||||
* @ingroup los_hwi
|
|
||||||
* @brief: Reset the vector table.
|
* @brief: Reset the vector table.
|
||||||
*
|
*
|
||||||
* @par Description:
|
* @par Description:
|
||||||
@@ -379,13 +332,13 @@ extern VOID HalHwiDefaultHandler(VOID);
|
|||||||
*
|
*
|
||||||
* @retval:None.
|
* @retval:None.
|
||||||
* @par Dependency:
|
* @par Dependency:
|
||||||
* <ul><li>los_hwi.h: the header file that contains the API declaration.</li></ul>
|
* <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
|
||||||
* @see None.
|
* @see None.
|
||||||
*/
|
*/
|
||||||
extern VOID Reset_Handler(VOID);
|
extern VOID Reset_Handler(VOID);
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* @brief: Pended System Call.
|
* @brief: Pended System Call.
|
||||||
*
|
*
|
||||||
* @par Description:
|
* @par Description:
|
||||||
@@ -399,39 +352,25 @@ extern VOID Reset_Handler(VOID);
|
|||||||
*
|
*
|
||||||
* @retval:None.
|
* @retval:None.
|
||||||
* @par Dependency:
|
* @par Dependency:
|
||||||
* <ul><li>los_hwi.h: the header file that contains the API declaration.</li></ul>
|
* <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
|
||||||
* @see None.
|
* @see None.
|
||||||
*/
|
*/
|
||||||
extern VOID HalPendSV(VOID);
|
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_BUF_LEN 25
|
||||||
#define OS_EXC_MAX_NEST_DEPTH 1
|
#define OS_EXC_MAX_NEST_DEPTH 1
|
||||||
|
#define OS_EXC_FLAG_NO_FLOAT 0x10000000
|
||||||
|
|
||||||
#define OS_NVIC_SHCSR 0xE000ED24
|
#define OS_NVIC_SHCSR 0xE000ED24
|
||||||
#define OS_NVIC_CCR 0xE000ED14
|
#define OS_NVIC_CCR 0xE000ED14
|
||||||
|
|
||||||
#define OS_NVIC_INT_ENABLE_SIZE 0x20
|
#define OS_NVIC_INT_ENABLE_SIZE 0x20
|
||||||
#define OS_NVIC_INT_PRI_SIZE 0xF0
|
#define OS_NVIC_INT_PRI_SIZE 0xF0
|
||||||
#define OS_NVIC_EXCPRI_SIZE 0xC
|
#define OS_NVIC_EXCPRI_SIZE 0xC
|
||||||
#define OS_NVIC_INT_CTRL_SIZE 4
|
#define OS_NVIC_INT_CTRL_SIZE 4
|
||||||
#define OS_NVIC_SHCSR_SIZE 4
|
#define OS_NVIC_SHCSR_SIZE 4
|
||||||
|
|
||||||
#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
|
#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
|
||||||
#define OS_NVIC_INT_ACT_SIZE OS_NVIC_INT_ENABLE_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
|
* @ingroup los_exc
|
||||||
* the struct of register files
|
* the struct of register files
|
||||||
@@ -500,11 +439,10 @@ typedef struct TagExcContext {
|
|||||||
UINT32 FPSCR;
|
UINT32 FPSCR;
|
||||||
UINT32 NO_NAME;
|
UINT32 NO_NAME;
|
||||||
#endif
|
#endif
|
||||||
}EXC_CONTEXT_S;
|
} EXC_CONTEXT_S;
|
||||||
|
|
||||||
typedef VOID (*EXC_PROC_FUNC)(UINT32, 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 HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr);
|
||||||
|
|
||||||
VOID HalExcNMI(VOID);
|
VOID HalExcNMI(VOID);
|
||||||
VOID HalExcHardFault(VOID);
|
VOID HalExcHardFault(VOID);
|
||||||
VOID HalExcMemFault(VOID);
|
VOID HalExcMemFault(VOID);
|
||||||
@@ -645,7 +583,7 @@ VOID HalHwiInit(VOID);
|
|||||||
* @ingroup los_exc
|
* @ingroup los_exc
|
||||||
* Exception information structure
|
* Exception information structure
|
||||||
*
|
*
|
||||||
* Description: Exception information saved when an exception is triggered on the Cortex-M4 platform.
|
* Description: Exception information saved when an exception is triggered on the Cortex-M33 platform.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
typedef struct TagExcInfo {
|
typedef struct TagExcInfo {
|
||||||
@@ -668,10 +606,9 @@ typedef struct TagExcInfo {
|
|||||||
EXC_CONTEXT_S *context;
|
EXC_CONTEXT_S *context;
|
||||||
} ExcInfo;
|
} ExcInfo;
|
||||||
|
|
||||||
extern UINT32 g_curNestCount;
|
|
||||||
extern UINT32 g_intCount;
|
|
||||||
extern UINT8 g_uwExcTbl[32];
|
|
||||||
extern ExcInfo g_excInfo;
|
extern ExcInfo g_excInfo;
|
||||||
|
extern UINT32 g_curNestCount;
|
||||||
|
extern UINT8 g_uwExcTbl[32];
|
||||||
|
|
||||||
#define MAX_INT_INFO_SIZE (8 + 0x164)
|
#define MAX_INT_INFO_SIZE (8 + 0x164)
|
||||||
|
|
||||||
@@ -681,4 +618,4 @@ extern ExcInfo g_excInfo;
|
|||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
#endif /* _LOS_EXC_H */
|
#endif /* _LOS_ARCH_INTERRUPT_H */
|
||||||
|
|||||||
@@ -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-2023 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:
|
||||||
@@ -29,12 +29,10 @@
|
|||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "los_interrupt.h"
|
|
||||||
#include "securec.h"
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include "los_arch_interrupt.h"
|
#include "securec.h"
|
||||||
#include "los_context.h"
|
#include "los_context.h"
|
||||||
#include "los_debug.h"
|
#include "los_arch_interrupt.h"
|
||||||
#include "los_hook.h"
|
#include "los_hook.h"
|
||||||
#include "los_task.h"
|
#include "los_task.h"
|
||||||
#include "los_sched.h"
|
#include "los_sched.h"
|
||||||
@@ -44,93 +42,6 @@
|
|||||||
#include "los_cpup.h"
|
#include "los_cpup.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*lint -save -e40 -e522 -e533*/
|
|
||||||
UINT32 g_intCount = 0;
|
|
||||||
|
|
||||||
/*lint -restore*/
|
|
||||||
#pragma location = ".data.vector"
|
|
||||||
#pragma data_alignment = LOSCFG_ARCH_HWI_VECTOR_ALIGN
|
|
||||||
/* *
|
|
||||||
* @ingroup los_hwi
|
|
||||||
* hardware interrupt form mapping handling function array.
|
|
||||||
*/
|
|
||||||
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)
|
|
||||||
|
|
||||||
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
|
Function : HwiNumGet
|
||||||
Description : Get an interrupt number
|
Description : Get an interrupt number
|
||||||
@@ -145,100 +56,54 @@ STATIC UINT32 HwiNumGet(VOID)
|
|||||||
|
|
||||||
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
|
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
|
||||||
{
|
{
|
||||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
|
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
|
||||||
{
|
{
|
||||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
NVIC_DisableIRQ((IRQn_Type)hwiNum);
|
NVIC_DisableIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority)
|
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);
|
NVIC_SetPriority((IRQn_Type)hwiNum, priority);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
|
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
|
||||||
{
|
{
|
||||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
|
NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
|
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
|
||||||
{
|
{
|
||||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
|
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
HwiControllerOps g_archHwiOps = {
|
STATIC UINT32 HwiCreate(HWI_HANDLE_T hwiNum, HWI_PRIOR_T hwiPrio)
|
||||||
|
{
|
||||||
|
HwiSetPriority(hwiNum, hwiPrio);
|
||||||
|
HwiUnmask(hwiNum);
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC HwiControllerOps g_archHwiOps = {
|
||||||
.enableIrq = HwiUnmask,
|
.enableIrq = HwiUnmask,
|
||||||
.disableIrq = HwiMask,
|
.disableIrq = HwiMask,
|
||||||
.setIrqPriority = HwiSetPriority,
|
.setIrqPriority = HwiSetPriority,
|
||||||
.getCurIrqNum = HwiNumGet,
|
.getCurIrqNum = HwiNumGet,
|
||||||
.triggerIrq = HwiPending,
|
.triggerIrq = HwiPending,
|
||||||
.clearIrq = HwiClear,
|
.clearIrq = HwiClear,
|
||||||
|
.createIrq = HwiCreate,
|
||||||
};
|
};
|
||||||
|
|
||||||
inline UINT32 ArchIsIntActive(VOID)
|
HwiControllerOps *ArchIntOpsGet(VOID)
|
||||||
{
|
{
|
||||||
return (g_intCount > 0);
|
return &g_archHwiOps;
|
||||||
}
|
|
||||||
/* ****************************************************************************
|
|
||||||
Function : HalHwiDefaultHandler
|
|
||||||
Description : default handler of the hardware interrupt
|
|
||||||
Input : None
|
|
||||||
Output : None
|
|
||||||
Return : None
|
|
||||||
**************************************************************************** */
|
|
||||||
/*lint -e529*/
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ****************************************************************************
|
/* ****************************************************************************
|
||||||
@@ -299,97 +164,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
|
|||||||
LOS_IntRestore(intSave);
|
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;
|
|
||||||
UINTPTR 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
NVIC_DisableIRQ((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 FAULT_STATUS_REG_BIT 32
|
||||||
#define USGFAULT (1 << 18)
|
#define USGFAULT (1 << 18)
|
||||||
#define BUSFAULT (1 << 17)
|
#define BUSFAULT (1 << 17)
|
||||||
@@ -611,6 +385,11 @@ LITE_OS_SEC_TEXT_INIT VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, U
|
|||||||
ArchSysExit();
|
ArchSysExit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WEAK VOID SysTick_Handler(VOID)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* ****************************************************************************
|
/* ****************************************************************************
|
||||||
Function : HalHwiInit
|
Function : HalHwiInit
|
||||||
Description : initialization of the hardware interrupt
|
Description : initialization of the hardware interrupt
|
||||||
@@ -622,23 +401,24 @@ 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 */
|
HWI_PROC_FUNC *hwiForm = (HWI_PROC_FUNC *)ArchGetHwiFrom();
|
||||||
g_hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */
|
hwiForm[0] = 0; /* [0] Top of Stack */
|
||||||
|
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;
|
hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
|
||||||
}
|
}
|
||||||
/* Exception handler register */
|
/* Exception handler register */
|
||||||
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
|
hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
|
||||||
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
|
hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
|
||||||
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
|
hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
|
||||||
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
|
hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
|
||||||
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
|
hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
|
||||||
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
|
hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
|
||||||
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
|
hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
|
||||||
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
|
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)hwiForm;
|
||||||
#endif
|
#endif
|
||||||
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
|
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
|
||||||
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
|
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
|
||||||
@@ -651,4 +431,3 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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-2023 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:
|
||||||
@@ -29,12 +29,10 @@
|
|||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _LOS_EXC_H
|
#ifndef _LOS_ARCH_INTERRUPT_H
|
||||||
#define _LOS_EXC_H
|
#define _LOS_ARCH_INTERRUPT_H
|
||||||
|
|
||||||
#include "los_config.h"
|
#include "los_common_interrupt.h"
|
||||||
#include "los_compiler.h"
|
|
||||||
#include "los_interrupt.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
@@ -43,15 +41,7 @@ extern "C" {
|
|||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @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_hwi
|
|
||||||
* Highest priority of a hardware interrupt.
|
* Highest priority of a hardware interrupt.
|
||||||
*/
|
*/
|
||||||
#ifndef OS_HWI_PRIO_HIGHEST
|
#ifndef OS_HWI_PRIO_HIGHEST
|
||||||
@@ -59,63 +49,50 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Lowest priority of a hardware interrupt.
|
* Lowest priority of a hardware interrupt.
|
||||||
*/
|
*/
|
||||||
#ifndef OS_HWI_PRIO_LOWEST
|
#ifndef OS_HWI_PRIO_LOWEST
|
||||||
#define OS_HWI_PRIO_LOWEST 7
|
#define OS_HWI_PRIO_LOWEST 7
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Define the type of a hardware interrupt vector table function.
|
|
||||||
*/
|
|
||||||
typedef VOID (**HWI_VECTOR_FUNC)(void);
|
|
||||||
|
|
||||||
/* *
|
|
||||||
* @ingroup los_hwi
|
|
||||||
* Count of interrupts.
|
|
||||||
*/
|
|
||||||
extern UINT32 g_intCount;
|
|
||||||
|
|
||||||
/* *
|
|
||||||
* @ingroup los_hwi
|
|
||||||
* Count of M-Core system interrupt vector.
|
|
||||||
*/
|
|
||||||
#define OS_SYS_VECTOR_CNT 16
|
|
||||||
|
|
||||||
/* *
|
|
||||||
* @ingroup los_hwi
|
|
||||||
* Count of M-Core interrupt vector.
|
|
||||||
*/
|
|
||||||
#define OS_VECTOR_CNT (OS_SYS_VECTOR_CNT + OS_HWI_MAX_NUM)
|
|
||||||
|
|
||||||
/* *
|
|
||||||
* @ingroup los_hwi
|
|
||||||
* AIRCR register priority group parameter .
|
* AIRCR register priority group parameter .
|
||||||
*/
|
*/
|
||||||
#define OS_NVIC_AIRCR_PRIGROUP 7
|
#define OS_NVIC_AIRCR_PRIGROUP 7
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Boot interrupt vector table.
|
* Boot interrupt vector table.
|
||||||
*/
|
*/
|
||||||
extern UINT32 _BootVectors[];
|
extern UINT32 _BootVectors[];
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @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
|
||||||
* Hardware interrupt error code: Invalid interrupt number.
|
* Hardware interrupt error code: Invalid interrupt number.
|
||||||
*
|
*
|
||||||
* Value: 0x02000900
|
* Value: 0x02000900
|
||||||
*
|
*
|
||||||
* Solution: Ensure that the interrupt number is valid.
|
* 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].
|
* 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)
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Hardware interrupt error code: Null hardware interrupt handling function.
|
* Hardware interrupt error code: Null hardware interrupt handling function.
|
||||||
*
|
*
|
||||||
* Value: 0x02000901
|
* Value: 0x02000901
|
||||||
@@ -125,7 +102,7 @@ extern UINT32 _BootVectors[];
|
|||||||
#define OS_ERRNO_HWI_PROC_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x01)
|
#define OS_ERRNO_HWI_PROC_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x01)
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Hardware interrupt error code: Insufficient interrupt resources for hardware interrupt creation.
|
* Hardware interrupt error code: Insufficient interrupt resources for hardware interrupt creation.
|
||||||
*
|
*
|
||||||
* Value: 0x02000902
|
* Value: 0x02000902
|
||||||
@@ -135,7 +112,7 @@ extern UINT32 _BootVectors[];
|
|||||||
#define OS_ERRNO_HWI_CB_UNAVAILABLE LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x02)
|
#define OS_ERRNO_HWI_CB_UNAVAILABLE LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x02)
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Hardware interrupt error code: Insufficient memory for hardware interrupt initialization.
|
* Hardware interrupt error code: Insufficient memory for hardware interrupt initialization.
|
||||||
*
|
*
|
||||||
* Value: 0x02000903
|
* Value: 0x02000903
|
||||||
@@ -145,7 +122,7 @@ extern UINT32 _BootVectors[];
|
|||||||
#define OS_ERRNO_HWI_NO_MEMORY LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x03)
|
#define OS_ERRNO_HWI_NO_MEMORY LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x03)
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Hardware interrupt error code: The interrupt has already been created.
|
* Hardware interrupt error code: The interrupt has already been created.
|
||||||
*
|
*
|
||||||
* Value: 0x02000904
|
* Value: 0x02000904
|
||||||
@@ -155,7 +132,7 @@ extern UINT32 _BootVectors[];
|
|||||||
#define OS_ERRNO_HWI_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x04)
|
#define OS_ERRNO_HWI_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x04)
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Hardware interrupt error code: Invalid interrupt priority.
|
* Hardware interrupt error code: Invalid interrupt priority.
|
||||||
*
|
*
|
||||||
* Value: 0x02000905
|
* Value: 0x02000905
|
||||||
@@ -166,7 +143,7 @@ extern UINT32 _BootVectors[];
|
|||||||
#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)
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Hardware interrupt error code: Incorrect interrupt creation mode.
|
* Hardware interrupt error code: Incorrect interrupt creation mode.
|
||||||
*
|
*
|
||||||
* Value: 0x02000906
|
* Value: 0x02000906
|
||||||
@@ -177,7 +154,7 @@ extern UINT32 _BootVectors[];
|
|||||||
#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)
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Hardware interrupt error code: The interrupt has already been created as a fast interrupt.
|
* Hardware interrupt error code: The interrupt has already been created as a fast interrupt.
|
||||||
*
|
*
|
||||||
* Value: 0x02000907
|
* Value: 0x02000907
|
||||||
@@ -187,7 +164,17 @@ extern UINT32 _BootVectors[];
|
|||||||
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
|
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
|
* Hardware interrupt error code: Invalid interrupt operation function.
|
||||||
|
*
|
||||||
|
* Value: 0x0200090c
|
||||||
|
*
|
||||||
|
* Solution: Set a valid interrupt operation function
|
||||||
|
*/
|
||||||
|
#define OS_ERRNO_HWI_OPS_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x0c)
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
* SysTick control and status register.
|
* SysTick control and status register.
|
||||||
*/
|
*/
|
||||||
#define OS_SYSTICK_CONTROL_REG 0xE000E010
|
#define OS_SYSTICK_CONTROL_REG 0xE000E010
|
||||||
@@ -199,133 +186,119 @@ extern UINT32 _BootVectors[];
|
|||||||
#define OS_SYSTICK_CURRENT_REG 0xE000E018
|
#define OS_SYSTICK_CURRENT_REG 0xE000E018
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Interrupt Priority-Level Registers.
|
* Interrupt Priority-Level Registers.
|
||||||
*/
|
*/
|
||||||
#define OS_NVIC_PRI_BASE 0xE000E400
|
#define OS_NVIC_PRI_BASE 0xE000E400
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Interrupt enable register for 0-31.
|
* Interrupt enable register for 0-31.
|
||||||
*/
|
*/
|
||||||
#define OS_NVIC_SETENA_BASE 0xE000E100
|
#define OS_NVIC_SETENA_BASE 0xE000E100
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* interrupt pending register.
|
* interrupt pending register.
|
||||||
*/
|
*/
|
||||||
#define OS_NVIC_SETPEND_BASE 0xE000E200
|
#define OS_NVIC_SETPEND_BASE 0xE000E200
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Interrupt active register.
|
* Interrupt active register.
|
||||||
*/
|
*/
|
||||||
#define OS_NVIC_INT_ACT_BASE 0xE000E300
|
#define OS_NVIC_INT_ACT_BASE 0xE000E300
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Interrupt disable register for 0-31.
|
* Interrupt disable register for 0-31.
|
||||||
*/
|
*/
|
||||||
#define OS_NVIC_CLRENA_BASE 0xE000E180
|
#define OS_NVIC_CLRENA_BASE 0xE000E180
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Interrupt control and status register.
|
* Interrupt control and status register.
|
||||||
*/
|
*/
|
||||||
#define OS_NVIC_INT_CTRL 0xE000ED04
|
#define OS_NVIC_INT_CTRL 0xE000ED04
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Vector table offset register.
|
* Vector table offset register.
|
||||||
*/
|
*/
|
||||||
#define OS_NVIC_VTOR 0xE000ED08
|
#define OS_NVIC_VTOR 0xE000ED08
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Application interrupt and reset control register
|
* Application interrupt and reset control register
|
||||||
*/
|
*/
|
||||||
#define OS_NVIC_AIRCR 0xE000ED0C
|
#define OS_NVIC_AIRCR 0xE000ED0C
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* System exception priority register.
|
* System exception priority register.
|
||||||
*/
|
*/
|
||||||
#define OS_NVIC_EXCPRI_BASE 0xE000ED18
|
#define OS_NVIC_EXCPRI_BASE 0xE000ED18
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Interrupt No. 1 :reset.
|
* Interrupt No. 1 :reset.
|
||||||
*/
|
*/
|
||||||
#define OS_EXC_RESET 1
|
#define OS_EXC_RESET 1
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Interrupt No. 2 :Non-Maskable Interrupt.
|
* Interrupt No. 2 :Non-Maskable Interrupt.
|
||||||
*/
|
*/
|
||||||
#define OS_EXC_NMI 2
|
#define OS_EXC_NMI 2
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Interrupt No. 3 :(hard)fault.
|
* Interrupt No. 3 :(hard)fault.
|
||||||
*/
|
*/
|
||||||
#define OS_EXC_HARD_FAULT 3
|
#define OS_EXC_HARD_FAULT 3
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Interrupt No. 4 :MemManage fault.
|
* Interrupt No. 4 :MemManage fault.
|
||||||
*/
|
*/
|
||||||
#define OS_EXC_MPU_FAULT 4
|
#define OS_EXC_MPU_FAULT 4
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Interrupt No. 5 :Bus fault.
|
* Interrupt No. 5 :Bus fault.
|
||||||
*/
|
*/
|
||||||
#define OS_EXC_BUS_FAULT 5
|
#define OS_EXC_BUS_FAULT 5
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Interrupt No. 6 :Usage fault.
|
* Interrupt No. 6 :Usage fault.
|
||||||
*/
|
*/
|
||||||
#define OS_EXC_USAGE_FAULT 6
|
#define OS_EXC_USAGE_FAULT 6
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Interrupt No. 11 :SVCall.
|
* Interrupt No. 11 :SVCall.
|
||||||
*/
|
*/
|
||||||
#define OS_EXC_SVC_CALL 11
|
#define OS_EXC_SVC_CALL 11
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Interrupt No. 12 :Debug monitor.
|
* Interrupt No. 12 :Debug monitor.
|
||||||
*/
|
*/
|
||||||
#define OS_EXC_DBG_MONITOR 12
|
#define OS_EXC_DBG_MONITOR 12
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Interrupt No. 14 :PendSV.
|
* Interrupt No. 14 :PendSV.
|
||||||
*/
|
*/
|
||||||
#define OS_EXC_PEND_SV 14
|
#define OS_EXC_PEND_SV 14
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Interrupt No. 15 :SysTick.
|
* Interrupt No. 15 :SysTick.
|
||||||
*/
|
*/
|
||||||
#define OS_EXC_SYS_TICK 15
|
#define OS_EXC_SYS_TICK 15
|
||||||
|
|
||||||
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
|
|
||||||
/* *
|
|
||||||
* @ingroup los_hwi
|
|
||||||
* Set interrupt vector table.
|
|
||||||
*/
|
|
||||||
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg);
|
|
||||||
#else
|
|
||||||
/* *
|
|
||||||
* @ingroup los_hwi
|
|
||||||
* Set interrupt vector table.
|
|
||||||
*/
|
|
||||||
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_hwi
|
||||||
* @brief: Hardware interrupt entry function.
|
* @brief: Hardware interrupt entry function.
|
||||||
@@ -346,27 +319,7 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
|
|||||||
extern VOID HalInterrupt(VOID);
|
extern VOID HalInterrupt(VOID);
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @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_hwi.h: the header file that contains the API declaration.</li
|
|
||||||
></ul>
|
|
||||||
* @see None.
|
|
||||||
*/
|
|
||||||
extern VOID HalHwiDefaultHandler(VOID);
|
|
||||||
|
|
||||||
/* *
|
|
||||||
* @ingroup los_hwi
|
|
||||||
* @brief: Reset the vector table.
|
* @brief: Reset the vector table.
|
||||||
*
|
*
|
||||||
* @par Description:
|
* @par Description:
|
||||||
@@ -379,13 +332,13 @@ extern VOID HalHwiDefaultHandler(VOID);
|
|||||||
*
|
*
|
||||||
* @retval:None.
|
* @retval:None.
|
||||||
* @par Dependency:
|
* @par Dependency:
|
||||||
* <ul><li>los_hwi.h: the header file that contains the API declaration.</li></ul>
|
* <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
|
||||||
* @see None.
|
* @see None.
|
||||||
*/
|
*/
|
||||||
extern VOID Reset_Handler(VOID);
|
extern VOID Reset_Handler(VOID);
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* @brief: Pended System Call.
|
* @brief: Pended System Call.
|
||||||
*
|
*
|
||||||
* @par Description:
|
* @par Description:
|
||||||
@@ -399,39 +352,25 @@ extern VOID Reset_Handler(VOID);
|
|||||||
*
|
*
|
||||||
* @retval:None.
|
* @retval:None.
|
||||||
* @par Dependency:
|
* @par Dependency:
|
||||||
* <ul><li>los_hwi.h: the header file that contains the API declaration.</li></ul>
|
* <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
|
||||||
* @see None.
|
* @see None.
|
||||||
*/
|
*/
|
||||||
extern VOID HalPendSV(VOID);
|
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_BUF_LEN 25
|
||||||
#define OS_EXC_MAX_NEST_DEPTH 1
|
#define OS_EXC_MAX_NEST_DEPTH 1
|
||||||
|
#define OS_EXC_FLAG_NO_FLOAT 0x10000000
|
||||||
|
|
||||||
#define OS_NVIC_SHCSR 0xE000ED24
|
#define OS_NVIC_SHCSR 0xE000ED24
|
||||||
#define OS_NVIC_CCR 0xE000ED14
|
#define OS_NVIC_CCR 0xE000ED14
|
||||||
|
|
||||||
#define OS_NVIC_INT_ENABLE_SIZE 0x20
|
#define OS_NVIC_INT_ENABLE_SIZE 0x20
|
||||||
#define OS_NVIC_INT_PRI_SIZE 0xF0
|
#define OS_NVIC_INT_PRI_SIZE 0xF0
|
||||||
#define OS_NVIC_EXCPRI_SIZE 0xC
|
#define OS_NVIC_EXCPRI_SIZE 0xC
|
||||||
#define OS_NVIC_INT_CTRL_SIZE 4
|
#define OS_NVIC_INT_CTRL_SIZE 4
|
||||||
#define OS_NVIC_SHCSR_SIZE 4
|
#define OS_NVIC_SHCSR_SIZE 4
|
||||||
|
|
||||||
#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
|
#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
|
||||||
#define OS_NVIC_INT_ACT_SIZE OS_NVIC_INT_ENABLE_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
|
* @ingroup los_exc
|
||||||
* the struct of register files
|
* the struct of register files
|
||||||
@@ -500,11 +439,10 @@ typedef struct TagExcContext {
|
|||||||
UINT32 FPSCR;
|
UINT32 FPSCR;
|
||||||
UINT32 NO_NAME;
|
UINT32 NO_NAME;
|
||||||
#endif
|
#endif
|
||||||
}EXC_CONTEXT_S;
|
} EXC_CONTEXT_S;
|
||||||
|
|
||||||
typedef VOID (*EXC_PROC_FUNC)(UINT32, 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 HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr);
|
||||||
|
|
||||||
VOID HalExcNMI(VOID);
|
VOID HalExcNMI(VOID);
|
||||||
VOID HalExcHardFault(VOID);
|
VOID HalExcHardFault(VOID);
|
||||||
VOID HalExcMemFault(VOID);
|
VOID HalExcMemFault(VOID);
|
||||||
@@ -645,7 +583,7 @@ VOID HalHwiInit(VOID);
|
|||||||
* @ingroup los_exc
|
* @ingroup los_exc
|
||||||
* Exception information structure
|
* Exception information structure
|
||||||
*
|
*
|
||||||
* Description: Exception information saved when an exception is triggered on the Cortex-M4 platform.
|
* Description: Exception information saved when an exception is triggered on the Cortex-M33 platform.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
typedef struct TagExcInfo {
|
typedef struct TagExcInfo {
|
||||||
@@ -668,10 +606,9 @@ typedef struct TagExcInfo {
|
|||||||
EXC_CONTEXT_S *context;
|
EXC_CONTEXT_S *context;
|
||||||
} ExcInfo;
|
} ExcInfo;
|
||||||
|
|
||||||
extern UINT32 g_curNestCount;
|
|
||||||
extern UINT32 g_intCount;
|
|
||||||
extern UINT8 g_uwExcTbl[32];
|
|
||||||
extern ExcInfo g_excInfo;
|
extern ExcInfo g_excInfo;
|
||||||
|
extern UINT32 g_curNestCount;
|
||||||
|
extern UINT8 g_uwExcTbl[32];
|
||||||
|
|
||||||
#define MAX_INT_INFO_SIZE (8 + 0x164)
|
#define MAX_INT_INFO_SIZE (8 + 0x164)
|
||||||
|
|
||||||
@@ -681,4 +618,4 @@ extern ExcInfo g_excInfo;
|
|||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
#endif /* _LOS_EXC_H */
|
#endif /* _LOS_ARCH_INTERRUPT_H */
|
||||||
|
|||||||
@@ -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-2023 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:
|
||||||
@@ -29,12 +29,10 @@
|
|||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "los_interrupt.h"
|
|
||||||
#include "securec.h"
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include "los_arch_interrupt.h"
|
#include "securec.h"
|
||||||
#include "los_context.h"
|
#include "los_context.h"
|
||||||
#include "los_debug.h"
|
#include "los_arch_interrupt.h"
|
||||||
#include "los_hook.h"
|
#include "los_hook.h"
|
||||||
#include "los_task.h"
|
#include "los_task.h"
|
||||||
#include "los_sched.h"
|
#include "los_sched.h"
|
||||||
@@ -44,93 +42,6 @@
|
|||||||
#include "los_cpup.h"
|
#include "los_cpup.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*lint -save -e40 -e522 -e533*/
|
|
||||||
UINT32 g_intCount = 0;
|
|
||||||
|
|
||||||
/*lint -restore*/
|
|
||||||
#pragma location = ".data.vector"
|
|
||||||
#pragma data_alignment = LOSCFG_ARCH_HWI_VECTOR_ALIGN
|
|
||||||
/* *
|
|
||||||
* @ingroup los_hwi
|
|
||||||
* hardware interrupt form mapping handling function array.
|
|
||||||
*/
|
|
||||||
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)
|
|
||||||
|
|
||||||
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
|
Function : HwiNumGet
|
||||||
Description : Get an interrupt number
|
Description : Get an interrupt number
|
||||||
@@ -145,100 +56,54 @@ STATIC UINT32 HwiNumGet(VOID)
|
|||||||
|
|
||||||
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
|
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
|
||||||
{
|
{
|
||||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
|
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
|
||||||
{
|
{
|
||||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
NVIC_DisableIRQ((IRQn_Type)hwiNum);
|
NVIC_DisableIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority)
|
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);
|
NVIC_SetPriority((IRQn_Type)hwiNum, priority);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
|
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
|
||||||
{
|
{
|
||||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
|
NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
|
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
|
||||||
{
|
{
|
||||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
|
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
HwiControllerOps g_archHwiOps = {
|
STATIC UINT32 HwiCreate(HWI_HANDLE_T hwiNum, HWI_PRIOR_T hwiPrio)
|
||||||
|
{
|
||||||
|
HwiSetPriority(hwiNum, hwiPrio);
|
||||||
|
HwiUnmask(hwiNum);
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC HwiControllerOps g_archHwiOps = {
|
||||||
.enableIrq = HwiUnmask,
|
.enableIrq = HwiUnmask,
|
||||||
.disableIrq = HwiMask,
|
.disableIrq = HwiMask,
|
||||||
.setIrqPriority = HwiSetPriority,
|
.setIrqPriority = HwiSetPriority,
|
||||||
.getCurIrqNum = HwiNumGet,
|
.getCurIrqNum = HwiNumGet,
|
||||||
.triggerIrq = HwiPending,
|
.triggerIrq = HwiPending,
|
||||||
.clearIrq = HwiClear,
|
.clearIrq = HwiClear,
|
||||||
|
.createIrq = HwiCreate,
|
||||||
};
|
};
|
||||||
|
|
||||||
inline UINT32 ArchIsIntActive(VOID)
|
HwiControllerOps *ArchIntOpsGet(VOID)
|
||||||
{
|
{
|
||||||
return (g_intCount > 0);
|
return &g_archHwiOps;
|
||||||
}
|
|
||||||
/* ****************************************************************************
|
|
||||||
Function : HalHwiDefaultHandler
|
|
||||||
Description : default handler of the hardware interrupt
|
|
||||||
Input : None
|
|
||||||
Output : None
|
|
||||||
Return : None
|
|
||||||
**************************************************************************** */
|
|
||||||
/*lint -e529*/
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ****************************************************************************
|
/* ****************************************************************************
|
||||||
@@ -299,97 +164,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
|
|||||||
LOS_IntRestore(intSave);
|
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;
|
|
||||||
UINTPTR 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
NVIC_DisableIRQ((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 FAULT_STATUS_REG_BIT 32
|
||||||
#define USGFAULT (1 << 18)
|
#define USGFAULT (1 << 18)
|
||||||
#define BUSFAULT (1 << 17)
|
#define BUSFAULT (1 << 17)
|
||||||
@@ -611,6 +385,11 @@ LITE_OS_SEC_TEXT_INIT VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, U
|
|||||||
ArchSysExit();
|
ArchSysExit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WEAK VOID SysTick_Handler(VOID)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* ****************************************************************************
|
/* ****************************************************************************
|
||||||
Function : HalHwiInit
|
Function : HalHwiInit
|
||||||
Description : initialization of the hardware interrupt
|
Description : initialization of the hardware interrupt
|
||||||
@@ -622,23 +401,24 @@ 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 */
|
HWI_PROC_FUNC *hwiForm = (HWI_PROC_FUNC *)ArchGetHwiFrom();
|
||||||
g_hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */
|
hwiForm[0] = 0; /* [0] Top of Stack */
|
||||||
|
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;
|
hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
|
||||||
}
|
}
|
||||||
/* Exception handler register */
|
/* Exception handler register */
|
||||||
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
|
hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
|
||||||
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
|
hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
|
||||||
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
|
hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
|
||||||
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
|
hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
|
||||||
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
|
hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
|
||||||
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
|
hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
|
||||||
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
|
hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
|
||||||
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
|
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)hwiForm;
|
||||||
#endif
|
#endif
|
||||||
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
|
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
|
||||||
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
|
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
|
||||||
@@ -651,4 +431,3 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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-2023 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:
|
||||||
@@ -32,9 +32,7 @@
|
|||||||
#ifndef _LOS_ARCH_INTERRUPT_H
|
#ifndef _LOS_ARCH_INTERRUPT_H
|
||||||
#define _LOS_ARCH_INTERRUPT_H
|
#define _LOS_ARCH_INTERRUPT_H
|
||||||
|
|
||||||
#include "los_config.h"
|
#include "los_common_interrupt.h"
|
||||||
#include "los_compiler.h"
|
|
||||||
#include "los_interrupt.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
@@ -42,14 +40,6 @@ extern "C" {
|
|||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
#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
|
* @ingroup los_arch_interrupt
|
||||||
* Highest priority of a hardware interrupt.
|
* Highest priority of a hardware interrupt.
|
||||||
@@ -66,18 +56,17 @@ extern "C" {
|
|||||||
#define OS_HWI_PRIO_LOWEST 7
|
#define OS_HWI_PRIO_LOWEST 7
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_arch_interrupt
|
* @ingroup los_arch_interrupt
|
||||||
* Define the type of a hardware interrupt vector table function.
|
* AIRCR register priority group parameter .
|
||||||
*/
|
*/
|
||||||
typedef VOID (**HWI_VECTOR_FUNC)(void);
|
#define OS_NVIC_AIRCR_PRIGROUP 7
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_arch_interrupt
|
* @ingroup los_arch_interrupt
|
||||||
* Count of interrupts.
|
* Boot interrupt vector table.
|
||||||
*/
|
*/
|
||||||
extern UINT32 g_intCount;
|
extern UINT32 _BootVectors[];
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_arch_interrupt
|
* @ingroup los_arch_interrupt
|
||||||
@@ -91,18 +80,6 @@ extern UINT32 g_intCount;
|
|||||||
*/
|
*/
|
||||||
#define OS_VECTOR_CNT (OS_SYS_VECTOR_CNT + OS_HWI_MAX_NUM)
|
#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
|
* @ingroup los_arch_interrupt
|
||||||
* Hardware interrupt error code: Invalid interrupt number.
|
* Hardware interrupt error code: Invalid interrupt number.
|
||||||
@@ -110,7 +87,7 @@ extern UINT32 _BootVectors[];
|
|||||||
* Value: 0x02000900
|
* Value: 0x02000900
|
||||||
*
|
*
|
||||||
* Solution: Ensure that the interrupt number is valid.
|
* 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].
|
* 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)
|
||||||
|
|
||||||
@@ -186,6 +163,16 @@ extern UINT32 _BootVectors[];
|
|||||||
*/
|
*/
|
||||||
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
|
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Hardware interrupt error code: Invalid interrupt operation function.
|
||||||
|
*
|
||||||
|
* Value: 0x0200090c
|
||||||
|
*
|
||||||
|
* Solution: Set a valid interrupt operation function
|
||||||
|
*/
|
||||||
|
#define OS_ERRNO_HWI_OPS_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x0c)
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_arch_interrupt
|
* @ingroup los_arch_interrupt
|
||||||
* SysTick control and status register.
|
* SysTick control and status register.
|
||||||
@@ -312,20 +299,6 @@ extern UINT32 _BootVectors[];
|
|||||||
*/
|
*/
|
||||||
#define OS_EXC_SYS_TICK 15
|
#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
|
* @ingroup los_arch_interrupt
|
||||||
* @brief: Hardware interrupt entry function.
|
* @brief: Hardware interrupt entry function.
|
||||||
@@ -345,25 +318,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
|
|||||||
*/
|
*/
|
||||||
extern VOID HalInterrupt(VOID);
|
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
|
* @ingroup los_arch_interrupt
|
||||||
* @brief: Reset the vector table.
|
* @brief: Reset the vector table.
|
||||||
@@ -403,34 +357,20 @@ extern VOID Reset_Handler(VOID);
|
|||||||
*/
|
*/
|
||||||
extern VOID HalPendSV(VOID);
|
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_BUF_LEN 25
|
||||||
#define OS_EXC_MAX_NEST_DEPTH 1
|
#define OS_EXC_MAX_NEST_DEPTH 1
|
||||||
|
#define OS_EXC_FLAG_NO_FLOAT 0x10000000
|
||||||
|
|
||||||
#define OS_NVIC_SHCSR 0xE000ED24
|
#define OS_NVIC_SHCSR 0xE000ED24
|
||||||
#define OS_NVIC_CCR 0xE000ED14
|
#define OS_NVIC_CCR 0xE000ED14
|
||||||
|
|
||||||
#define OS_NVIC_INT_ENABLE_SIZE 0x20
|
#define OS_NVIC_INT_ENABLE_SIZE 0x20
|
||||||
#define OS_NVIC_INT_PRI_SIZE 0xF0
|
#define OS_NVIC_INT_PRI_SIZE 0xF0
|
||||||
#define OS_NVIC_EXCPRI_SIZE 0xC
|
#define OS_NVIC_EXCPRI_SIZE 0xC
|
||||||
#define OS_NVIC_INT_CTRL_SIZE 4
|
#define OS_NVIC_INT_CTRL_SIZE 4
|
||||||
#define OS_NVIC_SHCSR_SIZE 4
|
#define OS_NVIC_SHCSR_SIZE 4
|
||||||
|
|
||||||
#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
|
#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
|
||||||
#define OS_NVIC_INT_ACT_SIZE OS_NVIC_INT_ENABLE_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
|
* @ingroup los_exc
|
||||||
* the struct of register files
|
* the struct of register files
|
||||||
@@ -503,7 +443,6 @@ typedef struct TagExcContext {
|
|||||||
|
|
||||||
typedef VOID (*EXC_PROC_FUNC)(UINT32, 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 HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr);
|
||||||
|
|
||||||
VOID HalExcNMI(VOID);
|
VOID HalExcNMI(VOID);
|
||||||
VOID HalExcHardFault(VOID);
|
VOID HalExcHardFault(VOID);
|
||||||
VOID HalExcMemFault(VOID);
|
VOID HalExcMemFault(VOID);
|
||||||
@@ -667,10 +606,9 @@ typedef struct TagExcInfo {
|
|||||||
EXC_CONTEXT_S *context;
|
EXC_CONTEXT_S *context;
|
||||||
} ExcInfo;
|
} ExcInfo;
|
||||||
|
|
||||||
extern UINT32 g_curNestCount;
|
|
||||||
extern UINT32 g_intCount;
|
|
||||||
extern UINT8 g_uwExcTbl[32];
|
|
||||||
extern ExcInfo g_excInfo;
|
extern ExcInfo g_excInfo;
|
||||||
|
extern UINT32 g_curNestCount;
|
||||||
|
extern UINT8 g_uwExcTbl[32];
|
||||||
|
|
||||||
#define MAX_INT_INFO_SIZE (8 + 0x164)
|
#define MAX_INT_INFO_SIZE (8 + 0x164)
|
||||||
|
|
||||||
|
|||||||
@@ -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-2023 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:
|
||||||
@@ -28,12 +28,11 @@
|
|||||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
#include "los_interrupt.h"
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include "securec.h"
|
#include "securec.h"
|
||||||
#include "los_context.h"
|
#include "los_context.h"
|
||||||
#include "los_arch_interrupt.h"
|
#include "los_arch_interrupt.h"
|
||||||
#include "los_debug.h"
|
|
||||||
#include "los_hook.h"
|
#include "los_hook.h"
|
||||||
#include "los_task.h"
|
#include "los_task.h"
|
||||||
#include "los_sched.h"
|
#include "los_sched.h"
|
||||||
@@ -43,89 +42,6 @@
|
|||||||
#include "los_cpup.h"
|
#include "los_cpup.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
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
|
Function : HwiNumGet
|
||||||
Description : Get an interrupt number
|
Description : Get an interrupt number
|
||||||
@@ -140,99 +56,54 @@ STATIC UINT32 HwiNumGet(VOID)
|
|||||||
|
|
||||||
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
|
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
|
||||||
{
|
{
|
||||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
|
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
|
||||||
{
|
{
|
||||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
NVIC_DisableIRQ((IRQn_Type)hwiNum);
|
NVIC_DisableIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority)
|
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);
|
NVIC_SetPriority((IRQn_Type)hwiNum, priority);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
|
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
|
||||||
{
|
{
|
||||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
|
NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
|
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
|
||||||
{
|
{
|
||||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
|
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
HwiControllerOps g_archHwiOps = {
|
STATIC UINT32 HwiCreate(HWI_HANDLE_T hwiNum, HWI_PRIOR_T hwiPrio)
|
||||||
|
{
|
||||||
|
HwiSetPriority(hwiNum, hwiPrio);
|
||||||
|
HwiUnmask(hwiNum);
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC HwiControllerOps g_archHwiOps = {
|
||||||
.enableIrq = HwiUnmask,
|
.enableIrq = HwiUnmask,
|
||||||
.disableIrq = HwiMask,
|
.disableIrq = HwiMask,
|
||||||
.setIrqPriority = HwiSetPriority,
|
.setIrqPriority = HwiSetPriority,
|
||||||
.getCurIrqNum = HwiNumGet,
|
.getCurIrqNum = HwiNumGet,
|
||||||
.triggerIrq = HwiPending,
|
.triggerIrq = HwiPending,
|
||||||
.clearIrq = HwiClear,
|
.clearIrq = HwiClear,
|
||||||
|
.createIrq = HwiCreate,
|
||||||
};
|
};
|
||||||
|
|
||||||
inline UINT32 ArchIsIntActive(VOID)
|
HwiControllerOps *ArchIntOpsGet(VOID)
|
||||||
{
|
{
|
||||||
return (g_intCount > 0);
|
return &g_archHwiOps;
|
||||||
}
|
|
||||||
/* ****************************************************************************
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ****************************************************************************
|
/* ****************************************************************************
|
||||||
@@ -291,97 +162,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
|
|||||||
LOS_IntRestore(intSave);
|
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 FAULT_STATUS_REG_BIT 32
|
||||||
#define USGFAULT (1 << 18)
|
#define USGFAULT (1 << 18)
|
||||||
#define BUSFAULT (1 << 17)
|
#define BUSFAULT (1 << 17)
|
||||||
@@ -614,6 +394,11 @@ WEAK VOID __stack_chk_fail(VOID)
|
|||||||
__builtin_return_address(0));
|
__builtin_return_address(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WEAK VOID SysTick_Handler(VOID)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* ****************************************************************************
|
/* ****************************************************************************
|
||||||
Function : HalHwiInit
|
Function : HalHwiInit
|
||||||
Description : initialization of the hardware interrupt
|
Description : initialization of the hardware interrupt
|
||||||
@@ -625,23 +410,24 @@ 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 */
|
HWI_PROC_FUNC *hwiForm = (HWI_PROC_FUNC *)ArchGetHwiFrom();
|
||||||
g_hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */
|
hwiForm[0] = 0; /* [0] Top of Stack */
|
||||||
|
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;
|
hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
|
||||||
}
|
}
|
||||||
/* Exception handler register */
|
/* Exception handler register */
|
||||||
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
|
hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
|
||||||
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
|
hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
|
||||||
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
|
hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
|
||||||
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
|
hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
|
||||||
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
|
hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
|
||||||
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcSvcCall;
|
hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcSvcCall;
|
||||||
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
|
hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
|
||||||
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
|
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)hwiForm;
|
||||||
#endif
|
#endif
|
||||||
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
|
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
|
||||||
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
|
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
|
||||||
@@ -659,4 +445,3 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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-2023 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:
|
||||||
@@ -32,9 +32,7 @@
|
|||||||
#ifndef _LOS_ARCH_INTERRUPT_H
|
#ifndef _LOS_ARCH_INTERRUPT_H
|
||||||
#define _LOS_ARCH_INTERRUPT_H
|
#define _LOS_ARCH_INTERRUPT_H
|
||||||
|
|
||||||
#include "los_config.h"
|
#include "los_common_interrupt.h"
|
||||||
#include "los_compiler.h"
|
|
||||||
#include "los_interrupt.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
@@ -42,14 +40,6 @@ extern "C" {
|
|||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
#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
|
* @ingroup los_arch_interrupt
|
||||||
* Highest priority of a hardware interrupt.
|
* Highest priority of a hardware interrupt.
|
||||||
@@ -66,18 +56,17 @@ extern "C" {
|
|||||||
#define OS_HWI_PRIO_LOWEST 7
|
#define OS_HWI_PRIO_LOWEST 7
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_arch_interrupt
|
* @ingroup los_arch_interrupt
|
||||||
* Define the type of a hardware interrupt vector table function.
|
* AIRCR register priority group parameter .
|
||||||
*/
|
*/
|
||||||
typedef VOID (**HWI_VECTOR_FUNC)(void);
|
#define OS_NVIC_AIRCR_PRIGROUP 7
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_arch_interrupt
|
* @ingroup los_arch_interrupt
|
||||||
* Count of interrupts.
|
* Boot interrupt vector table.
|
||||||
*/
|
*/
|
||||||
extern UINT32 g_intCount;
|
extern UINT32 _BootVectors[];
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_arch_interrupt
|
* @ingroup los_arch_interrupt
|
||||||
@@ -91,18 +80,6 @@ extern UINT32 g_intCount;
|
|||||||
*/
|
*/
|
||||||
#define OS_VECTOR_CNT (OS_SYS_VECTOR_CNT + OS_HWI_MAX_NUM)
|
#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
|
* @ingroup los_arch_interrupt
|
||||||
* Hardware interrupt error code: Invalid interrupt number.
|
* Hardware interrupt error code: Invalid interrupt number.
|
||||||
@@ -110,7 +87,7 @@ extern UINT32 _BootVectors[];
|
|||||||
* Value: 0x02000900
|
* Value: 0x02000900
|
||||||
*
|
*
|
||||||
* Solution: Ensure that the interrupt number is valid.
|
* 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].
|
* The value range of the interrupt number applicable for a Cortex-M4 platformis [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)
|
||||||
|
|
||||||
@@ -186,6 +163,16 @@ extern UINT32 _BootVectors[];
|
|||||||
*/
|
*/
|
||||||
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
|
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Hardware interrupt error code: Invalid interrupt operation function.
|
||||||
|
*
|
||||||
|
* Value: 0x0200090c
|
||||||
|
*
|
||||||
|
* Solution: Set a valid interrupt operation function
|
||||||
|
*/
|
||||||
|
#define OS_ERRNO_HWI_OPS_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x0c)
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_arch_interrupt
|
* @ingroup los_arch_interrupt
|
||||||
* SysTick control and status register.
|
* SysTick control and status register.
|
||||||
@@ -312,20 +299,6 @@ extern UINT32 _BootVectors[];
|
|||||||
*/
|
*/
|
||||||
#define OS_EXC_SYS_TICK 15
|
#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
|
* @ingroup los_arch_interrupt
|
||||||
* @brief: Hardware interrupt entry function.
|
* @brief: Hardware interrupt entry function.
|
||||||
@@ -345,25 +318,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
|
|||||||
*/
|
*/
|
||||||
extern VOID HalInterrupt(VOID);
|
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
|
* @ingroup los_arch_interrupt
|
||||||
* @brief: Reset the vector table.
|
* @brief: Reset the vector table.
|
||||||
@@ -403,34 +357,20 @@ extern VOID Reset_Handler(VOID);
|
|||||||
*/
|
*/
|
||||||
extern VOID HalPendSV(VOID);
|
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_BUF_LEN 25
|
||||||
#define OS_EXC_MAX_NEST_DEPTH 1
|
#define OS_EXC_MAX_NEST_DEPTH 1
|
||||||
|
#define OS_EXC_FLAG_NO_FLOAT 0x10000000
|
||||||
|
|
||||||
#define OS_NVIC_SHCSR 0xE000ED24
|
#define OS_NVIC_SHCSR 0xE000ED24
|
||||||
#define OS_NVIC_CCR 0xE000ED14
|
#define OS_NVIC_CCR 0xE000ED14
|
||||||
|
|
||||||
#define OS_NVIC_INT_ENABLE_SIZE 0x20
|
#define OS_NVIC_INT_ENABLE_SIZE 0x20
|
||||||
#define OS_NVIC_INT_PRI_SIZE 0xF0
|
#define OS_NVIC_INT_PRI_SIZE 0xF0
|
||||||
#define OS_NVIC_EXCPRI_SIZE 0xC
|
#define OS_NVIC_EXCPRI_SIZE 0xC
|
||||||
#define OS_NVIC_INT_CTRL_SIZE 4
|
#define OS_NVIC_INT_CTRL_SIZE 4
|
||||||
#define OS_NVIC_SHCSR_SIZE 4
|
#define OS_NVIC_SHCSR_SIZE 4
|
||||||
|
|
||||||
#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
|
#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
|
||||||
#define OS_NVIC_INT_ACT_SIZE OS_NVIC_INT_ENABLE_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
|
* @ingroup los_exc
|
||||||
* the struct of register files
|
* the struct of register files
|
||||||
@@ -503,7 +443,6 @@ typedef struct TagExcContext {
|
|||||||
|
|
||||||
typedef VOID (*EXC_PROC_FUNC)(UINT32, 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 HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr);
|
||||||
|
|
||||||
VOID HalExcNMI(VOID);
|
VOID HalExcNMI(VOID);
|
||||||
VOID HalExcHardFault(VOID);
|
VOID HalExcHardFault(VOID);
|
||||||
VOID HalExcMemFault(VOID);
|
VOID HalExcMemFault(VOID);
|
||||||
@@ -667,10 +606,9 @@ typedef struct TagExcInfo {
|
|||||||
EXC_CONTEXT_S *context;
|
EXC_CONTEXT_S *context;
|
||||||
} ExcInfo;
|
} ExcInfo;
|
||||||
|
|
||||||
extern UINT32 g_curNestCount;
|
|
||||||
extern UINT32 g_intCount;
|
|
||||||
extern UINT8 g_uwExcTbl[32];
|
|
||||||
extern ExcInfo g_excInfo;
|
extern ExcInfo g_excInfo;
|
||||||
|
extern UINT32 g_curNestCount;
|
||||||
|
extern UINT8 g_uwExcTbl[32];
|
||||||
|
|
||||||
#define MAX_INT_INFO_SIZE (8 + 0x164)
|
#define MAX_INT_INFO_SIZE (8 + 0x164)
|
||||||
|
|
||||||
|
|||||||
@@ -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-2023 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:
|
||||||
@@ -29,12 +29,10 @@
|
|||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "los_interrupt.h"
|
|
||||||
#include "securec.h"
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include "los_arch_interrupt.h"
|
#include "securec.h"
|
||||||
#include "los_context.h"
|
#include "los_context.h"
|
||||||
#include "los_debug.h"
|
#include "los_arch_interrupt.h"
|
||||||
#include "los_hook.h"
|
#include "los_hook.h"
|
||||||
#include "los_task.h"
|
#include "los_task.h"
|
||||||
#include "los_sched.h"
|
#include "los_sched.h"
|
||||||
@@ -44,95 +42,6 @@
|
|||||||
#include "los_cpup.h"
|
#include "los_cpup.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
UINT32 g_intCount = 0;
|
|
||||||
|
|
||||||
#ifdef __ICCARM__
|
|
||||||
#pragma location = ".data.vector"
|
|
||||||
#pragma data_alignment = LOSCFG_ARCH_HWI_VECTOR_ALIGN
|
|
||||||
#elif defined(__CC_ARM) || defined(__GNUC__)
|
|
||||||
LITE_OS_SEC_VEC
|
|
||||||
#endif
|
|
||||||
/* *
|
|
||||||
* @ingroup los_hwi
|
|
||||||
* Hardware interrupt form mapping handling function array.
|
|
||||||
*/
|
|
||||||
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)
|
|
||||||
|
|
||||||
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
|
Function : HwiNumGet
|
||||||
Description : Get an interrupt number
|
Description : Get an interrupt number
|
||||||
@@ -147,100 +56,54 @@ STATIC UINT32 HwiNumGet(VOID)
|
|||||||
|
|
||||||
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
|
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
|
||||||
{
|
{
|
||||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
|
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
|
||||||
{
|
{
|
||||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
NVIC_DisableIRQ((IRQn_Type)hwiNum);
|
NVIC_DisableIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority)
|
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);
|
NVIC_SetPriority((IRQn_Type)hwiNum, priority);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
|
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
|
||||||
{
|
{
|
||||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
|
NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
|
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
|
||||||
{
|
{
|
||||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
|
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
HwiControllerOps g_archHwiOps = {
|
STATIC UINT32 HwiCreate(HWI_HANDLE_T hwiNum, HWI_PRIOR_T hwiPrio)
|
||||||
|
{
|
||||||
|
HwiSetPriority(hwiNum, hwiPrio);
|
||||||
|
HwiUnmask(hwiNum);
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC HwiControllerOps g_archHwiOps = {
|
||||||
.enableIrq = HwiUnmask,
|
.enableIrq = HwiUnmask,
|
||||||
.disableIrq = HwiMask,
|
.disableIrq = HwiMask,
|
||||||
.setIrqPriority = HwiSetPriority,
|
.setIrqPriority = HwiSetPriority,
|
||||||
.getCurIrqNum = HwiNumGet,
|
.getCurIrqNum = HwiNumGet,
|
||||||
.triggerIrq = HwiPending,
|
.triggerIrq = HwiPending,
|
||||||
.clearIrq = HwiClear,
|
.clearIrq = HwiClear,
|
||||||
|
.createIrq = HwiCreate,
|
||||||
};
|
};
|
||||||
|
|
||||||
inline UINT32 ArchIsIntActive(VOID)
|
HwiControllerOps *ArchIntOpsGet(VOID)
|
||||||
{
|
{
|
||||||
return (g_intCount > 0);
|
return &g_archHwiOps;
|
||||||
}
|
|
||||||
/* ****************************************************************************
|
|
||||||
Function : HalHwiDefaultHandler
|
|
||||||
Description : default handler of the hardware interrupt
|
|
||||||
Input : None
|
|
||||||
Output : None
|
|
||||||
Return : None
|
|
||||||
**************************************************************************** */
|
|
||||||
/*lint -e529*/
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ****************************************************************************
|
/* ****************************************************************************
|
||||||
@@ -299,97 +162,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
|
|||||||
LOS_IntRestore(intSave);
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
NVIC_DisableIRQ((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 FAULT_STATUS_REG_BIT 32
|
||||||
#define USGFAULT (1 << 18)
|
#define USGFAULT (1 << 18)
|
||||||
#define BUSFAULT (1 << 17)
|
#define BUSFAULT (1 << 17)
|
||||||
@@ -612,6 +384,11 @@ LITE_OS_SEC_TEXT_INIT VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, U
|
|||||||
ArchSysExit();
|
ArchSysExit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WEAK VOID SysTick_Handler(VOID)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* ****************************************************************************
|
/* ****************************************************************************
|
||||||
Function : HalHwiInit
|
Function : HalHwiInit
|
||||||
Description : initialization of the hardware interrupt
|
Description : initialization of the hardware interrupt
|
||||||
@@ -623,23 +400,24 @@ 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 */
|
HWI_PROC_FUNC *hwiForm = (HWI_PROC_FUNC *)ArchGetHwiFrom();
|
||||||
g_hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */
|
hwiForm[0] = 0; /* [0] Top of Stack */
|
||||||
|
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;
|
hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
|
||||||
}
|
}
|
||||||
/* Exception handler register */
|
/* Exception handler register */
|
||||||
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
|
hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
|
||||||
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
|
hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
|
||||||
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
|
hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
|
||||||
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
|
hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
|
||||||
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
|
hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
|
||||||
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcSvcCall;
|
hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcSvcCall;
|
||||||
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
|
hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
|
||||||
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
|
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)hwiForm;
|
||||||
#endif
|
#endif
|
||||||
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
|
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
|
||||||
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
|
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
|
||||||
@@ -657,4 +435,3 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
|
* Copyright (c) 2022-2023 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,9 +31,7 @@
|
|||||||
#ifndef _LOS_ARCH_INTERRUPT_H
|
#ifndef _LOS_ARCH_INTERRUPT_H
|
||||||
#define _LOS_ARCH_INTERRUPT_H
|
#define _LOS_ARCH_INTERRUPT_H
|
||||||
|
|
||||||
#include "los_config.h"
|
#include "los_common_interrupt.h"
|
||||||
#include "los_compiler.h"
|
|
||||||
#include "los_interrupt.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
@@ -41,14 +39,6 @@ extern "C" {
|
|||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
#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
|
* @ingroup los_arch_interrupt
|
||||||
* Highest priority of a hardware interrupt.
|
* Highest priority of a hardware interrupt.
|
||||||
@@ -65,18 +55,11 @@ extern "C" {
|
|||||||
#define OS_HWI_PRIO_LOWEST 7
|
#define OS_HWI_PRIO_LOWEST 7
|
||||||
#endif
|
#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
|
* @ingroup los_arch_interrupt
|
||||||
* Count of interrupts.
|
* AIRCR register priority group parameter .
|
||||||
*/
|
*/
|
||||||
extern UINT32 g_intCount;
|
#define OS_NVIC_AIRCR_PRIGROUP 7
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_arch_interrupt
|
* @ingroup los_arch_interrupt
|
||||||
@@ -90,12 +73,6 @@ extern UINT32 g_intCount;
|
|||||||
*/
|
*/
|
||||||
#define OS_VECTOR_CNT (OS_SYS_VECTOR_CNT + OS_HWI_MAX_NUM)
|
#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
|
* @ingroup los_arch_interrupt
|
||||||
* Hardware interrupt error code: Invalid interrupt number.
|
* Hardware interrupt error code: Invalid interrupt number.
|
||||||
@@ -103,7 +80,7 @@ extern UINT32 g_intCount;
|
|||||||
* Value: 0x02000900
|
* Value: 0x02000900
|
||||||
*
|
*
|
||||||
* Solution: Ensure that the interrupt number is valid.
|
* 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].
|
* The value range of the interrupt number applicable for a Cortex-M55 platformis [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)
|
||||||
|
|
||||||
@@ -154,7 +131,7 @@ extern UINT32 g_intCount;
|
|||||||
* Value: 0x02000905
|
* Value: 0x02000905
|
||||||
*
|
*
|
||||||
* Solution: Ensure that the interrupt priority is valid.
|
* Solution: Ensure that the interrupt priority is valid.
|
||||||
* The value range of the interrupt priority applicable for a Cortex-M33 platform is [0,15].
|
* The value range of the interrupt priority applicable for a Cortex-M55 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)
|
||||||
|
|
||||||
@@ -179,6 +156,16 @@ extern UINT32 g_intCount;
|
|||||||
*/
|
*/
|
||||||
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
|
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Hardware interrupt error code: Invalid interrupt operation function.
|
||||||
|
*
|
||||||
|
* Value: 0x0200090c
|
||||||
|
*
|
||||||
|
* Solution: Set a valid interrupt operation function
|
||||||
|
*/
|
||||||
|
#define OS_ERRNO_HWI_OPS_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x0c)
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_arch_interrupt
|
* @ingroup los_arch_interrupt
|
||||||
* SysTick control and status register.
|
* SysTick control and status register.
|
||||||
@@ -305,20 +292,6 @@ extern UINT32 g_intCount;
|
|||||||
*/
|
*/
|
||||||
#define OS_EXC_SYS_TICK 15
|
#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
|
* @ingroup los_arch_interrupt
|
||||||
* @brief: Hardware interrupt entry function.
|
* @brief: Hardware interrupt entry function.
|
||||||
@@ -338,25 +311,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
|
|||||||
*/
|
*/
|
||||||
extern VOID HalInterrupt(VOID);
|
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
|
* @ingroup los_arch_interrupt
|
||||||
* @brief: Reset the vector table.
|
* @brief: Reset the vector table.
|
||||||
@@ -396,34 +350,20 @@ extern VOID Reset_Handler(VOID);
|
|||||||
*/
|
*/
|
||||||
extern VOID HalPendSV(VOID);
|
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_BUF_LEN 25
|
||||||
#define OS_EXC_MAX_NEST_DEPTH 1
|
#define OS_EXC_MAX_NEST_DEPTH 1
|
||||||
|
#define OS_EXC_FLAG_NO_FLOAT 0x10000000
|
||||||
|
|
||||||
#define OS_NVIC_SHCSR 0xE000ED24
|
#define OS_NVIC_SHCSR 0xE000ED24
|
||||||
#define OS_NVIC_CCR 0xE000ED14
|
#define OS_NVIC_CCR 0xE000ED14
|
||||||
|
|
||||||
#define OS_NVIC_INT_ENABLE_SIZE 0x20
|
#define OS_NVIC_INT_ENABLE_SIZE 0x20
|
||||||
#define OS_NVIC_INT_PRI_SIZE 0xF0
|
#define OS_NVIC_INT_PRI_SIZE 0xF0
|
||||||
#define OS_NVIC_EXCPRI_SIZE 0xC
|
#define OS_NVIC_EXCPRI_SIZE 0xC
|
||||||
#define OS_NVIC_INT_CTRL_SIZE 4
|
#define OS_NVIC_INT_CTRL_SIZE 4
|
||||||
#define OS_NVIC_SHCSR_SIZE 4
|
#define OS_NVIC_SHCSR_SIZE 4
|
||||||
|
|
||||||
#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
|
#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
|
||||||
#define OS_NVIC_INT_ACT_SIZE OS_NVIC_INT_ENABLE_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
|
* @ingroup los_exc
|
||||||
* the struct of register files
|
* the struct of register files
|
||||||
@@ -496,7 +436,6 @@ typedef struct TagExcContext {
|
|||||||
|
|
||||||
typedef VOID (*EXC_PROC_FUNC)(UINT32, 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 HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr);
|
||||||
|
|
||||||
VOID HalExcNMI(VOID);
|
VOID HalExcNMI(VOID);
|
||||||
VOID HalExcHardFault(VOID);
|
VOID HalExcHardFault(VOID);
|
||||||
VOID HalExcMemFault(VOID);
|
VOID HalExcMemFault(VOID);
|
||||||
@@ -654,7 +593,7 @@ VOID HalHwiInit(VOID);
|
|||||||
* @ingroup los_exc
|
* @ingroup los_exc
|
||||||
* Exception information structure
|
* Exception information structure
|
||||||
*
|
*
|
||||||
* Description: Exception information saved when an exception is triggered on the Cortex-M33 platform.
|
* Description: Exception information saved when an exception is triggered on the Cortex-M55 platform.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
typedef struct TagExcInfo {
|
typedef struct TagExcInfo {
|
||||||
@@ -677,10 +616,9 @@ typedef struct TagExcInfo {
|
|||||||
EXC_CONTEXT_S *context;
|
EXC_CONTEXT_S *context;
|
||||||
} ExcInfo;
|
} ExcInfo;
|
||||||
|
|
||||||
extern UINT32 g_curNestCount;
|
|
||||||
extern UINT32 g_intCount;
|
|
||||||
extern UINT8 g_uwExcTbl[32];
|
|
||||||
extern ExcInfo g_excInfo;
|
extern ExcInfo g_excInfo;
|
||||||
|
extern UINT32 g_curNestCount;
|
||||||
|
extern UINT8 g_uwExcTbl[32];
|
||||||
|
|
||||||
#define MAX_INT_INFO_SIZE (8 + 0x164)
|
#define MAX_INT_INFO_SIZE (8 + 0x164)
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
|
* Copyright (c) 2022-2023 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:
|
||||||
@@ -27,12 +27,10 @@
|
|||||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
#include "los_interrupt.h"
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include "securec.h"
|
#include "securec.h"
|
||||||
#include "los_context.h"
|
#include "los_context.h"
|
||||||
#include "los_arch_interrupt.h"
|
#include "los_arch_interrupt.h"
|
||||||
#include "los_debug.h"
|
|
||||||
#include "los_hook.h"
|
#include "los_hook.h"
|
||||||
#include "los_task.h"
|
#include "los_task.h"
|
||||||
#include "los_sched.h"
|
#include "los_sched.h"
|
||||||
@@ -43,89 +41,6 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define DEF_HANDLER_START_INDEX 2
|
#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
|
Function : HwiNumGet
|
||||||
@@ -141,99 +56,54 @@ STATIC UINT32 HwiNumGet(VOID)
|
|||||||
|
|
||||||
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
|
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
|
||||||
{
|
{
|
||||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
|
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
|
||||||
{
|
{
|
||||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
NVIC_DisableIRQ((IRQn_Type)hwiNum);
|
NVIC_DisableIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority)
|
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);
|
NVIC_SetPriority((IRQn_Type)hwiNum, priority);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
|
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
|
||||||
{
|
{
|
||||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
|
NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
|
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
|
||||||
{
|
{
|
||||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
|
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
HwiControllerOps g_archHwiOps = {
|
STATIC UINT32 HwiCreate(HWI_HANDLE_T hwiNum, HWI_PRIOR_T hwiPrio)
|
||||||
|
{
|
||||||
|
HwiSetPriority(hwiNum, hwiPrio);
|
||||||
|
HwiUnmask(hwiNum);
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC HwiControllerOps g_archHwiOps = {
|
||||||
.enableIrq = HwiUnmask,
|
.enableIrq = HwiUnmask,
|
||||||
.disableIrq = HwiMask,
|
.disableIrq = HwiMask,
|
||||||
.setIrqPriority = HwiSetPriority,
|
.setIrqPriority = HwiSetPriority,
|
||||||
.getCurIrqNum = HwiNumGet,
|
.getCurIrqNum = HwiNumGet,
|
||||||
.triggerIrq = HwiPending,
|
.triggerIrq = HwiPending,
|
||||||
.clearIrq = HwiClear,
|
.clearIrq = HwiClear,
|
||||||
|
.createIrq = HwiCreate,
|
||||||
};
|
};
|
||||||
|
|
||||||
inline UINT32 ArchIsIntActive(VOID)
|
HwiControllerOps *ArchIntOpsGet(VOID)
|
||||||
{
|
{
|
||||||
return (g_intCount > 0);
|
return &g_archHwiOps;
|
||||||
}
|
|
||||||
/* ****************************************************************************
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ****************************************************************************
|
/* ****************************************************************************
|
||||||
@@ -292,97 +162,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
|
|||||||
LOS_IntRestore(intSave);
|
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 FAULT_STATUS_REG_BIT 32
|
||||||
#define USGFAULT (1 << 18)
|
#define USGFAULT (1 << 18)
|
||||||
#define BUSFAULT (1 << 17)
|
#define BUSFAULT (1 << 17)
|
||||||
@@ -609,6 +388,11 @@ LITE_OS_SEC_TEXT_INIT VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, U
|
|||||||
ArchSysExit();
|
ArchSysExit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WEAK VOID SysTick_Handler(VOID)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* ****************************************************************************
|
/* ****************************************************************************
|
||||||
Function : HalHwiInit
|
Function : HalHwiInit
|
||||||
Description : initialization of the hardware interrupt
|
Description : initialization of the hardware interrupt
|
||||||
@@ -620,23 +404,24 @@ 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 */
|
HWI_PROC_FUNC *hwiForm = (HWI_PROC_FUNC *)ArchGetHwiFrom();
|
||||||
g_hwiForm[1] = 0; /* [1] reset */
|
hwiForm[0] = 0; /* [0] Top of Stack */
|
||||||
|
hwiForm[1] = 0; /* [1] reset */
|
||||||
for (index = DEF_HANDLER_START_INDEX; index < OS_VECTOR_CNT; index++) {
|
for (index = DEF_HANDLER_START_INDEX; index < OS_VECTOR_CNT; index++) {
|
||||||
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
|
hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
|
||||||
}
|
}
|
||||||
/* Exception handler register */
|
/* Exception handler register */
|
||||||
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
|
hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
|
||||||
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
|
hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
|
||||||
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
|
hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
|
||||||
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
|
hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
|
||||||
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
|
hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
|
||||||
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
|
hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
|
||||||
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
|
hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
|
||||||
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)OsTickHandler;
|
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)hwiForm;
|
||||||
#endif
|
#endif
|
||||||
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
|
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
|
||||||
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
|
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
|
||||||
@@ -654,4 +439,3 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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-2023 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:
|
||||||
@@ -32,9 +32,7 @@
|
|||||||
#ifndef _LOS_ARCH_INTERRUPT_H
|
#ifndef _LOS_ARCH_INTERRUPT_H
|
||||||
#define _LOS_ARCH_INTERRUPT_H
|
#define _LOS_ARCH_INTERRUPT_H
|
||||||
|
|
||||||
#include "los_config.h"
|
#include "los_common_interrupt.h"
|
||||||
#include "los_compiler.h"
|
|
||||||
#include "los_interrupt.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
@@ -42,14 +40,6 @@ extern "C" {
|
|||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
#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
|
* @ingroup los_arch_interrupt
|
||||||
* Highest priority of a hardware interrupt.
|
* Highest priority of a hardware interrupt.
|
||||||
@@ -66,18 +56,17 @@ extern "C" {
|
|||||||
#define OS_HWI_PRIO_LOWEST 7
|
#define OS_HWI_PRIO_LOWEST 7
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_arch_interrupt
|
* @ingroup los_arch_interrupt
|
||||||
* Define the type of a hardware interrupt vector table function.
|
* AIRCR register priority group parameter .
|
||||||
*/
|
*/
|
||||||
typedef VOID (**HWI_VECTOR_FUNC)(void);
|
#define OS_NVIC_AIRCR_PRIGROUP 7
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_arch_interrupt
|
* @ingroup los_arch_interrupt
|
||||||
* Count of interrupts.
|
* Boot interrupt vector table.
|
||||||
*/
|
*/
|
||||||
extern UINT32 g_intCount;
|
extern UINT32 _BootVectors[];
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_arch_interrupt
|
* @ingroup los_arch_interrupt
|
||||||
@@ -91,18 +80,6 @@ extern UINT32 g_intCount;
|
|||||||
*/
|
*/
|
||||||
#define OS_VECTOR_CNT (OS_SYS_VECTOR_CNT + OS_HWI_MAX_NUM)
|
#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
|
* @ingroup los_arch_interrupt
|
||||||
* Hardware interrupt error code: Invalid interrupt number.
|
* Hardware interrupt error code: Invalid interrupt number.
|
||||||
@@ -110,7 +87,7 @@ extern UINT32 _BootVectors[];
|
|||||||
* Value: 0x02000900
|
* Value: 0x02000900
|
||||||
*
|
*
|
||||||
* Solution: Ensure that the interrupt number is valid.
|
* 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].
|
* 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)
|
||||||
|
|
||||||
@@ -186,6 +163,16 @@ extern UINT32 _BootVectors[];
|
|||||||
*/
|
*/
|
||||||
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
|
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Hardware interrupt error code: Invalid interrupt operation function.
|
||||||
|
*
|
||||||
|
* Value: 0x0200090c
|
||||||
|
*
|
||||||
|
* Solution: Set a valid interrupt operation function
|
||||||
|
*/
|
||||||
|
#define OS_ERRNO_HWI_OPS_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x0c)
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_arch_interrupt
|
* @ingroup los_arch_interrupt
|
||||||
* SysTick control and status register.
|
* SysTick control and status register.
|
||||||
@@ -312,20 +299,6 @@ extern UINT32 _BootVectors[];
|
|||||||
*/
|
*/
|
||||||
#define OS_EXC_SYS_TICK 15
|
#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
|
* @ingroup los_arch_interrupt
|
||||||
* @brief: Hardware interrupt entry function.
|
* @brief: Hardware interrupt entry function.
|
||||||
@@ -345,25 +318,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
|
|||||||
*/
|
*/
|
||||||
extern VOID HalInterrupt(VOID);
|
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
|
* @ingroup los_arch_interrupt
|
||||||
* @brief: Reset the vector table.
|
* @brief: Reset the vector table.
|
||||||
@@ -403,34 +357,20 @@ extern VOID Reset_Handler(VOID);
|
|||||||
*/
|
*/
|
||||||
extern VOID HalPendSV(VOID);
|
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_BUF_LEN 25
|
||||||
#define OS_EXC_MAX_NEST_DEPTH 1
|
#define OS_EXC_MAX_NEST_DEPTH 1
|
||||||
|
#define OS_EXC_FLAG_NO_FLOAT 0x10000000
|
||||||
|
|
||||||
#define OS_NVIC_SHCSR 0xE000ED24
|
#define OS_NVIC_SHCSR 0xE000ED24
|
||||||
#define OS_NVIC_CCR 0xE000ED14
|
#define OS_NVIC_CCR 0xE000ED14
|
||||||
|
|
||||||
#define OS_NVIC_INT_ENABLE_SIZE 0x20
|
#define OS_NVIC_INT_ENABLE_SIZE 0x20
|
||||||
#define OS_NVIC_INT_PRI_SIZE 0xF0
|
#define OS_NVIC_INT_PRI_SIZE 0xF0
|
||||||
#define OS_NVIC_EXCPRI_SIZE 0xC
|
#define OS_NVIC_EXCPRI_SIZE 0xC
|
||||||
#define OS_NVIC_INT_CTRL_SIZE 4
|
#define OS_NVIC_INT_CTRL_SIZE 4
|
||||||
#define OS_NVIC_SHCSR_SIZE 4
|
#define OS_NVIC_SHCSR_SIZE 4
|
||||||
|
|
||||||
#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
|
#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
|
||||||
#define OS_NVIC_INT_ACT_SIZE OS_NVIC_INT_ENABLE_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
|
* @ingroup los_exc
|
||||||
* the struct of register files
|
* the struct of register files
|
||||||
@@ -503,7 +443,6 @@ typedef struct TagExcContext {
|
|||||||
|
|
||||||
typedef VOID (*EXC_PROC_FUNC)(UINT32, 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 HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr);
|
||||||
|
|
||||||
VOID HalExcNMI(VOID);
|
VOID HalExcNMI(VOID);
|
||||||
VOID HalExcHardFault(VOID);
|
VOID HalExcHardFault(VOID);
|
||||||
VOID HalExcMemFault(VOID);
|
VOID HalExcMemFault(VOID);
|
||||||
@@ -644,7 +583,7 @@ VOID HalHwiInit(VOID);
|
|||||||
* @ingroup los_exc
|
* @ingroup los_exc
|
||||||
* Exception information structure
|
* Exception information structure
|
||||||
*
|
*
|
||||||
* Description: Exception information saved when an exception is triggered on the Cortex-M33 platform.
|
* Description: Exception information saved when an exception is triggered on the Cortex-M55 platform.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
typedef struct TagExcInfo {
|
typedef struct TagExcInfo {
|
||||||
@@ -667,10 +606,9 @@ typedef struct TagExcInfo {
|
|||||||
EXC_CONTEXT_S *context;
|
EXC_CONTEXT_S *context;
|
||||||
} ExcInfo;
|
} ExcInfo;
|
||||||
|
|
||||||
extern UINT32 g_curNestCount;
|
|
||||||
extern UINT32 g_intCount;
|
|
||||||
extern UINT8 g_uwExcTbl[32];
|
|
||||||
extern ExcInfo g_excInfo;
|
extern ExcInfo g_excInfo;
|
||||||
|
extern UINT32 g_curNestCount;
|
||||||
|
extern UINT8 g_uwExcTbl[32];
|
||||||
|
|
||||||
#define MAX_INT_INFO_SIZE (8 + 0x164)
|
#define MAX_INT_INFO_SIZE (8 + 0x164)
|
||||||
|
|
||||||
|
|||||||
@@ -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-2023 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:
|
||||||
@@ -28,99 +28,20 @@
|
|||||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
#include "los_interrupt.h"
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include "securec.h"
|
#include "securec.h"
|
||||||
#include "los_context.h"
|
#include "los_context.h"
|
||||||
#include "los_arch_interrupt.h"
|
#include "los_arch_interrupt.h"
|
||||||
#include "los_debug.h"
|
|
||||||
#include "los_hook.h"
|
|
||||||
#include "los_task.h"
|
#include "los_task.h"
|
||||||
#include "los_sched.h"
|
#include "los_sched.h"
|
||||||
#include "los_memory.h"
|
#include "los_memory.h"
|
||||||
#include "los_membox.h"
|
#include "los_membox.h"
|
||||||
|
#include "los_hook.h"
|
||||||
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
|
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
|
||||||
#include "los_cpup.h"
|
#include "los_cpup.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define DEF_HANDLER_START_INDEX 2
|
#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
|
|
||||||
|
|
||||||
/* ****************************************************************************
|
/* ****************************************************************************
|
||||||
Function : HwiNumGet
|
Function : HwiNumGet
|
||||||
@@ -136,100 +57,54 @@ STATIC UINT32 HwiNumGet(VOID)
|
|||||||
|
|
||||||
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
|
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
|
||||||
{
|
{
|
||||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
|
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
|
||||||
{
|
{
|
||||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
NVIC_DisableIRQ((IRQn_Type)hwiNum);
|
NVIC_DisableIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority)
|
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);
|
NVIC_SetPriority((IRQn_Type)hwiNum, priority);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
|
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
|
||||||
{
|
{
|
||||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
|
NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
|
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
|
||||||
{
|
{
|
||||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
|
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
HwiControllerOps g_archHwiOps = {
|
STATIC UINT32 HwiCreate(HWI_HANDLE_T hwiNum, HWI_PRIOR_T hwiPrio)
|
||||||
|
{
|
||||||
|
HwiSetPriority(hwiNum, hwiPrio);
|
||||||
|
HwiUnmask(hwiNum);
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC HwiControllerOps g_archHwiOps = {
|
||||||
.enableIrq = HwiUnmask,
|
.enableIrq = HwiUnmask,
|
||||||
.disableIrq = HwiMask,
|
.disableIrq = HwiMask,
|
||||||
.setIrqPriority = HwiSetPriority,
|
.setIrqPriority = HwiSetPriority,
|
||||||
.getCurIrqNum = HwiNumGet,
|
.getCurIrqNum = HwiNumGet,
|
||||||
.triggerIrq = HwiPending,
|
.triggerIrq = HwiPending,
|
||||||
.clearIrq = HwiClear,
|
.clearIrq = HwiClear,
|
||||||
|
.createIrq = HwiCreate,
|
||||||
};
|
};
|
||||||
|
|
||||||
inline UINT32 ArchIsIntActive(VOID)
|
HwiControllerOps *ArchIntOpsGet(VOID)
|
||||||
{
|
{
|
||||||
return (g_intCount > 0);
|
return &g_archHwiOps;
|
||||||
}
|
|
||||||
/* ****************************************************************************
|
|
||||||
Function : HalHwiDefaultHandler
|
|
||||||
Description : default handler of the hardware interrupt
|
|
||||||
Input : None
|
|
||||||
Output : None
|
|
||||||
Return : None
|
|
||||||
**************************************************************************** */
|
|
||||||
/*lint -e529*/
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ****************************************************************************
|
/* ****************************************************************************
|
||||||
@@ -288,97 +163,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
|
|||||||
LOS_IntRestore(intSave);
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
NVIC_DisableIRQ((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 FAULT_STATUS_REG_BIT 32
|
||||||
#define USGFAULT (1 << 18)
|
#define USGFAULT (1 << 18)
|
||||||
#define BUSFAULT (1 << 17)
|
#define BUSFAULT (1 << 17)
|
||||||
@@ -612,23 +396,24 @@ 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 */
|
HWI_PROC_FUNC *hwiForm = (HWI_PROC_FUNC *)ArchGetHwiFrom();
|
||||||
g_hwiForm[1] = 0; /* [1] reset */
|
hwiForm[0] = 0; /* [0] Top of Stack */
|
||||||
|
hwiForm[1] = 0; /* [1] reset */
|
||||||
for (index = DEF_HANDLER_START_INDEX; index < OS_VECTOR_CNT; index++) {
|
for (index = DEF_HANDLER_START_INDEX; index < OS_VECTOR_CNT; index++) {
|
||||||
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
|
hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
|
||||||
}
|
}
|
||||||
/* Exception handler register */
|
/* Exception handler register */
|
||||||
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
|
hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
|
||||||
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
|
hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
|
||||||
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
|
hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
|
||||||
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
|
hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
|
||||||
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
|
hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
|
||||||
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
|
hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
|
||||||
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
|
hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
|
||||||
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)OsTickHandler;
|
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)hwiForm;
|
||||||
#endif
|
#endif
|
||||||
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
|
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
|
||||||
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
|
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
|
||||||
@@ -646,4 +431,3 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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-2023 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:
|
||||||
@@ -29,12 +29,10 @@
|
|||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _LOS_EXC_H
|
#ifndef _LOS_ARCH_INTERRUPT_H
|
||||||
#define _LOS_EXC_H
|
#define _LOS_ARCH_INTERRUPT_H
|
||||||
|
|
||||||
#include "los_config.h"
|
#include "los_common_interrupt.h"
|
||||||
#include "los_compiler.h"
|
|
||||||
#include "los_interrupt.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
@@ -43,15 +41,7 @@ extern "C" {
|
|||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @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_hwi
|
|
||||||
* Highest priority of a hardware interrupt.
|
* Highest priority of a hardware interrupt.
|
||||||
*/
|
*/
|
||||||
#ifndef OS_HWI_PRIO_HIGHEST
|
#ifndef OS_HWI_PRIO_HIGHEST
|
||||||
@@ -59,63 +49,50 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Lowest priority of a hardware interrupt.
|
* Lowest priority of a hardware interrupt.
|
||||||
*/
|
*/
|
||||||
#ifndef OS_HWI_PRIO_LOWEST
|
#ifndef OS_HWI_PRIO_LOWEST
|
||||||
#define OS_HWI_PRIO_LOWEST 7
|
#define OS_HWI_PRIO_LOWEST 7
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Define the type of a hardware interrupt vector table function.
|
|
||||||
*/
|
|
||||||
typedef VOID (**HWI_VECTOR_FUNC)(void);
|
|
||||||
|
|
||||||
/* *
|
|
||||||
* @ingroup los_hwi
|
|
||||||
* Count of interrupts.
|
|
||||||
*/
|
|
||||||
extern UINT32 g_intCount;
|
|
||||||
|
|
||||||
/* *
|
|
||||||
* @ingroup los_hwi
|
|
||||||
* Count of M-Core system interrupt vector.
|
|
||||||
*/
|
|
||||||
#define OS_SYS_VECTOR_CNT 16
|
|
||||||
|
|
||||||
/* *
|
|
||||||
* @ingroup los_hwi
|
|
||||||
* Count of M-Core interrupt vector.
|
|
||||||
*/
|
|
||||||
#define OS_VECTOR_CNT (OS_SYS_VECTOR_CNT + OS_HWI_MAX_NUM)
|
|
||||||
|
|
||||||
/* *
|
|
||||||
* @ingroup los_hwi
|
|
||||||
* AIRCR register priority group parameter .
|
* AIRCR register priority group parameter .
|
||||||
*/
|
*/
|
||||||
#define OS_NVIC_AIRCR_PRIGROUP 7
|
#define OS_NVIC_AIRCR_PRIGROUP 7
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Boot interrupt vector table.
|
* Boot interrupt vector table.
|
||||||
*/
|
*/
|
||||||
extern UINT32 _BootVectors[];
|
extern UINT32 _BootVectors[];
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @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
|
||||||
* Hardware interrupt error code: Invalid interrupt number.
|
* Hardware interrupt error code: Invalid interrupt number.
|
||||||
*
|
*
|
||||||
* Value: 0x02000900
|
* Value: 0x02000900
|
||||||
*
|
*
|
||||||
* Solution: Ensure that the interrupt number is valid.
|
* 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].
|
* 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)
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Hardware interrupt error code: Null hardware interrupt handling function.
|
* Hardware interrupt error code: Null hardware interrupt handling function.
|
||||||
*
|
*
|
||||||
* Value: 0x02000901
|
* Value: 0x02000901
|
||||||
@@ -125,7 +102,7 @@ extern UINT32 _BootVectors[];
|
|||||||
#define OS_ERRNO_HWI_PROC_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x01)
|
#define OS_ERRNO_HWI_PROC_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x01)
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Hardware interrupt error code: Insufficient interrupt resources for hardware interrupt creation.
|
* Hardware interrupt error code: Insufficient interrupt resources for hardware interrupt creation.
|
||||||
*
|
*
|
||||||
* Value: 0x02000902
|
* Value: 0x02000902
|
||||||
@@ -135,7 +112,7 @@ extern UINT32 _BootVectors[];
|
|||||||
#define OS_ERRNO_HWI_CB_UNAVAILABLE LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x02)
|
#define OS_ERRNO_HWI_CB_UNAVAILABLE LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x02)
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Hardware interrupt error code: Insufficient memory for hardware interrupt initialization.
|
* Hardware interrupt error code: Insufficient memory for hardware interrupt initialization.
|
||||||
*
|
*
|
||||||
* Value: 0x02000903
|
* Value: 0x02000903
|
||||||
@@ -145,7 +122,7 @@ extern UINT32 _BootVectors[];
|
|||||||
#define OS_ERRNO_HWI_NO_MEMORY LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x03)
|
#define OS_ERRNO_HWI_NO_MEMORY LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x03)
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Hardware interrupt error code: The interrupt has already been created.
|
* Hardware interrupt error code: The interrupt has already been created.
|
||||||
*
|
*
|
||||||
* Value: 0x02000904
|
* Value: 0x02000904
|
||||||
@@ -155,7 +132,7 @@ extern UINT32 _BootVectors[];
|
|||||||
#define OS_ERRNO_HWI_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x04)
|
#define OS_ERRNO_HWI_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x04)
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Hardware interrupt error code: Invalid interrupt priority.
|
* Hardware interrupt error code: Invalid interrupt priority.
|
||||||
*
|
*
|
||||||
* Value: 0x02000905
|
* Value: 0x02000905
|
||||||
@@ -166,7 +143,7 @@ extern UINT32 _BootVectors[];
|
|||||||
#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)
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Hardware interrupt error code: Incorrect interrupt creation mode.
|
* Hardware interrupt error code: Incorrect interrupt creation mode.
|
||||||
*
|
*
|
||||||
* Value: 0x02000906
|
* Value: 0x02000906
|
||||||
@@ -177,7 +154,7 @@ extern UINT32 _BootVectors[];
|
|||||||
#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)
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Hardware interrupt error code: The interrupt has already been created as a fast interrupt.
|
* Hardware interrupt error code: The interrupt has already been created as a fast interrupt.
|
||||||
*
|
*
|
||||||
* Value: 0x02000907
|
* Value: 0x02000907
|
||||||
@@ -187,7 +164,17 @@ extern UINT32 _BootVectors[];
|
|||||||
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
|
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
|
* Hardware interrupt error code: Invalid interrupt operation function.
|
||||||
|
*
|
||||||
|
* Value: 0x0200090c
|
||||||
|
*
|
||||||
|
* Solution: Set a valid interrupt operation function
|
||||||
|
*/
|
||||||
|
#define OS_ERRNO_HWI_OPS_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x0c)
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
* SysTick control and status register.
|
* SysTick control and status register.
|
||||||
*/
|
*/
|
||||||
#define OS_SYSTICK_CONTROL_REG 0xE000E010
|
#define OS_SYSTICK_CONTROL_REG 0xE000E010
|
||||||
@@ -199,133 +186,119 @@ extern UINT32 _BootVectors[];
|
|||||||
#define OS_SYSTICK_CURRENT_REG 0xE000E018
|
#define OS_SYSTICK_CURRENT_REG 0xE000E018
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Interrupt Priority-Level Registers.
|
* Interrupt Priority-Level Registers.
|
||||||
*/
|
*/
|
||||||
#define OS_NVIC_PRI_BASE 0xE000E400
|
#define OS_NVIC_PRI_BASE 0xE000E400
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Interrupt enable register for 0-31.
|
* Interrupt enable register for 0-31.
|
||||||
*/
|
*/
|
||||||
#define OS_NVIC_SETENA_BASE 0xE000E100
|
#define OS_NVIC_SETENA_BASE 0xE000E100
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* interrupt pending register.
|
* interrupt pending register.
|
||||||
*/
|
*/
|
||||||
#define OS_NVIC_SETPEND_BASE 0xE000E200
|
#define OS_NVIC_SETPEND_BASE 0xE000E200
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Interrupt active register.
|
* Interrupt active register.
|
||||||
*/
|
*/
|
||||||
#define OS_NVIC_INT_ACT_BASE 0xE000E300
|
#define OS_NVIC_INT_ACT_BASE 0xE000E300
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Interrupt disable register for 0-31.
|
* Interrupt disable register for 0-31.
|
||||||
*/
|
*/
|
||||||
#define OS_NVIC_CLRENA_BASE 0xE000E180
|
#define OS_NVIC_CLRENA_BASE 0xE000E180
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Interrupt control and status register.
|
* Interrupt control and status register.
|
||||||
*/
|
*/
|
||||||
#define OS_NVIC_INT_CTRL 0xE000ED04
|
#define OS_NVIC_INT_CTRL 0xE000ED04
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Vector table offset register.
|
* Vector table offset register.
|
||||||
*/
|
*/
|
||||||
#define OS_NVIC_VTOR 0xE000ED08
|
#define OS_NVIC_VTOR 0xE000ED08
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Application interrupt and reset control register
|
* Application interrupt and reset control register
|
||||||
*/
|
*/
|
||||||
#define OS_NVIC_AIRCR 0xE000ED0C
|
#define OS_NVIC_AIRCR 0xE000ED0C
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* System exception priority register.
|
* System exception priority register.
|
||||||
*/
|
*/
|
||||||
#define OS_NVIC_EXCPRI_BASE 0xE000ED18
|
#define OS_NVIC_EXCPRI_BASE 0xE000ED18
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Interrupt No. 1 :reset.
|
* Interrupt No. 1 :reset.
|
||||||
*/
|
*/
|
||||||
#define OS_EXC_RESET 1
|
#define OS_EXC_RESET 1
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Interrupt No. 2 :Non-Maskable Interrupt.
|
* Interrupt No. 2 :Non-Maskable Interrupt.
|
||||||
*/
|
*/
|
||||||
#define OS_EXC_NMI 2
|
#define OS_EXC_NMI 2
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Interrupt No. 3 :(hard)fault.
|
* Interrupt No. 3 :(hard)fault.
|
||||||
*/
|
*/
|
||||||
#define OS_EXC_HARD_FAULT 3
|
#define OS_EXC_HARD_FAULT 3
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Interrupt No. 4 :MemManage fault.
|
* Interrupt No. 4 :MemManage fault.
|
||||||
*/
|
*/
|
||||||
#define OS_EXC_MPU_FAULT 4
|
#define OS_EXC_MPU_FAULT 4
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Interrupt No. 5 :Bus fault.
|
* Interrupt No. 5 :Bus fault.
|
||||||
*/
|
*/
|
||||||
#define OS_EXC_BUS_FAULT 5
|
#define OS_EXC_BUS_FAULT 5
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Interrupt No. 6 :Usage fault.
|
* Interrupt No. 6 :Usage fault.
|
||||||
*/
|
*/
|
||||||
#define OS_EXC_USAGE_FAULT 6
|
#define OS_EXC_USAGE_FAULT 6
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Interrupt No. 11 :SVCall.
|
* Interrupt No. 11 :SVCall.
|
||||||
*/
|
*/
|
||||||
#define OS_EXC_SVC_CALL 11
|
#define OS_EXC_SVC_CALL 11
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Interrupt No. 12 :Debug monitor.
|
* Interrupt No. 12 :Debug monitor.
|
||||||
*/
|
*/
|
||||||
#define OS_EXC_DBG_MONITOR 12
|
#define OS_EXC_DBG_MONITOR 12
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Interrupt No. 14 :PendSV.
|
* Interrupt No. 14 :PendSV.
|
||||||
*/
|
*/
|
||||||
#define OS_EXC_PEND_SV 14
|
#define OS_EXC_PEND_SV 14
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Interrupt No. 15 :SysTick.
|
* Interrupt No. 15 :SysTick.
|
||||||
*/
|
*/
|
||||||
#define OS_EXC_SYS_TICK 15
|
#define OS_EXC_SYS_TICK 15
|
||||||
|
|
||||||
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
|
|
||||||
/* *
|
|
||||||
* @ingroup los_hwi
|
|
||||||
* Set interrupt vector table.
|
|
||||||
*/
|
|
||||||
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg);
|
|
||||||
#else
|
|
||||||
/* *
|
|
||||||
* @ingroup los_hwi
|
|
||||||
* Set interrupt vector table.
|
|
||||||
*/
|
|
||||||
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_hwi
|
||||||
* @brief: Hardware interrupt entry function.
|
* @brief: Hardware interrupt entry function.
|
||||||
@@ -346,27 +319,7 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
|
|||||||
extern VOID HalInterrupt(VOID);
|
extern VOID HalInterrupt(VOID);
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @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_hwi.h: the header file that contains the API declaration.</li
|
|
||||||
></ul>
|
|
||||||
* @see None.
|
|
||||||
*/
|
|
||||||
extern VOID HalHwiDefaultHandler(VOID);
|
|
||||||
|
|
||||||
/* *
|
|
||||||
* @ingroup los_hwi
|
|
||||||
* @brief: Reset the vector table.
|
* @brief: Reset the vector table.
|
||||||
*
|
*
|
||||||
* @par Description:
|
* @par Description:
|
||||||
@@ -379,13 +332,13 @@ extern VOID HalHwiDefaultHandler(VOID);
|
|||||||
*
|
*
|
||||||
* @retval:None.
|
* @retval:None.
|
||||||
* @par Dependency:
|
* @par Dependency:
|
||||||
* <ul><li>los_hwi.h: the header file that contains the API declaration.</li></ul>
|
* <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
|
||||||
* @see None.
|
* @see None.
|
||||||
*/
|
*/
|
||||||
extern VOID Reset_Handler(VOID);
|
extern VOID Reset_Handler(VOID);
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* @brief: Pended System Call.
|
* @brief: Pended System Call.
|
||||||
*
|
*
|
||||||
* @par Description:
|
* @par Description:
|
||||||
@@ -399,39 +352,25 @@ extern VOID Reset_Handler(VOID);
|
|||||||
*
|
*
|
||||||
* @retval:None.
|
* @retval:None.
|
||||||
* @par Dependency:
|
* @par Dependency:
|
||||||
* <ul><li>los_hwi.h: the header file that contains the API declaration.</li></ul>
|
* <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
|
||||||
* @see None.
|
* @see None.
|
||||||
*/
|
*/
|
||||||
extern VOID HalPendSV(VOID);
|
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_BUF_LEN 25
|
||||||
#define OS_EXC_MAX_NEST_DEPTH 1
|
#define OS_EXC_MAX_NEST_DEPTH 1
|
||||||
|
#define OS_EXC_FLAG_NO_FLOAT 0x10000000
|
||||||
|
|
||||||
#define OS_NVIC_SHCSR 0xE000ED24
|
#define OS_NVIC_SHCSR 0xE000ED24
|
||||||
#define OS_NVIC_CCR 0xE000ED14
|
#define OS_NVIC_CCR 0xE000ED14
|
||||||
|
|
||||||
#define OS_NVIC_INT_ENABLE_SIZE 0x20
|
#define OS_NVIC_INT_ENABLE_SIZE 0x20
|
||||||
#define OS_NVIC_INT_PRI_SIZE 0xF0
|
#define OS_NVIC_INT_PRI_SIZE 0xF0
|
||||||
#define OS_NVIC_EXCPRI_SIZE 0xC
|
#define OS_NVIC_EXCPRI_SIZE 0xC
|
||||||
#define OS_NVIC_INT_CTRL_SIZE 4
|
#define OS_NVIC_INT_CTRL_SIZE 4
|
||||||
#define OS_NVIC_SHCSR_SIZE 4
|
#define OS_NVIC_SHCSR_SIZE 4
|
||||||
|
|
||||||
#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
|
#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
|
||||||
#define OS_NVIC_INT_ACT_SIZE OS_NVIC_INT_ENABLE_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
|
* @ingroup los_exc
|
||||||
* the struct of register files
|
* the struct of register files
|
||||||
@@ -500,11 +439,10 @@ typedef struct TagExcContext {
|
|||||||
UINT32 FPSCR;
|
UINT32 FPSCR;
|
||||||
UINT32 NO_NAME;
|
UINT32 NO_NAME;
|
||||||
#endif
|
#endif
|
||||||
}EXC_CONTEXT_S;
|
} EXC_CONTEXT_S;
|
||||||
|
|
||||||
typedef VOID (*EXC_PROC_FUNC)(UINT32, 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 HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr);
|
||||||
|
|
||||||
VOID HalExcNMI(VOID);
|
VOID HalExcNMI(VOID);
|
||||||
VOID HalExcHardFault(VOID);
|
VOID HalExcHardFault(VOID);
|
||||||
VOID HalExcMemFault(VOID);
|
VOID HalExcMemFault(VOID);
|
||||||
@@ -645,7 +583,7 @@ VOID HalHwiInit(VOID);
|
|||||||
* @ingroup los_exc
|
* @ingroup los_exc
|
||||||
* Exception information structure
|
* Exception information structure
|
||||||
*
|
*
|
||||||
* Description: Exception information saved when an exception is triggered on the Cortex-M4 platform.
|
* Description: Exception information saved when an exception is triggered on the Cortex-M55 platform.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
typedef struct TagExcInfo {
|
typedef struct TagExcInfo {
|
||||||
@@ -668,10 +606,9 @@ typedef struct TagExcInfo {
|
|||||||
EXC_CONTEXT_S *context;
|
EXC_CONTEXT_S *context;
|
||||||
} ExcInfo;
|
} ExcInfo;
|
||||||
|
|
||||||
extern UINT32 g_curNestCount;
|
|
||||||
extern UINT32 g_intCount;
|
|
||||||
extern UINT8 g_uwExcTbl[32];
|
|
||||||
extern ExcInfo g_excInfo;
|
extern ExcInfo g_excInfo;
|
||||||
|
extern UINT32 g_curNestCount;
|
||||||
|
extern UINT8 g_uwExcTbl[32];
|
||||||
|
|
||||||
#define MAX_INT_INFO_SIZE (8 + 0x164)
|
#define MAX_INT_INFO_SIZE (8 + 0x164)
|
||||||
|
|
||||||
@@ -681,4 +618,4 @@ extern ExcInfo g_excInfo;
|
|||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
#endif /* _LOS_EXC_H */
|
#endif /* _LOS_ARCH_INTERRUPT_H */
|
||||||
|
|||||||
@@ -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-2023 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:
|
||||||
@@ -29,12 +29,10 @@
|
|||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "los_interrupt.h"
|
|
||||||
#include "securec.h"
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include "los_arch_interrupt.h"
|
#include "securec.h"
|
||||||
#include "los_context.h"
|
#include "los_context.h"
|
||||||
#include "los_debug.h"
|
#include "los_arch_interrupt.h"
|
||||||
#include "los_hook.h"
|
#include "los_hook.h"
|
||||||
#include "los_task.h"
|
#include "los_task.h"
|
||||||
#include "los_sched.h"
|
#include "los_sched.h"
|
||||||
@@ -44,93 +42,6 @@
|
|||||||
#include "los_cpup.h"
|
#include "los_cpup.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*lint -save -e40 -e522 -e533*/
|
|
||||||
UINT32 g_intCount = 0;
|
|
||||||
|
|
||||||
/*lint -restore*/
|
|
||||||
#pragma location = ".data.vector"
|
|
||||||
#pragma data_alignment = LOSCFG_ARCH_HWI_VECTOR_ALIGN
|
|
||||||
/* *
|
|
||||||
* @ingroup los_hwi
|
|
||||||
* hardware interrupt form mapping handling function array.
|
|
||||||
*/
|
|
||||||
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)
|
|
||||||
|
|
||||||
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
|
Function : HwiNumGet
|
||||||
Description : Get an interrupt number
|
Description : Get an interrupt number
|
||||||
@@ -145,100 +56,54 @@ STATIC UINT32 HwiNumGet(VOID)
|
|||||||
|
|
||||||
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
|
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
|
||||||
{
|
{
|
||||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
|
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
|
||||||
{
|
{
|
||||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
NVIC_DisableIRQ((IRQn_Type)hwiNum);
|
NVIC_DisableIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority)
|
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);
|
NVIC_SetPriority((IRQn_Type)hwiNum, priority);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
|
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
|
||||||
{
|
{
|
||||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
|
NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
|
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
|
||||||
{
|
{
|
||||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
|
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
HwiControllerOps g_archHwiOps = {
|
STATIC UINT32 HwiCreate(HWI_HANDLE_T hwiNum, HWI_PRIOR_T hwiPrio)
|
||||||
|
{
|
||||||
|
HwiSetPriority(hwiNum, hwiPrio);
|
||||||
|
HwiUnmask(hwiNum);
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC HwiControllerOps g_archHwiOps = {
|
||||||
.enableIrq = HwiUnmask,
|
.enableIrq = HwiUnmask,
|
||||||
.disableIrq = HwiMask,
|
.disableIrq = HwiMask,
|
||||||
.setIrqPriority = HwiSetPriority,
|
.setIrqPriority = HwiSetPriority,
|
||||||
.getCurIrqNum = HwiNumGet,
|
.getCurIrqNum = HwiNumGet,
|
||||||
.triggerIrq = HwiPending,
|
.triggerIrq = HwiPending,
|
||||||
.clearIrq = HwiClear,
|
.clearIrq = HwiClear,
|
||||||
|
.createIrq = HwiCreate,
|
||||||
};
|
};
|
||||||
|
|
||||||
inline UINT32 ArchIsIntActive(VOID)
|
HwiControllerOps *ArchIntOpsGet(VOID)
|
||||||
{
|
{
|
||||||
return (g_intCount > 0);
|
return &g_archHwiOps;
|
||||||
}
|
|
||||||
/* ****************************************************************************
|
|
||||||
Function : HalHwiDefaultHandler
|
|
||||||
Description : default handler of the hardware interrupt
|
|
||||||
Input : None
|
|
||||||
Output : None
|
|
||||||
Return : None
|
|
||||||
**************************************************************************** */
|
|
||||||
/*lint -e529*/
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ****************************************************************************
|
/* ****************************************************************************
|
||||||
@@ -299,97 +164,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
|
|||||||
LOS_IntRestore(intSave);
|
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;
|
|
||||||
UINTPTR 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
NVIC_DisableIRQ((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 FAULT_STATUS_REG_BIT 32
|
||||||
#define USGFAULT (1 << 18)
|
#define USGFAULT (1 << 18)
|
||||||
#define BUSFAULT (1 << 17)
|
#define BUSFAULT (1 << 17)
|
||||||
@@ -611,6 +385,11 @@ LITE_OS_SEC_TEXT_INIT VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, U
|
|||||||
ArchSysExit();
|
ArchSysExit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WEAK VOID SysTick_Handler(VOID)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* ****************************************************************************
|
/* ****************************************************************************
|
||||||
Function : HalHwiInit
|
Function : HalHwiInit
|
||||||
Description : initialization of the hardware interrupt
|
Description : initialization of the hardware interrupt
|
||||||
@@ -622,23 +401,24 @@ 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 */
|
HWI_PROC_FUNC *hwiForm = (HWI_PROC_FUNC *)ArchGetHwiFrom();
|
||||||
g_hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */
|
hwiForm[0] = 0; /* [0] Top of Stack */
|
||||||
|
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;
|
hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
|
||||||
}
|
}
|
||||||
/* Exception handler register */
|
/* Exception handler register */
|
||||||
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
|
hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
|
||||||
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
|
hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
|
||||||
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
|
hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
|
||||||
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
|
hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
|
||||||
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
|
hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
|
||||||
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
|
hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
|
||||||
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
|
hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
|
||||||
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
|
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)hwiForm;
|
||||||
#endif
|
#endif
|
||||||
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
|
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
|
||||||
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
|
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
|
||||||
@@ -651,4 +431,3 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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-2023 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:
|
||||||
@@ -32,15 +32,21 @@ import("//kernel/liteos_m/liteos.gni")
|
|||||||
module_name = "arch"
|
module_name = "arch"
|
||||||
kernel_module(module_name) {
|
kernel_module(module_name) {
|
||||||
sources = [
|
sources = [
|
||||||
"los_context.c",
|
"non_secure/los_context.c",
|
||||||
"los_dispatch.S",
|
"non_secure/los_dispatch.S",
|
||||||
"los_exc.S",
|
"non_secure/los_exc.S",
|
||||||
"los_interrupt.c",
|
"non_secure/los_interrupt.c",
|
||||||
"los_timer.c",
|
"non_secure/los_timer.c",
|
||||||
|
"non_secure/los_trustzone.c",
|
||||||
]
|
]
|
||||||
configs += [ "$LITEOSTOPDIR:warn_config" ]
|
configs += [ "$LITEOSTOPDIR:warn_config" ]
|
||||||
|
|
||||||
|
include_dirs = [
|
||||||
|
"non_secure",
|
||||||
|
"secure",
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
config("public") {
|
config("public") {
|
||||||
include_dirs = [ "." ]
|
include_dirs = [ "non_secure" ]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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-2023 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:
|
||||||
@@ -29,12 +29,10 @@
|
|||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _LOS_EXC_H
|
#ifndef _LOS_ARCH_INTERRUPT_H
|
||||||
#define _LOS_EXC_H
|
#define _LOS_ARCH_INTERRUPT_H
|
||||||
|
|
||||||
#include "los_config.h"
|
#include "los_common_interrupt.h"
|
||||||
#include "los_compiler.h"
|
|
||||||
#include "los_interrupt.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
@@ -43,15 +41,7 @@ extern "C" {
|
|||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @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_hwi
|
|
||||||
* Highest priority of a hardware interrupt.
|
* Highest priority of a hardware interrupt.
|
||||||
*/
|
*/
|
||||||
#ifndef OS_HWI_PRIO_HIGHEST
|
#ifndef OS_HWI_PRIO_HIGHEST
|
||||||
@@ -59,63 +49,50 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Lowest priority of a hardware interrupt.
|
* Lowest priority of a hardware interrupt.
|
||||||
*/
|
*/
|
||||||
#ifndef OS_HWI_PRIO_LOWEST
|
#ifndef OS_HWI_PRIO_LOWEST
|
||||||
#define OS_HWI_PRIO_LOWEST 7
|
#define OS_HWI_PRIO_LOWEST 7
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Define the type of a hardware interrupt vector table function.
|
|
||||||
*/
|
|
||||||
typedef VOID (**HWI_VECTOR_FUNC)(void);
|
|
||||||
|
|
||||||
/* *
|
|
||||||
* @ingroup los_hwi
|
|
||||||
* Count of interrupts.
|
|
||||||
*/
|
|
||||||
extern UINT32 g_intCount;
|
|
||||||
|
|
||||||
/* *
|
|
||||||
* @ingroup los_hwi
|
|
||||||
* Count of M-Core system interrupt vector.
|
|
||||||
*/
|
|
||||||
#define OS_SYS_VECTOR_CNT 16
|
|
||||||
|
|
||||||
/* *
|
|
||||||
* @ingroup los_hwi
|
|
||||||
* Count of M-Core interrupt vector.
|
|
||||||
*/
|
|
||||||
#define OS_VECTOR_CNT (OS_SYS_VECTOR_CNT + OS_HWI_MAX_NUM)
|
|
||||||
|
|
||||||
/* *
|
|
||||||
* @ingroup los_hwi
|
|
||||||
* AIRCR register priority group parameter .
|
* AIRCR register priority group parameter .
|
||||||
*/
|
*/
|
||||||
#define OS_NVIC_AIRCR_PRIGROUP 7
|
#define OS_NVIC_AIRCR_PRIGROUP 7
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Boot interrupt vector table.
|
* Boot interrupt vector table.
|
||||||
*/
|
*/
|
||||||
extern UINT32 _BootVectors[];
|
extern UINT32 _BootVectors[];
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @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
|
||||||
* Hardware interrupt error code: Invalid interrupt number.
|
* Hardware interrupt error code: Invalid interrupt number.
|
||||||
*
|
*
|
||||||
* Value: 0x02000900
|
* Value: 0x02000900
|
||||||
*
|
*
|
||||||
* Solution: Ensure that the interrupt number is valid.
|
* 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].
|
* 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)
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Hardware interrupt error code: Null hardware interrupt handling function.
|
* Hardware interrupt error code: Null hardware interrupt handling function.
|
||||||
*
|
*
|
||||||
* Value: 0x02000901
|
* Value: 0x02000901
|
||||||
@@ -125,7 +102,7 @@ extern UINT32 _BootVectors[];
|
|||||||
#define OS_ERRNO_HWI_PROC_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x01)
|
#define OS_ERRNO_HWI_PROC_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x01)
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Hardware interrupt error code: Insufficient interrupt resources for hardware interrupt creation.
|
* Hardware interrupt error code: Insufficient interrupt resources for hardware interrupt creation.
|
||||||
*
|
*
|
||||||
* Value: 0x02000902
|
* Value: 0x02000902
|
||||||
@@ -135,7 +112,7 @@ extern UINT32 _BootVectors[];
|
|||||||
#define OS_ERRNO_HWI_CB_UNAVAILABLE LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x02)
|
#define OS_ERRNO_HWI_CB_UNAVAILABLE LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x02)
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Hardware interrupt error code: Insufficient memory for hardware interrupt initialization.
|
* Hardware interrupt error code: Insufficient memory for hardware interrupt initialization.
|
||||||
*
|
*
|
||||||
* Value: 0x02000903
|
* Value: 0x02000903
|
||||||
@@ -145,7 +122,7 @@ extern UINT32 _BootVectors[];
|
|||||||
#define OS_ERRNO_HWI_NO_MEMORY LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x03)
|
#define OS_ERRNO_HWI_NO_MEMORY LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x03)
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Hardware interrupt error code: The interrupt has already been created.
|
* Hardware interrupt error code: The interrupt has already been created.
|
||||||
*
|
*
|
||||||
* Value: 0x02000904
|
* Value: 0x02000904
|
||||||
@@ -155,7 +132,7 @@ extern UINT32 _BootVectors[];
|
|||||||
#define OS_ERRNO_HWI_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x04)
|
#define OS_ERRNO_HWI_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x04)
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Hardware interrupt error code: Invalid interrupt priority.
|
* Hardware interrupt error code: Invalid interrupt priority.
|
||||||
*
|
*
|
||||||
* Value: 0x02000905
|
* Value: 0x02000905
|
||||||
@@ -166,7 +143,7 @@ extern UINT32 _BootVectors[];
|
|||||||
#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)
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Hardware interrupt error code: Incorrect interrupt creation mode.
|
* Hardware interrupt error code: Incorrect interrupt creation mode.
|
||||||
*
|
*
|
||||||
* Value: 0x02000906
|
* Value: 0x02000906
|
||||||
@@ -177,7 +154,7 @@ extern UINT32 _BootVectors[];
|
|||||||
#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)
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Hardware interrupt error code: The interrupt has already been created as a fast interrupt.
|
* Hardware interrupt error code: The interrupt has already been created as a fast interrupt.
|
||||||
*
|
*
|
||||||
* Value: 0x02000907
|
* Value: 0x02000907
|
||||||
@@ -187,7 +164,17 @@ extern UINT32 _BootVectors[];
|
|||||||
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
|
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
|
* Hardware interrupt error code: Invalid interrupt operation function.
|
||||||
|
*
|
||||||
|
* Value: 0x0200090c
|
||||||
|
*
|
||||||
|
* Solution: Set a valid interrupt operation function
|
||||||
|
*/
|
||||||
|
#define OS_ERRNO_HWI_OPS_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x0c)
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
* SysTick control and status register.
|
* SysTick control and status register.
|
||||||
*/
|
*/
|
||||||
#define OS_SYSTICK_CONTROL_REG 0xE000E010
|
#define OS_SYSTICK_CONTROL_REG 0xE000E010
|
||||||
@@ -199,133 +186,119 @@ extern UINT32 _BootVectors[];
|
|||||||
#define OS_SYSTICK_CURRENT_REG 0xE000E018
|
#define OS_SYSTICK_CURRENT_REG 0xE000E018
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Interrupt Priority-Level Registers.
|
* Interrupt Priority-Level Registers.
|
||||||
*/
|
*/
|
||||||
#define OS_NVIC_PRI_BASE 0xE000E400
|
#define OS_NVIC_PRI_BASE 0xE000E400
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Interrupt enable register for 0-31.
|
* Interrupt enable register for 0-31.
|
||||||
*/
|
*/
|
||||||
#define OS_NVIC_SETENA_BASE 0xE000E100
|
#define OS_NVIC_SETENA_BASE 0xE000E100
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* interrupt pending register.
|
* interrupt pending register.
|
||||||
*/
|
*/
|
||||||
#define OS_NVIC_SETPEND_BASE 0xE000E200
|
#define OS_NVIC_SETPEND_BASE 0xE000E200
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Interrupt active register.
|
* Interrupt active register.
|
||||||
*/
|
*/
|
||||||
#define OS_NVIC_INT_ACT_BASE 0xE000E300
|
#define OS_NVIC_INT_ACT_BASE 0xE000E300
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Interrupt disable register for 0-31.
|
* Interrupt disable register for 0-31.
|
||||||
*/
|
*/
|
||||||
#define OS_NVIC_CLRENA_BASE 0xE000E180
|
#define OS_NVIC_CLRENA_BASE 0xE000E180
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Interrupt control and status register.
|
* Interrupt control and status register.
|
||||||
*/
|
*/
|
||||||
#define OS_NVIC_INT_CTRL 0xE000ED04
|
#define OS_NVIC_INT_CTRL 0xE000ED04
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Vector table offset register.
|
* Vector table offset register.
|
||||||
*/
|
*/
|
||||||
#define OS_NVIC_VTOR 0xE000ED08
|
#define OS_NVIC_VTOR 0xE000ED08
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Application interrupt and reset control register
|
* Application interrupt and reset control register
|
||||||
*/
|
*/
|
||||||
#define OS_NVIC_AIRCR 0xE000ED0C
|
#define OS_NVIC_AIRCR 0xE000ED0C
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* System exception priority register.
|
* System exception priority register.
|
||||||
*/
|
*/
|
||||||
#define OS_NVIC_EXCPRI_BASE 0xE000ED18
|
#define OS_NVIC_EXCPRI_BASE 0xE000ED18
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Interrupt No. 1 :reset.
|
* Interrupt No. 1 :reset.
|
||||||
*/
|
*/
|
||||||
#define OS_EXC_RESET 1
|
#define OS_EXC_RESET 1
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Interrupt No. 2 :Non-Maskable Interrupt.
|
* Interrupt No. 2 :Non-Maskable Interrupt.
|
||||||
*/
|
*/
|
||||||
#define OS_EXC_NMI 2
|
#define OS_EXC_NMI 2
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Interrupt No. 3 :(hard)fault.
|
* Interrupt No. 3 :(hard)fault.
|
||||||
*/
|
*/
|
||||||
#define OS_EXC_HARD_FAULT 3
|
#define OS_EXC_HARD_FAULT 3
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Interrupt No. 4 :MemManage fault.
|
* Interrupt No. 4 :MemManage fault.
|
||||||
*/
|
*/
|
||||||
#define OS_EXC_MPU_FAULT 4
|
#define OS_EXC_MPU_FAULT 4
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Interrupt No. 5 :Bus fault.
|
* Interrupt No. 5 :Bus fault.
|
||||||
*/
|
*/
|
||||||
#define OS_EXC_BUS_FAULT 5
|
#define OS_EXC_BUS_FAULT 5
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Interrupt No. 6 :Usage fault.
|
* Interrupt No. 6 :Usage fault.
|
||||||
*/
|
*/
|
||||||
#define OS_EXC_USAGE_FAULT 6
|
#define OS_EXC_USAGE_FAULT 6
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Interrupt No. 11 :SVCall.
|
* Interrupt No. 11 :SVCall.
|
||||||
*/
|
*/
|
||||||
#define OS_EXC_SVC_CALL 11
|
#define OS_EXC_SVC_CALL 11
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Interrupt No. 12 :Debug monitor.
|
* Interrupt No. 12 :Debug monitor.
|
||||||
*/
|
*/
|
||||||
#define OS_EXC_DBG_MONITOR 12
|
#define OS_EXC_DBG_MONITOR 12
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Interrupt No. 14 :PendSV.
|
* Interrupt No. 14 :PendSV.
|
||||||
*/
|
*/
|
||||||
#define OS_EXC_PEND_SV 14
|
#define OS_EXC_PEND_SV 14
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* Interrupt No. 15 :SysTick.
|
* Interrupt No. 15 :SysTick.
|
||||||
*/
|
*/
|
||||||
#define OS_EXC_SYS_TICK 15
|
#define OS_EXC_SYS_TICK 15
|
||||||
|
|
||||||
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
|
|
||||||
/* *
|
|
||||||
* @ingroup los_hwi
|
|
||||||
* Set interrupt vector table.
|
|
||||||
*/
|
|
||||||
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg);
|
|
||||||
#else
|
|
||||||
/* *
|
|
||||||
* @ingroup los_hwi
|
|
||||||
* Set interrupt vector table.
|
|
||||||
*/
|
|
||||||
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_hwi
|
||||||
* @brief: Hardware interrupt entry function.
|
* @brief: Hardware interrupt entry function.
|
||||||
@@ -346,27 +319,7 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
|
|||||||
extern VOID HalInterrupt(VOID);
|
extern VOID HalInterrupt(VOID);
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @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_hwi.h: the header file that contains the API declaration.</li
|
|
||||||
></ul>
|
|
||||||
* @see None.
|
|
||||||
*/
|
|
||||||
extern VOID HalHwiDefaultHandler(VOID);
|
|
||||||
|
|
||||||
/* *
|
|
||||||
* @ingroup los_hwi
|
|
||||||
* @brief: Reset the vector table.
|
* @brief: Reset the vector table.
|
||||||
*
|
*
|
||||||
* @par Description:
|
* @par Description:
|
||||||
@@ -379,13 +332,13 @@ extern VOID HalHwiDefaultHandler(VOID);
|
|||||||
*
|
*
|
||||||
* @retval:None.
|
* @retval:None.
|
||||||
* @par Dependency:
|
* @par Dependency:
|
||||||
* <ul><li>los_hwi.h: the header file that contains the API declaration.</li></ul>
|
* <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
|
||||||
* @see None.
|
* @see None.
|
||||||
*/
|
*/
|
||||||
extern VOID Reset_Handler(VOID);
|
extern VOID Reset_Handler(VOID);
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_arch_interrupt
|
||||||
* @brief: Pended System Call.
|
* @brief: Pended System Call.
|
||||||
*
|
*
|
||||||
* @par Description:
|
* @par Description:
|
||||||
@@ -399,39 +352,25 @@ extern VOID Reset_Handler(VOID);
|
|||||||
*
|
*
|
||||||
* @retval:None.
|
* @retval:None.
|
||||||
* @par Dependency:
|
* @par Dependency:
|
||||||
* <ul><li>los_hwi.h: the header file that contains the API declaration.</li></ul>
|
* <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
|
||||||
* @see None.
|
* @see None.
|
||||||
*/
|
*/
|
||||||
extern VOID HalPendSV(VOID);
|
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_BUF_LEN 25
|
||||||
#define OS_EXC_MAX_NEST_DEPTH 1
|
#define OS_EXC_MAX_NEST_DEPTH 1
|
||||||
|
#define OS_EXC_FLAG_NO_FLOAT 0x10000000
|
||||||
|
|
||||||
#define OS_NVIC_SHCSR 0xE000ED24
|
#define OS_NVIC_SHCSR 0xE000ED24
|
||||||
#define OS_NVIC_CCR 0xE000ED14
|
#define OS_NVIC_CCR 0xE000ED14
|
||||||
|
|
||||||
#define OS_NVIC_INT_ENABLE_SIZE 0x20
|
#define OS_NVIC_INT_ENABLE_SIZE 0x20
|
||||||
#define OS_NVIC_INT_PRI_SIZE 0xF0
|
#define OS_NVIC_INT_PRI_SIZE 0xF0
|
||||||
#define OS_NVIC_EXCPRI_SIZE 0xC
|
#define OS_NVIC_EXCPRI_SIZE 0xC
|
||||||
#define OS_NVIC_INT_CTRL_SIZE 4
|
#define OS_NVIC_INT_CTRL_SIZE 4
|
||||||
#define OS_NVIC_SHCSR_SIZE 4
|
#define OS_NVIC_SHCSR_SIZE 4
|
||||||
|
|
||||||
#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
|
#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
|
||||||
#define OS_NVIC_INT_ACT_SIZE OS_NVIC_INT_ENABLE_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
|
* @ingroup los_exc
|
||||||
* the struct of register files
|
* the struct of register files
|
||||||
@@ -500,11 +439,10 @@ typedef struct TagExcContext {
|
|||||||
UINT32 FPSCR;
|
UINT32 FPSCR;
|
||||||
UINT32 NO_NAME;
|
UINT32 NO_NAME;
|
||||||
#endif
|
#endif
|
||||||
}EXC_CONTEXT_S;
|
} EXC_CONTEXT_S;
|
||||||
|
|
||||||
typedef VOID (*EXC_PROC_FUNC)(UINT32, 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 HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr);
|
||||||
|
|
||||||
VOID HalExcNMI(VOID);
|
VOID HalExcNMI(VOID);
|
||||||
VOID HalExcHardFault(VOID);
|
VOID HalExcHardFault(VOID);
|
||||||
VOID HalExcMemFault(VOID);
|
VOID HalExcMemFault(VOID);
|
||||||
@@ -645,7 +583,7 @@ VOID HalHwiInit(VOID);
|
|||||||
* @ingroup los_exc
|
* @ingroup los_exc
|
||||||
* Exception information structure
|
* Exception information structure
|
||||||
*
|
*
|
||||||
* Description: Exception information saved when an exception is triggered on the Cortex-M4 platform.
|
* Description: Exception information saved when an exception is triggered on the Cortex-M55 platform.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
typedef struct TagExcInfo {
|
typedef struct TagExcInfo {
|
||||||
@@ -668,10 +606,9 @@ typedef struct TagExcInfo {
|
|||||||
EXC_CONTEXT_S *context;
|
EXC_CONTEXT_S *context;
|
||||||
} ExcInfo;
|
} ExcInfo;
|
||||||
|
|
||||||
extern UINT32 g_curNestCount;
|
|
||||||
extern UINT32 g_intCount;
|
|
||||||
extern UINT8 g_uwExcTbl[32];
|
|
||||||
extern ExcInfo g_excInfo;
|
extern ExcInfo g_excInfo;
|
||||||
|
extern UINT32 g_curNestCount;
|
||||||
|
extern UINT8 g_uwExcTbl[32];
|
||||||
|
|
||||||
#define MAX_INT_INFO_SIZE (8 + 0x164)
|
#define MAX_INT_INFO_SIZE (8 + 0x164)
|
||||||
|
|
||||||
@@ -681,4 +618,4 @@ extern ExcInfo g_excInfo;
|
|||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
#endif /* _LOS_EXC_H */
|
#endif /* _LOS_ARCH_INTERRUPT_H */
|
||||||
|
|||||||
@@ -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-2023 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:
|
||||||
@@ -28,13 +28,10 @@
|
|||||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "los_interrupt.h"
|
|
||||||
#include "securec.h"
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include "los_arch_interrupt.h"
|
#include "securec.h"
|
||||||
#include "los_context.h"
|
#include "los_context.h"
|
||||||
#include "los_debug.h"
|
#include "los_arch_interrupt.h"
|
||||||
#include "los_hook.h"
|
#include "los_hook.h"
|
||||||
#include "los_task.h"
|
#include "los_task.h"
|
||||||
#include "los_sched.h"
|
#include "los_sched.h"
|
||||||
@@ -44,92 +41,7 @@
|
|||||||
#include "los_cpup.h"
|
#include "los_cpup.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*lint -save -e40 -e522 -e533*/
|
#define DEF_HANDLER_START_INDEX 2
|
||||||
UINT32 g_intCount = 0;
|
|
||||||
|
|
||||||
/*lint -restore*/
|
|
||||||
#pragma location = ".data.vector"
|
|
||||||
#pragma data_alignment = LOSCFG_ARCH_HWI_VECTOR_ALIGN
|
|
||||||
/* *
|
|
||||||
* @ingroup los_hwi
|
|
||||||
* hardware interrupt form mapping handling function array.
|
|
||||||
*/
|
|
||||||
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)
|
|
||||||
|
|
||||||
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
|
Function : HwiNumGet
|
||||||
@@ -145,100 +57,54 @@ STATIC UINT32 HwiNumGet(VOID)
|
|||||||
|
|
||||||
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
|
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
|
||||||
{
|
{
|
||||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
|
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
|
||||||
{
|
{
|
||||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
NVIC_DisableIRQ((IRQn_Type)hwiNum);
|
NVIC_DisableIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority)
|
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);
|
NVIC_SetPriority((IRQn_Type)hwiNum, priority);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
|
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
|
||||||
{
|
{
|
||||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
|
NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
|
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
|
||||||
{
|
{
|
||||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
|
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
HwiControllerOps g_archHwiOps = {
|
STATIC UINT32 HwiCreate(HWI_HANDLE_T hwiNum, HWI_PRIOR_T hwiPrio)
|
||||||
|
{
|
||||||
|
HwiSetPriority(hwiNum, hwiPrio);
|
||||||
|
HwiUnmask(hwiNum);
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC HwiControllerOps g_archHwiOps = {
|
||||||
.enableIrq = HwiUnmask,
|
.enableIrq = HwiUnmask,
|
||||||
.disableIrq = HwiMask,
|
.disableIrq = HwiMask,
|
||||||
.setIrqPriority = HwiSetPriority,
|
.setIrqPriority = HwiSetPriority,
|
||||||
.getCurIrqNum = HwiNumGet,
|
.getCurIrqNum = HwiNumGet,
|
||||||
.triggerIrq = HwiPending,
|
.triggerIrq = HwiPending,
|
||||||
.clearIrq = HwiClear,
|
.clearIrq = HwiClear,
|
||||||
|
.createIrq = HwiCreate,
|
||||||
};
|
};
|
||||||
|
|
||||||
inline UINT32 ArchIsIntActive(VOID)
|
HwiControllerOps *ArchIntOpsGet(VOID)
|
||||||
{
|
{
|
||||||
return (g_intCount > 0);
|
return &g_archHwiOps;
|
||||||
}
|
|
||||||
/* ****************************************************************************
|
|
||||||
Function : HalHwiDefaultHandler
|
|
||||||
Description : default handler of the hardware interrupt
|
|
||||||
Input : None
|
|
||||||
Output : None
|
|
||||||
Return : None
|
|
||||||
**************************************************************************** */
|
|
||||||
/*lint -e529*/
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ****************************************************************************
|
/* ****************************************************************************
|
||||||
@@ -299,97 +165,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
|
|||||||
LOS_IntRestore(intSave);
|
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;
|
|
||||||
UINTPTR 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
NVIC_DisableIRQ((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 FAULT_STATUS_REG_BIT 32
|
||||||
#define USGFAULT (1 << 18)
|
#define USGFAULT (1 << 18)
|
||||||
#define BUSFAULT (1 << 17)
|
#define BUSFAULT (1 << 17)
|
||||||
@@ -622,23 +397,24 @@ 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 */
|
HWI_PROC_FUNC *hwiForm = (HWI_PROC_FUNC *)ArchGetHwiFrom();
|
||||||
g_hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */
|
hwiForm[0] = 0; /* [0] Top of Stack */
|
||||||
|
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;
|
hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
|
||||||
}
|
}
|
||||||
/* Exception handler register */
|
/* Exception handler register */
|
||||||
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
|
hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
|
||||||
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
|
hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
|
||||||
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
|
hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
|
||||||
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
|
hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
|
||||||
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
|
hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
|
||||||
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
|
hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
|
||||||
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
|
hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
|
||||||
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
|
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)hwiForm;
|
||||||
#endif
|
#endif
|
||||||
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
|
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
|
||||||
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
|
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
|
||||||
@@ -651,4 +427,3 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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-2023 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:
|
||||||
@@ -32,9 +32,7 @@
|
|||||||
#ifndef _LOS_ARCH_INTERRUPT_H
|
#ifndef _LOS_ARCH_INTERRUPT_H
|
||||||
#define _LOS_ARCH_INTERRUPT_H
|
#define _LOS_ARCH_INTERRUPT_H
|
||||||
|
|
||||||
#include "los_config.h"
|
#include "los_common_interrupt.h"
|
||||||
#include "los_compiler.h"
|
|
||||||
#include "los_interrupt.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
@@ -42,14 +40,6 @@ extern "C" {
|
|||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
#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
|
* @ingroup los_arch_interrupt
|
||||||
* Highest priority of a hardware interrupt.
|
* Highest priority of a hardware interrupt.
|
||||||
@@ -66,19 +56,6 @@ extern "C" {
|
|||||||
#define OS_HWI_PRIO_LOWEST 7
|
#define OS_HWI_PRIO_LOWEST 7
|
||||||
#endif
|
#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
|
* @ingroup los_arch_interrupt
|
||||||
* Count of M-Core system interrupt vector.
|
* Count of M-Core system interrupt vector.
|
||||||
@@ -110,7 +87,7 @@ extern UINT32 _BootVectors[];
|
|||||||
* Value: 0x02000900
|
* Value: 0x02000900
|
||||||
*
|
*
|
||||||
* Solution: Ensure that the interrupt number is valid.
|
* Solution: Ensure that the interrupt number is valid.
|
||||||
* The value range of the interrupt number applicable for a Cortex-M7 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
|
* The value range of the interrupt number applicable for a Cortex-M7 platformis [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)
|
||||||
|
|
||||||
@@ -186,6 +163,16 @@ extern UINT32 _BootVectors[];
|
|||||||
*/
|
*/
|
||||||
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
|
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Hardware interrupt error code: Invalid interrupt operation function.
|
||||||
|
*
|
||||||
|
* Value: 0x0200090c
|
||||||
|
*
|
||||||
|
* Solution: Set a valid interrupt operation function
|
||||||
|
*/
|
||||||
|
#define OS_ERRNO_HWI_OPS_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x0c)
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_arch_interrupt
|
* @ingroup los_arch_interrupt
|
||||||
* SysTick control and status register.
|
* SysTick control and status register.
|
||||||
@@ -312,20 +299,6 @@ extern UINT32 _BootVectors[];
|
|||||||
*/
|
*/
|
||||||
#define OS_EXC_SYS_TICK 15
|
#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
|
* @ingroup los_arch_interrupt
|
||||||
* @brief: Hardware interrupt entry function.
|
* @brief: Hardware interrupt entry function.
|
||||||
@@ -345,25 +318,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
|
|||||||
*/
|
*/
|
||||||
extern VOID HalInterrupt(VOID);
|
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
|
* @ingroup los_arch_interrupt
|
||||||
* @brief: Reset the vector table.
|
* @brief: Reset the vector table.
|
||||||
@@ -403,34 +357,20 @@ extern VOID Reset_Handler(VOID);
|
|||||||
*/
|
*/
|
||||||
extern VOID HalPendSV(VOID);
|
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_BUF_LEN 25
|
||||||
#define OS_EXC_MAX_NEST_DEPTH 1
|
#define OS_EXC_MAX_NEST_DEPTH 1
|
||||||
|
#define OS_EXC_FLAG_NO_FLOAT 0x10000000
|
||||||
|
|
||||||
#define OS_NVIC_SHCSR 0xE000ED24
|
#define OS_NVIC_SHCSR 0xE000ED24
|
||||||
#define OS_NVIC_CCR 0xE000ED14
|
#define OS_NVIC_CCR 0xE000ED14
|
||||||
|
|
||||||
#define OS_NVIC_INT_ENABLE_SIZE 0x20
|
#define OS_NVIC_INT_ENABLE_SIZE 0x20
|
||||||
#define OS_NVIC_INT_PRI_SIZE 0xF0
|
#define OS_NVIC_INT_PRI_SIZE 0xF0
|
||||||
#define OS_NVIC_EXCPRI_SIZE 0xC
|
#define OS_NVIC_EXCPRI_SIZE 0xC
|
||||||
#define OS_NVIC_INT_CTRL_SIZE 4
|
#define OS_NVIC_INT_CTRL_SIZE 4
|
||||||
#define OS_NVIC_SHCSR_SIZE 4
|
#define OS_NVIC_SHCSR_SIZE 4
|
||||||
|
|
||||||
#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
|
#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
|
||||||
#define OS_NVIC_INT_ACT_SIZE OS_NVIC_INT_ENABLE_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
|
* @ingroup los_exc
|
||||||
* the struct of register files
|
* the struct of register files
|
||||||
@@ -503,7 +443,6 @@ typedef struct TagExcContext {
|
|||||||
|
|
||||||
typedef VOID (*EXC_PROC_FUNC)(UINT32, 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 HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr);
|
||||||
|
|
||||||
VOID HalExcNMI(VOID);
|
VOID HalExcNMI(VOID);
|
||||||
VOID HalExcHardFault(VOID);
|
VOID HalExcHardFault(VOID);
|
||||||
VOID HalExcMemFault(VOID);
|
VOID HalExcMemFault(VOID);
|
||||||
@@ -667,10 +606,9 @@ typedef struct TagExcInfo {
|
|||||||
EXC_CONTEXT_S *context;
|
EXC_CONTEXT_S *context;
|
||||||
} ExcInfo;
|
} ExcInfo;
|
||||||
|
|
||||||
extern UINT32 g_curNestCount;
|
|
||||||
extern UINT32 g_intCount;
|
|
||||||
extern UINT8 g_uwExcTbl[32];
|
|
||||||
extern ExcInfo g_excInfo;
|
extern ExcInfo g_excInfo;
|
||||||
|
extern UINT32 g_curNestCount;
|
||||||
|
extern UINT8 g_uwExcTbl[32];
|
||||||
|
|
||||||
#define MAX_INT_INFO_SIZE (8 + 0x164)
|
#define MAX_INT_INFO_SIZE (8 + 0x164)
|
||||||
|
|
||||||
|
|||||||
@@ -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-2023 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:
|
||||||
@@ -28,12 +28,10 @@
|
|||||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
#include "los_interrupt.h"
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include "securec.h"
|
#include "securec.h"
|
||||||
#include "los_context.h"
|
#include "los_context.h"
|
||||||
#include "los_arch_interrupt.h"
|
#include "los_arch_interrupt.h"
|
||||||
#include "los_debug.h"
|
|
||||||
#include "los_hook.h"
|
#include "los_hook.h"
|
||||||
#include "los_task.h"
|
#include "los_task.h"
|
||||||
#include "los_sched.h"
|
#include "los_sched.h"
|
||||||
@@ -43,84 +41,6 @@
|
|||||||
#include "los_cpup.h"
|
#include "los_cpup.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
/* ****************************************************************************
|
/* ****************************************************************************
|
||||||
Function : HwiNumGet
|
Function : HwiNumGet
|
||||||
Description : Get an interrupt number
|
Description : Get an interrupt number
|
||||||
@@ -135,99 +55,54 @@ STATIC UINT32 HwiNumGet(VOID)
|
|||||||
|
|
||||||
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
|
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
|
||||||
{
|
{
|
||||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
|
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
|
||||||
{
|
{
|
||||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
NVIC_DisableIRQ((IRQn_Type)hwiNum);
|
NVIC_DisableIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority)
|
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);
|
NVIC_SetPriority((IRQn_Type)hwiNum, priority);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
|
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
|
||||||
{
|
{
|
||||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
|
NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
|
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
|
||||||
{
|
{
|
||||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
|
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
HwiControllerOps g_archHwiOps = {
|
STATIC UINT32 HwiCreate(HWI_HANDLE_T hwiNum, HWI_PRIOR_T hwiPrio)
|
||||||
|
{
|
||||||
|
HwiSetPriority(hwiNum, hwiPrio);
|
||||||
|
HwiUnmask(hwiNum);
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC HwiControllerOps g_archHwiOps = {
|
||||||
.enableIrq = HwiUnmask,
|
.enableIrq = HwiUnmask,
|
||||||
.disableIrq = HwiMask,
|
.disableIrq = HwiMask,
|
||||||
.setIrqPriority = HwiSetPriority,
|
.setIrqPriority = HwiSetPriority,
|
||||||
.getCurIrqNum = HwiNumGet,
|
.getCurIrqNum = HwiNumGet,
|
||||||
.triggerIrq = HwiPending,
|
.triggerIrq = HwiPending,
|
||||||
.clearIrq = HwiClear,
|
.clearIrq = HwiClear,
|
||||||
|
.createIrq = HwiCreate,
|
||||||
};
|
};
|
||||||
|
|
||||||
inline UINT32 ArchIsIntActive(VOID)
|
HwiControllerOps *ArchIntOpsGet(VOID)
|
||||||
{
|
{
|
||||||
return (g_intCount > 0);
|
return &g_archHwiOps;
|
||||||
}
|
|
||||||
/* ****************************************************************************
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ****************************************************************************
|
/* ****************************************************************************
|
||||||
@@ -286,97 +161,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
|
|||||||
LOS_IntRestore(intSave);
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
NVIC_DisableIRQ((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 FAULT_STATUS_REG_BIT 32
|
||||||
#define USGFAULT (1 << 18)
|
#define USGFAULT (1 << 18)
|
||||||
#define BUSFAULT (1 << 17)
|
#define BUSFAULT (1 << 17)
|
||||||
@@ -599,6 +383,11 @@ LITE_OS_SEC_TEXT_INIT VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, U
|
|||||||
ArchSysExit();
|
ArchSysExit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WEAK VOID SysTick_Handler(VOID)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* ****************************************************************************
|
/* ****************************************************************************
|
||||||
Function : HalHwiInit
|
Function : HalHwiInit
|
||||||
Description : initialization of the hardware interrupt
|
Description : initialization of the hardware interrupt
|
||||||
@@ -610,23 +399,24 @@ 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 */
|
HWI_PROC_FUNC *hwiForm = (HWI_PROC_FUNC *)ArchGetHwiFrom();
|
||||||
g_hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */
|
hwiForm[0] = 0; /* [0] Top of Stack */
|
||||||
|
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;
|
hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
|
||||||
}
|
}
|
||||||
/* Exception handler register */
|
/* Exception handler register */
|
||||||
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
|
hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
|
||||||
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
|
hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
|
||||||
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
|
hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
|
||||||
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
|
hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
|
||||||
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
|
hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
|
||||||
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcSvcCall;
|
hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcSvcCall;
|
||||||
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
|
hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
|
||||||
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
|
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)hwiForm;
|
||||||
#endif
|
#endif
|
||||||
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
|
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
|
||||||
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
|
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
|
||||||
@@ -644,4 +434,3 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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-2023 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:
|
||||||
@@ -32,9 +32,7 @@
|
|||||||
#ifndef _LOS_ARCH_INTERRUPT_H
|
#ifndef _LOS_ARCH_INTERRUPT_H
|
||||||
#define _LOS_ARCH_INTERRUPT_H
|
#define _LOS_ARCH_INTERRUPT_H
|
||||||
|
|
||||||
#include "los_config.h"
|
#include "los_common_interrupt.h"
|
||||||
#include "los_compiler.h"
|
|
||||||
#include "los_interrupt.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
@@ -42,14 +40,6 @@ extern "C" {
|
|||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
#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
|
* @ingroup los_arch_interrupt
|
||||||
* Highest priority of a hardware interrupt.
|
* Highest priority of a hardware interrupt.
|
||||||
@@ -66,18 +56,17 @@ extern "C" {
|
|||||||
#define OS_HWI_PRIO_LOWEST 7
|
#define OS_HWI_PRIO_LOWEST 7
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_arch_interrupt
|
* @ingroup los_arch_interrupt
|
||||||
* Define the type of a hardware interrupt vector table function.
|
* AIRCR register priority group parameter .
|
||||||
*/
|
*/
|
||||||
typedef VOID (**HWI_VECTOR_FUNC)(void);
|
#define OS_NVIC_AIRCR_PRIGROUP 7
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_arch_interrupt
|
* @ingroup los_arch_interrupt
|
||||||
* Count of interrupts.
|
* Boot interrupt vector table.
|
||||||
*/
|
*/
|
||||||
extern UINT32 g_intCount;
|
extern UINT32 _BootVectors[];
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_arch_interrupt
|
* @ingroup los_arch_interrupt
|
||||||
@@ -91,18 +80,6 @@ extern UINT32 g_intCount;
|
|||||||
*/
|
*/
|
||||||
#define OS_VECTOR_CNT (OS_SYS_VECTOR_CNT + OS_HWI_MAX_NUM)
|
#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
|
* @ingroup los_arch_interrupt
|
||||||
* Hardware interrupt error code: Invalid interrupt number.
|
* Hardware interrupt error code: Invalid interrupt number.
|
||||||
@@ -110,7 +87,7 @@ extern UINT32 _BootVectors[];
|
|||||||
* Value: 0x02000900
|
* Value: 0x02000900
|
||||||
*
|
*
|
||||||
* Solution: Ensure that the interrupt number is valid.
|
* Solution: Ensure that the interrupt number is valid.
|
||||||
* The value range of the interrupt number applicable for a Cortex-M7 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
|
* The value range of the interrupt number applicable for a Cortex-M7 platformis [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)
|
||||||
|
|
||||||
@@ -186,6 +163,16 @@ extern UINT32 _BootVectors[];
|
|||||||
*/
|
*/
|
||||||
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
|
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Hardware interrupt error code: Invalid interrupt operation function.
|
||||||
|
*
|
||||||
|
* Value: 0x0200090c
|
||||||
|
*
|
||||||
|
* Solution: Set a valid interrupt operation function
|
||||||
|
*/
|
||||||
|
#define OS_ERRNO_HWI_OPS_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x0c)
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_arch_interrupt
|
* @ingroup los_arch_interrupt
|
||||||
* SysTick control and status register.
|
* SysTick control and status register.
|
||||||
@@ -312,20 +299,6 @@ extern UINT32 _BootVectors[];
|
|||||||
*/
|
*/
|
||||||
#define OS_EXC_SYS_TICK 15
|
#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
|
* @ingroup los_arch_interrupt
|
||||||
* @brief: Hardware interrupt entry function.
|
* @brief: Hardware interrupt entry function.
|
||||||
@@ -345,25 +318,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
|
|||||||
*/
|
*/
|
||||||
extern VOID HalInterrupt(VOID);
|
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
|
* @ingroup los_arch_interrupt
|
||||||
* @brief: Reset the vector table.
|
* @brief: Reset the vector table.
|
||||||
@@ -403,34 +357,20 @@ extern VOID Reset_Handler(VOID);
|
|||||||
*/
|
*/
|
||||||
extern VOID HalPendSV(VOID);
|
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_BUF_LEN 25
|
||||||
#define OS_EXC_MAX_NEST_DEPTH 1
|
#define OS_EXC_MAX_NEST_DEPTH 1
|
||||||
|
#define OS_EXC_FLAG_NO_FLOAT 0x10000000
|
||||||
|
|
||||||
#define OS_NVIC_SHCSR 0xE000ED24
|
#define OS_NVIC_SHCSR 0xE000ED24
|
||||||
#define OS_NVIC_CCR 0xE000ED14
|
#define OS_NVIC_CCR 0xE000ED14
|
||||||
|
|
||||||
#define OS_NVIC_INT_ENABLE_SIZE 0x20
|
#define OS_NVIC_INT_ENABLE_SIZE 0x20
|
||||||
#define OS_NVIC_INT_PRI_SIZE 0xF0
|
#define OS_NVIC_INT_PRI_SIZE 0xF0
|
||||||
#define OS_NVIC_EXCPRI_SIZE 0xC
|
#define OS_NVIC_EXCPRI_SIZE 0xC
|
||||||
#define OS_NVIC_INT_CTRL_SIZE 4
|
#define OS_NVIC_INT_CTRL_SIZE 4
|
||||||
#define OS_NVIC_SHCSR_SIZE 4
|
#define OS_NVIC_SHCSR_SIZE 4
|
||||||
|
|
||||||
#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
|
#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
|
||||||
#define OS_NVIC_INT_ACT_SIZE OS_NVIC_INT_ENABLE_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
|
* @ingroup los_exc
|
||||||
* the struct of register files
|
* the struct of register files
|
||||||
@@ -503,7 +443,6 @@ typedef struct TagExcContext {
|
|||||||
|
|
||||||
typedef VOID (*EXC_PROC_FUNC)(UINT32, 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 HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr);
|
||||||
|
|
||||||
VOID HalExcNMI(VOID);
|
VOID HalExcNMI(VOID);
|
||||||
VOID HalExcHardFault(VOID);
|
VOID HalExcHardFault(VOID);
|
||||||
VOID HalExcMemFault(VOID);
|
VOID HalExcMemFault(VOID);
|
||||||
@@ -667,10 +606,9 @@ typedef struct TagExcInfo {
|
|||||||
EXC_CONTEXT_S *context;
|
EXC_CONTEXT_S *context;
|
||||||
} ExcInfo;
|
} ExcInfo;
|
||||||
|
|
||||||
extern UINT32 g_curNestCount;
|
|
||||||
extern UINT32 g_intCount;
|
|
||||||
extern UINT8 g_uwExcTbl[32];
|
|
||||||
extern ExcInfo g_excInfo;
|
extern ExcInfo g_excInfo;
|
||||||
|
extern UINT32 g_curNestCount;
|
||||||
|
extern UINT8 g_uwExcTbl[32];
|
||||||
|
|
||||||
#define MAX_INT_INFO_SIZE (8 + 0x164)
|
#define MAX_INT_INFO_SIZE (8 + 0x164)
|
||||||
|
|
||||||
|
|||||||
@@ -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-2023 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:
|
||||||
@@ -29,12 +29,10 @@
|
|||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "los_interrupt.h"
|
|
||||||
#include "securec.h"
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include "los_arch_interrupt.h"
|
#include "securec.h"
|
||||||
#include "los_context.h"
|
#include "los_context.h"
|
||||||
#include "los_debug.h"
|
#include "los_arch_interrupt.h"
|
||||||
#include "los_hook.h"
|
#include "los_hook.h"
|
||||||
#include "los_task.h"
|
#include "los_task.h"
|
||||||
#include "los_sched.h"
|
#include "los_sched.h"
|
||||||
@@ -44,90 +42,8 @@
|
|||||||
#include "los_cpup.h"
|
#include "los_cpup.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
UINT32 g_intCount = 0;
|
|
||||||
|
|
||||||
#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
|
|
||||||
* Hardware interrupt form mapping handling function array.
|
|
||||||
*/
|
|
||||||
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)
|
|
||||||
|
|
||||||
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
|
Function : HwiNumGet
|
||||||
@@ -143,100 +59,54 @@ STATIC UINT32 HwiNumGet(VOID)
|
|||||||
|
|
||||||
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
|
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
|
||||||
{
|
{
|
||||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
|
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
|
||||||
{
|
{
|
||||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
NVIC_DisableIRQ((IRQn_Type)hwiNum);
|
NVIC_DisableIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority)
|
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);
|
NVIC_SetPriority((IRQn_Type)hwiNum, priority);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
|
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
|
||||||
{
|
{
|
||||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
|
NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
|
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
|
||||||
{
|
{
|
||||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
|
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
HwiControllerOps g_archHwiOps = {
|
STATIC UINT32 HwiCreate(HWI_HANDLE_T hwiNum, HWI_PRIOR_T hwiPrio)
|
||||||
|
{
|
||||||
|
HwiSetPriority(hwiNum, hwiPrio);
|
||||||
|
HwiUnmask(hwiNum);
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC HwiControllerOps g_archHwiOps = {
|
||||||
.enableIrq = HwiUnmask,
|
.enableIrq = HwiUnmask,
|
||||||
.disableIrq = HwiMask,
|
.disableIrq = HwiMask,
|
||||||
.setIrqPriority = HwiSetPriority,
|
.setIrqPriority = HwiSetPriority,
|
||||||
.getCurIrqNum = HwiNumGet,
|
.getCurIrqNum = HwiNumGet,
|
||||||
.triggerIrq = HwiPending,
|
.triggerIrq = HwiPending,
|
||||||
.clearIrq = HwiClear,
|
.clearIrq = HwiClear,
|
||||||
|
.createIrq = HwiCreate,
|
||||||
};
|
};
|
||||||
|
|
||||||
inline UINT32 ArchIsIntActive(VOID)
|
HwiControllerOps *ArchIntOpsGet(VOID)
|
||||||
{
|
{
|
||||||
return (g_intCount > 0);
|
return &g_archHwiOps;
|
||||||
}
|
|
||||||
/* ****************************************************************************
|
|
||||||
Function : HalHwiDefaultHandler
|
|
||||||
Description : default handler of the hardware interrupt
|
|
||||||
Input : None
|
|
||||||
Output : None
|
|
||||||
Return : None
|
|
||||||
**************************************************************************** */
|
|
||||||
/*lint -e529*/
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ****************************************************************************
|
/* ****************************************************************************
|
||||||
@@ -295,97 +165,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
|
|||||||
LOS_IntRestore(intSave);
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
NVIC_DisableIRQ((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 FAULT_STATUS_REG_BIT 32
|
||||||
#define USGFAULT (1 << 18)
|
#define USGFAULT (1 << 18)
|
||||||
#define BUSFAULT (1 << 17)
|
#define BUSFAULT (1 << 17)
|
||||||
@@ -608,6 +387,11 @@ LITE_OS_SEC_TEXT_INIT VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, U
|
|||||||
ArchSysExit();
|
ArchSysExit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WEAK VOID SysTick_Handler(VOID)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* ****************************************************************************
|
/* ****************************************************************************
|
||||||
Function : HalHwiInit
|
Function : HalHwiInit
|
||||||
Description : initialization of the hardware interrupt
|
Description : initialization of the hardware interrupt
|
||||||
@@ -619,23 +403,24 @@ 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 */
|
HWI_PROC_FUNC *hwiForm = (HWI_PROC_FUNC *)ArchGetHwiFrom();
|
||||||
g_hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */
|
hwiForm[0] = 0; /* [0] Top of Stack */
|
||||||
|
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;
|
hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
|
||||||
}
|
}
|
||||||
/* Exception handler register */
|
/* Exception handler register */
|
||||||
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
|
hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
|
||||||
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
|
hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
|
||||||
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
|
hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
|
||||||
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
|
hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
|
||||||
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
|
hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
|
||||||
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcSvcCall;
|
hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcSvcCall;
|
||||||
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
|
hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
|
||||||
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
|
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)hwiForm;
|
||||||
#endif
|
#endif
|
||||||
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
|
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
|
||||||
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
|
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
|
||||||
@@ -649,4 +434,3 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-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-2023 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:
|
||||||
@@ -30,5 +30,8 @@
|
|||||||
import("//kernel/liteos_m/liteos.gni")
|
import("//kernel/liteos_m/liteos.gni")
|
||||||
|
|
||||||
module_group("csky") {
|
module_group("csky") {
|
||||||
modules = [ "v2/gcc" ]
|
modules = [
|
||||||
|
"common",
|
||||||
|
"v2/gcc",
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
# Copyright (c) 2023-2023 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 = "common"
|
||||||
|
kernel_module(module_name) {
|
||||||
|
sources = [ "los_common_interrupt.c" ]
|
||||||
|
configs += [ "$LITEOSTOPDIR:warn_config" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
config("public") {
|
||||||
|
include_dirs = [ "." ]
|
||||||
|
}
|
||||||
@@ -0,0 +1,289 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2023-2023 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_arch_interrupt.h"
|
||||||
|
#include "los_debug.h"
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_hwi
|
||||||
|
* Hardware interrupt form mapping handling function array.
|
||||||
|
*/
|
||||||
|
HWI_PROC_FUNC __attribute__((aligned(HWI_ALIGNSIZE))) g_hwiForm[OS_VECTOR_CNT] = {0};
|
||||||
|
|
||||||
|
VOID *ArchGetHwiFrom(VOID)
|
||||||
|
{
|
||||||
|
return g_hwiForm;
|
||||||
|
}
|
||||||
|
|
||||||
|
UINT32 volatile 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:%x\n", __FUNCTION__, ArchIntCurIrqNum());
|
||||||
|
while (1) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
WEAK VOID HalPreInterruptHandler(UINT32 arg)
|
||||||
|
{
|
||||||
|
(VOID)arg;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
WEAK VOID HalAftInterruptHandler(UINT32 arg)
|
||||||
|
{
|
||||||
|
(VOID)arg;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC UINT32 HwiNumValid(UINT32 num)
|
||||||
|
{
|
||||||
|
return ((num) >= OS_USER_HWI_MIN) && ((num) <= OS_USER_HWI_MAX);
|
||||||
|
}
|
||||||
|
|
||||||
|
UINT32 ArchIntTrigger(HWI_HANDLE_T hwiNum)
|
||||||
|
{
|
||||||
|
if (!HwiNumValid(hwiNum)) {
|
||||||
|
return LOS_ERRNO_HWI_NUM_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
HwiControllerOps *hwiOps = ArchIntOpsGet();
|
||||||
|
if (hwiOps->triggerIrq == NULL) {
|
||||||
|
return OS_ERRNO_HWI_OPS_FUNC_NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return hwiOps->triggerIrq(hwiNum);
|
||||||
|
}
|
||||||
|
|
||||||
|
UINT32 ArchIntEnable(HWI_HANDLE_T hwiNum)
|
||||||
|
{
|
||||||
|
if (!HwiNumValid(hwiNum)) {
|
||||||
|
return LOS_ERRNO_HWI_NUM_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
HwiControllerOps *hwiOps = ArchIntOpsGet();
|
||||||
|
if (hwiOps->enableIrq == NULL) {
|
||||||
|
return OS_ERRNO_HWI_OPS_FUNC_NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return hwiOps->enableIrq(hwiNum);
|
||||||
|
}
|
||||||
|
|
||||||
|
UINT32 ArchIntDisable(HWI_HANDLE_T hwiNum)
|
||||||
|
{
|
||||||
|
if (!HwiNumValid(hwiNum)) {
|
||||||
|
return LOS_ERRNO_HWI_NUM_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
HwiControllerOps *hwiOps = ArchIntOpsGet();
|
||||||
|
if (hwiOps->disableIrq == NULL) {
|
||||||
|
return OS_ERRNO_HWI_OPS_FUNC_NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return hwiOps->disableIrq(hwiNum);
|
||||||
|
}
|
||||||
|
|
||||||
|
UINT32 ArchIntClear(HWI_HANDLE_T hwiNum)
|
||||||
|
{
|
||||||
|
if (!HwiNumValid(hwiNum)) {
|
||||||
|
return LOS_ERRNO_HWI_NUM_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
HwiControllerOps *hwiOps = ArchIntOpsGet();
|
||||||
|
if (hwiOps->clearIrq == NULL) {
|
||||||
|
return OS_ERRNO_HWI_OPS_FUNC_NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return hwiOps->clearIrq(hwiNum);
|
||||||
|
}
|
||||||
|
|
||||||
|
UINT32 ArchIntSetPriority(HWI_HANDLE_T hwiNum, HWI_PRIOR_T priority)
|
||||||
|
{
|
||||||
|
if (!HwiNumValid(hwiNum)) {
|
||||||
|
return LOS_ERRNO_HWI_NUM_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!HWI_PRI_VALID(priority)) {
|
||||||
|
return OS_ERRNO_HWI_PRIO_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
HwiControllerOps *hwiOps = ArchIntOpsGet();
|
||||||
|
if (hwiOps->setIrqPriority == NULL) {
|
||||||
|
return OS_ERRNO_HWI_OPS_FUNC_NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return hwiOps->setIrqPriority(hwiNum, priority);
|
||||||
|
}
|
||||||
|
|
||||||
|
UINT32 ArchIntCurIrqNum(VOID)
|
||||||
|
{
|
||||||
|
HwiControllerOps *hwiOps = ArchIntOpsGet();
|
||||||
|
return hwiOps->getCurIrqNum();
|
||||||
|
}
|
||||||
|
|
||||||
|
#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.
|
||||||
|
*/
|
||||||
|
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)IrqEntry;
|
||||||
|
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector;
|
||||||
|
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pParm = arg;
|
||||||
|
ArchIntEnable(num);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
/* *
|
||||||
|
* @ingroup los_hwi
|
||||||
|
* Hardware interrupt handler form mapping handling function array.
|
||||||
|
*/
|
||||||
|
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] = IrqEntry;
|
||||||
|
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT] = vector;
|
||||||
|
ArchIntEnable(num);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* ****************************************************************************
|
||||||
|
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_hwiHandlerForm[hwiNum + OS_SYS_VECTOR_CNT] != 0) {
|
||||||
|
return OS_ERRNO_HWI_ALREADY_CREATED;
|
||||||
|
}
|
||||||
|
if (g_hwiHandlerForm[hwiNum + OS_SYS_VECTOR_CNT] != 0) {
|
||||||
|
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
|
||||||
|
|
||||||
|
HwiControllerOps *hwiOps = ArchIntOpsGet();
|
||||||
|
if (hwiOps->createIrq == NULL) {
|
||||||
|
LOS_IntRestore(intSave);
|
||||||
|
return OS_ERRNO_HWI_OPS_FUNC_NULL;
|
||||||
|
}
|
||||||
|
hwiOps->createIrq(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;
|
||||||
|
}
|
||||||
|
|
||||||
|
ArchIntDisable((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
|
intSave = LOS_IntLock();
|
||||||
|
g_hwiHandlerForm[hwiNum + OS_SYS_VECTOR_CNT] = 0;
|
||||||
|
LOS_IntRestore(intSave);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
UINT32 ArchIsIntActive(VOID)
|
||||||
|
{
|
||||||
|
return (g_intCount > 0);
|
||||||
|
}
|
||||||
@@ -0,0 +1,116 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2023-2023 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_COMMON_INTERRUPT_H
|
||||||
|
#define _LOS_COMMON_INTERRUPT_H
|
||||||
|
|
||||||
|
#include "los_config.h"
|
||||||
|
#include "los_compiler.h"
|
||||||
|
#include "los_interrupt.h"
|
||||||
|
#include "los_error.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#if __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @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 volatile UINT32 g_intCount;
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @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
|
||||||
|
|
||||||
|
#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);
|
||||||
|
extern HWI_HANDLER_FUNC g_hwiHandlerForm[];
|
||||||
|
#else
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Set interrupt vector table.
|
||||||
|
*/
|
||||||
|
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
|
||||||
|
extern HWI_PROC_FUNC g_hwiHandlerForm[];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define OS_EXC_IN_INIT 0
|
||||||
|
#define OS_EXC_IN_TASK 1
|
||||||
|
#define OS_EXC_IN_HWI 2
|
||||||
|
#define OS_EXC_FLAG_FAULTADDR_VALID 0x01
|
||||||
|
#define OS_EXC_IMPRECISE_ACCESS_ADDR 0xABABABAB
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @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);
|
||||||
|
|
||||||
|
VOID HalPreInterruptHandler(UINT32 arg);
|
||||||
|
VOID HalAftInterruptHandler(UINT32 arg);
|
||||||
|
VOID *ArchGetHwiFrom(VOID);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#if __cplusplus
|
||||||
|
}
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
#endif /* _LOS_COMMON_INTERRUPT_H */
|
||||||
@@ -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-2023 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:
|
||||||
@@ -32,9 +32,7 @@
|
|||||||
#ifndef _LOS_ARCH_INTERRUPT_H
|
#ifndef _LOS_ARCH_INTERRUPT_H
|
||||||
#define _LOS_ARCH_INTERRUPT_H
|
#define _LOS_ARCH_INTERRUPT_H
|
||||||
|
|
||||||
#include "los_config.h"
|
#include "los_common_interrupt.h"
|
||||||
#include "los_compiler.h"
|
|
||||||
#include "los_interrupt.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
@@ -42,14 +40,6 @@ extern "C" {
|
|||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
#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
|
* @ingroup los_arch_interrupt
|
||||||
* Highest priority of a hardware interrupt.
|
* Highest priority of a hardware interrupt.
|
||||||
@@ -72,18 +62,6 @@ extern "C" {
|
|||||||
*/
|
*/
|
||||||
#define HWI_PRI_VALID(pri) (((pri) >= OS_HWI_PRIO_HIGHEST) && ((pri) <= OS_HWI_PRIO_LOWEST))
|
#define HWI_PRI_VALID(pri) (((pri) >= OS_HWI_PRIO_HIGHEST) && ((pri) <= OS_HWI_PRIO_LOWEST))
|
||||||
|
|
||||||
/* *
|
|
||||||
* @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 volatile UINT32 g_intCount;
|
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_arch_interrupt
|
* @ingroup los_arch_interrupt
|
||||||
* Count of C-sky system interrupt vector.
|
* Count of C-sky system interrupt vector.
|
||||||
@@ -96,6 +74,11 @@ extern volatile UINT32 g_intCount;
|
|||||||
*/
|
*/
|
||||||
#define OS_VECTOR_CNT (OS_SYS_VECTOR_CNT + OS_HWI_MAX_NUM)
|
#define OS_VECTOR_CNT (OS_SYS_VECTOR_CNT + OS_HWI_MAX_NUM)
|
||||||
|
|
||||||
|
#define OS_USER_HWI_MIN 0
|
||||||
|
#define OS_USER_HWI_MAX (LOSCFG_PLATFORM_HWI_LIMIT - 1)
|
||||||
|
|
||||||
|
#define HWI_ALIGNSIZE 0x400
|
||||||
|
|
||||||
#define PSR_VEC_OFFSET 16U
|
#define PSR_VEC_OFFSET 16U
|
||||||
#define VIC_REG_BASE 0xE000E100UL
|
#define VIC_REG_BASE 0xE000E100UL
|
||||||
|
|
||||||
@@ -208,6 +191,16 @@ extern VIC_TYPE *VIC_REG;
|
|||||||
*/
|
*/
|
||||||
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
|
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Hardware interrupt error code: Invalid interrupt operation function.
|
||||||
|
*
|
||||||
|
* Value: 0x0200090c
|
||||||
|
*
|
||||||
|
* Solution: Set a valid interrupt operation function
|
||||||
|
*/
|
||||||
|
#define OS_ERRNO_HWI_OPS_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x0c)
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_arch_interrupt
|
* @ingroup los_arch_interrupt
|
||||||
* Hardware interrupt error code: Invalid interrupt number.
|
* Hardware interrupt error code: Invalid interrupt number.
|
||||||
@@ -218,20 +211,6 @@ extern VIC_TYPE *VIC_REG;
|
|||||||
*/
|
*/
|
||||||
#define LOS_ERRNO_HWI_NUM_INVALID OS_ERRNO_HWI_NUM_INVALID
|
#define LOS_ERRNO_HWI_NUM_INVALID OS_ERRNO_HWI_NUM_INVALID
|
||||||
|
|
||||||
#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
|
* @ingroup los_arch_interrupt
|
||||||
* @brief: Hardware interrupt entry function.
|
* @brief: Hardware interrupt entry function.
|
||||||
@@ -251,29 +230,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
|
|||||||
*/
|
*/
|
||||||
extern VOID HalInterrupt(VOID);
|
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);
|
|
||||||
|
|
||||||
#define OS_EXC_IN_INIT 0
|
|
||||||
#define OS_EXC_IN_TASK 1
|
|
||||||
#define OS_EXC_IN_HWI 2
|
|
||||||
|
|
||||||
#define OS_VIC_INT_ENABLE_SIZE 0x4
|
#define OS_VIC_INT_ENABLE_SIZE 0x4
|
||||||
#define OS_VIC_INT_WAKER_SIZE 0x4
|
#define OS_VIC_INT_WAKER_SIZE 0x4
|
||||||
#define OS_VIC_INT_ICER_SIZE 0x4
|
#define OS_VIC_INT_ICER_SIZE 0x4
|
||||||
@@ -283,10 +239,6 @@ extern VOID HalHwiDefaultHandler(VOID);
|
|||||||
#define OS_VIC_INT_ISR_SIZE 0x4
|
#define OS_VIC_INT_ISR_SIZE 0x4
|
||||||
#define OS_VIC_INT_IPTR_SIZE 0x4
|
#define OS_VIC_INT_IPTR_SIZE 0x4
|
||||||
|
|
||||||
#define OS_EXC_FLAG_FAULTADDR_VALID 0x01
|
|
||||||
|
|
||||||
#define OS_EXC_IMPRECISE_ACCESS_ADDR 0xABABABAB
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ingroup los_exc
|
* @ingroup los_exc
|
||||||
* the struct of register files
|
* the struct of register files
|
||||||
|
|||||||
@@ -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-2023 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:
|
||||||
@@ -29,7 +29,6 @@
|
|||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "los_interrupt.h"
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include "securec.h"
|
#include "securec.h"
|
||||||
#include "los_context.h"
|
#include "los_context.h"
|
||||||
@@ -53,20 +52,10 @@
|
|||||||
#define MASK_32_BITS 0xFFFFFFFF
|
#define MASK_32_BITS 0xFFFFFFFF
|
||||||
#define BYTES_OF_128_INT 4
|
#define BYTES_OF_128_INT 4
|
||||||
|
|
||||||
#define OS_USER_HWI_MIN 0
|
|
||||||
#define OS_USER_HWI_MAX (LOSCFG_PLATFORM_HWI_LIMIT - 1)
|
|
||||||
#define HWI_ALIGNSIZE 0x400
|
|
||||||
|
|
||||||
UINT32 volatile g_intCount = 0;
|
|
||||||
CHAR g_trapStackBase[OS_TRAP_STACK_SIZE];
|
CHAR g_trapStackBase[OS_TRAP_STACK_SIZE];
|
||||||
|
|
||||||
VIC_TYPE *VIC_REG = (VIC_TYPE *)VIC_REG_BASE;
|
VIC_TYPE *VIC_REG = (VIC_TYPE *)VIC_REG_BASE;
|
||||||
|
|
||||||
UINT32 HwiNumValid(UINT32 num)
|
|
||||||
{
|
|
||||||
return ((num) >= OS_USER_HWI_MIN) && ((num) <= OS_USER_HWI_MAX);
|
|
||||||
}
|
|
||||||
|
|
||||||
UINT32 HalGetPsr(VOID)
|
UINT32 HalGetPsr(VOID)
|
||||||
{
|
{
|
||||||
UINT32 intSave;
|
UINT32 intSave;
|
||||||
@@ -120,10 +109,6 @@ STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
|
|||||||
{
|
{
|
||||||
UINT32 intSave;
|
UINT32 intSave;
|
||||||
|
|
||||||
if (!HwiNumValid(hwiNum)) {
|
|
||||||
return LOS_ERRNO_HWI_NUM_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
intSave = LOS_IntLock();
|
intSave = LOS_IntLock();
|
||||||
VIC_REG->ISER[hwiNum / OS_SYS_VECTOR_CNT] = (UINT32)(1UL << (hwiNum % OS_SYS_VECTOR_CNT));
|
VIC_REG->ISER[hwiNum / OS_SYS_VECTOR_CNT] = (UINT32)(1UL << (hwiNum % OS_SYS_VECTOR_CNT));
|
||||||
VIC_REG->ISSR[hwiNum / OS_SYS_VECTOR_CNT] = (UINT32)(1UL << (hwiNum % OS_SYS_VECTOR_CNT));
|
VIC_REG->ISSR[hwiNum / OS_SYS_VECTOR_CNT] = (UINT32)(1UL << (hwiNum % OS_SYS_VECTOR_CNT));
|
||||||
@@ -136,14 +121,6 @@ STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority)
|
|||||||
{
|
{
|
||||||
UINT32 intSave;
|
UINT32 intSave;
|
||||||
|
|
||||||
if (!HwiNumValid(hwiNum)) {
|
|
||||||
return LOS_ERRNO_HWI_NUM_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!HWI_PRI_VALID(priority)) {
|
|
||||||
return OS_ERRNO_HWI_PRIO_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
intSave = LOS_IntLock();
|
intSave = LOS_IntLock();
|
||||||
VIC_REG->IPR[hwiNum / PRI_PER_REG] |= (((priority << PRI_OFF_IN_REG) << (hwiNum % PRI_PER_REG)) * PRI_OFF_PER_INT);
|
VIC_REG->IPR[hwiNum / PRI_PER_REG] |= (((priority << PRI_OFF_IN_REG) << (hwiNum % PRI_PER_REG)) * PRI_OFF_PER_INT);
|
||||||
LOS_IntRestore(intSave);
|
LOS_IntRestore(intSave);
|
||||||
@@ -155,10 +132,6 @@ STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
|
|||||||
{
|
{
|
||||||
UINT32 intSave;
|
UINT32 intSave;
|
||||||
|
|
||||||
if (!HwiNumValid(hwiNum)) {
|
|
||||||
return LOS_ERRNO_HWI_NUM_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
intSave = LOS_IntLock();
|
intSave = LOS_IntLock();
|
||||||
VIC_REG->ICER[hwiNum / OS_SYS_VECTOR_CNT] = (UINT32)(1UL << (hwiNum % OS_SYS_VECTOR_CNT));
|
VIC_REG->ICER[hwiNum / OS_SYS_VECTOR_CNT] = (UINT32)(1UL << (hwiNum % OS_SYS_VECTOR_CNT));
|
||||||
LOS_IntRestore(intSave);
|
LOS_IntRestore(intSave);
|
||||||
@@ -170,10 +143,6 @@ STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
|
|||||||
{
|
{
|
||||||
UINT32 intSave;
|
UINT32 intSave;
|
||||||
|
|
||||||
if (!HwiNumValid(hwiNum)) {
|
|
||||||
return LOS_ERRNO_HWI_NUM_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
intSave = LOS_IntLock();
|
intSave = LOS_IntLock();
|
||||||
VIC_REG->ISPR[hwiNum / OS_SYS_VECTOR_CNT] = (UINT32)(1UL << (hwiNum % OS_SYS_VECTOR_CNT));
|
VIC_REG->ISPR[hwiNum / OS_SYS_VECTOR_CNT] = (UINT32)(1UL << (hwiNum % OS_SYS_VECTOR_CNT));
|
||||||
LOS_IntRestore(intSave);
|
LOS_IntRestore(intSave);
|
||||||
@@ -183,69 +152,11 @@ STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
|
|||||||
|
|
||||||
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
|
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
|
||||||
{
|
{
|
||||||
if (!HwiNumValid(hwiNum)) {
|
|
||||||
return LOS_ERRNO_HWI_NUM_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
VIC_REG->ICPR[hwiNum / OS_SYS_VECTOR_CNT] = (UINT32)(1UL << (hwiNum % OS_SYS_VECTOR_CNT));
|
VIC_REG->ICPR[hwiNum / OS_SYS_VECTOR_CNT] = (UINT32)(1UL << (hwiNum % OS_SYS_VECTOR_CNT));
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* *
|
|
||||||
* @ingroup los_hwi
|
|
||||||
* Hardware interrupt form mapping handling function array.
|
|
||||||
*/
|
|
||||||
STATIC HWI_PROC_FUNC __attribute__((aligned(HWI_ALIGNSIZE))) g_hwiForm[OS_VECTOR_CNT] = {0};
|
|
||||||
|
|
||||||
#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)IrqEntry;
|
|
||||||
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector;
|
|
||||||
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pParm = arg;
|
|
||||||
HwiUnmask(num);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#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] = IrqEntry;
|
|
||||||
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT] = vector;
|
|
||||||
HwiUnmask(num);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* ****************************************************************************
|
/* ****************************************************************************
|
||||||
Function : HwiNumGet
|
Function : HwiNumGet
|
||||||
Description : Get an interrupt number
|
Description : Get an interrupt number
|
||||||
@@ -258,43 +169,26 @@ STATIC UINT32 HwiNumGet(VOID)
|
|||||||
return (HalGetPsr() >> PSR_VEC_OFFSET) & MASK_8_BITS;
|
return (HalGetPsr() >> PSR_VEC_OFFSET) & MASK_8_BITS;
|
||||||
}
|
}
|
||||||
|
|
||||||
HwiControllerOps g_archHwiOps = {
|
STATIC UINT32 HwiCreate(HWI_HANDLE_T hwiNum, HWI_PRIOR_T hwiPrio)
|
||||||
.triggerIrq = HwiPending,
|
{
|
||||||
|
HwiSetPriority(hwiNum, (UINT8)hwiPrio);
|
||||||
|
HwiUnmask(hwiNum);
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC HwiControllerOps g_archHwiOps = {
|
||||||
.enableIrq = HwiUnmask,
|
.enableIrq = HwiUnmask,
|
||||||
.disableIrq = HwiMask,
|
.disableIrq = HwiMask,
|
||||||
.setIrqPriority = HwiSetPriority,
|
.setIrqPriority = HwiSetPriority,
|
||||||
.getCurIrqNum = HwiNumGet,
|
.getCurIrqNum = HwiNumGet,
|
||||||
|
.triggerIrq = HwiPending,
|
||||||
.clearIrq = HwiClear,
|
.clearIrq = HwiClear,
|
||||||
|
.createIrq = HwiCreate,
|
||||||
};
|
};
|
||||||
|
|
||||||
inline UINT32 ArchIsIntActive(VOID)
|
HwiControllerOps *ArchIntOpsGet(VOID)
|
||||||
{
|
{
|
||||||
return (g_intCount > 0);
|
return &g_archHwiOps;
|
||||||
}
|
|
||||||
|
|
||||||
/* ****************************************************************************
|
|
||||||
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:%x\n", __FUNCTION__, HwiNumGet());
|
|
||||||
while (1) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
WEAK VOID HalPreInterruptHandler(UINT32 arg)
|
|
||||||
{
|
|
||||||
(VOID)arg;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
WEAK VOID HalAftInterruptHandler(UINT32 arg)
|
|
||||||
{
|
|
||||||
(VOID)arg;
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ****************************************************************************
|
/* ****************************************************************************
|
||||||
@@ -339,83 +233,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
|
|||||||
LOS_IntRestore(intSave);
|
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_hwiHandlerForm[hwiNum + OS_SYS_VECTOR_CNT] != 0) {
|
|
||||||
return OS_ERRNO_HWI_ALREADY_CREATED;
|
|
||||||
}
|
|
||||||
if (g_hwiHandlerForm[hwiNum + OS_SYS_VECTOR_CNT] != 0) {
|
|
||||||
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
|
|
||||||
HwiUnmask(hwiNum);
|
|
||||||
(VOID)HwiSetPriority(hwiNum, (UINT8)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(hwiNum);
|
|
||||||
intSave = LOS_IntLock();
|
|
||||||
g_hwiHandlerForm[hwiNum + OS_SYS_VECTOR_CNT] = 0;
|
|
||||||
LOS_IntRestore(intSave);
|
|
||||||
|
|
||||||
return LOS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
ExcInfo g_excInfo = {0};
|
ExcInfo g_excInfo = {0};
|
||||||
|
|
||||||
#if (LOSCFG_KERNEL_PRINTF != 0)
|
#if (LOSCFG_KERNEL_PRINTF != 0)
|
||||||
@@ -602,16 +419,17 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
|
|||||||
{
|
{
|
||||||
UINT32 i;
|
UINT32 i;
|
||||||
|
|
||||||
|
HWI_PROC_FUNC *hwiForm = (HWI_PROC_FUNC *)ArchGetHwiFrom();
|
||||||
for (i = 1; i < OS_SYS_VECTOR_CNT; i++) {
|
for (i = 1; i < OS_SYS_VECTOR_CNT; i++) {
|
||||||
g_hwiForm[i] = (HWI_PROC_FUNC)HandleEntry;
|
hwiForm[i] = (HWI_PROC_FUNC)HandleEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = OS_SYS_VECTOR_CNT; i < (LOSCFG_PLATFORM_HWI_LIMIT + OS_SYS_VECTOR_CNT); i++) {
|
for (i = OS_SYS_VECTOR_CNT; i < (LOSCFG_PLATFORM_HWI_LIMIT + OS_SYS_VECTOR_CNT); i++) {
|
||||||
g_hwiForm[i] = (HWI_PROC_FUNC)IrqEntry;
|
hwiForm[i] = (HWI_PROC_FUNC)IrqEntry;
|
||||||
}
|
}
|
||||||
HalHwiHandleReInit((UINT32)&g_hwiForm);
|
HalHwiHandleReInit((UINT32)hwiForm);
|
||||||
|
|
||||||
HalSetVbr((UINT32)&g_hwiForm);
|
HalSetVbr((UINT32)hwiForm);
|
||||||
for (i = 0; i < BYTES_OF_128_INT; i++) {
|
for (i = 0; i < BYTES_OF_128_INT; i++) {
|
||||||
VIC_REG->IABR[i] = 0x0;
|
VIC_REG->IABR[i] = 0x0;
|
||||||
VIC_REG->ICPR[i] = MASK_32_BITS;
|
VIC_REG->ICPR[i] = MASK_32_BITS;
|
||||||
|
|||||||
@@ -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-2022 Huawei Device Co., Ltd. All rights reserved.
|
* Copyright (c) 2020-2023 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,6 +31,7 @@
|
|||||||
|
|
||||||
#ifndef _LOS_INTERRUPT_H
|
#ifndef _LOS_INTERRUPT_H
|
||||||
#define _LOS_INTERRUPT_H
|
#define _LOS_INTERRUPT_H
|
||||||
|
|
||||||
#include "los_config.h"
|
#include "los_config.h"
|
||||||
#include "los_compiler.h"
|
#include "los_compiler.h"
|
||||||
|
|
||||||
@@ -41,11 +42,8 @@ extern "C" {
|
|||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
typedef UINT32 HWI_HANDLE_T;
|
typedef UINT32 HWI_HANDLE_T;
|
||||||
|
|
||||||
typedef UINT16 HWI_PRIOR_T;
|
typedef UINT16 HWI_PRIOR_T;
|
||||||
|
|
||||||
typedef UINT16 HWI_MODE_T;
|
typedef UINT16 HWI_MODE_T;
|
||||||
|
|
||||||
typedef UINT32 HWI_ARG_T;
|
typedef UINT32 HWI_ARG_T;
|
||||||
|
|
||||||
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
|
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
|
||||||
@@ -53,6 +51,7 @@ typedef VOID (*HWI_PROC_FUNC)(VOID *parm);
|
|||||||
#else
|
#else
|
||||||
typedef VOID (*HWI_PROC_FUNC)(void);
|
typedef VOID (*HWI_PROC_FUNC)(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct tagIrqParam {
|
typedef struct tagIrqParam {
|
||||||
int swIrq; /**< The interrupt number */
|
int swIrq; /**< The interrupt number */
|
||||||
VOID *pDevId; /**< The pointer to the device ID that launches the interrupt */
|
VOID *pDevId; /**< The pointer to the device ID that launches the interrupt */
|
||||||
@@ -66,37 +65,17 @@ typedef struct {
|
|||||||
UINT32 (*disableIrq)(HWI_HANDLE_T hwiNum);
|
UINT32 (*disableIrq)(HWI_HANDLE_T hwiNum);
|
||||||
UINT32 (*setIrqPriority)(HWI_HANDLE_T hwiNum, UINT8 priority);
|
UINT32 (*setIrqPriority)(HWI_HANDLE_T hwiNum, UINT8 priority);
|
||||||
UINT32 (*getCurIrqNum)(VOID);
|
UINT32 (*getCurIrqNum)(VOID);
|
||||||
|
UINT32 (*createIrq)(HWI_HANDLE_T hwiNum, HWI_PRIOR_T hwiPrio);
|
||||||
} HwiControllerOps;
|
} HwiControllerOps;
|
||||||
|
|
||||||
extern HwiControllerOps g_archHwiOps;
|
|
||||||
|
|
||||||
/* stack protector */
|
/* stack protector */
|
||||||
extern UINT32 __stack_chk_guard;
|
extern UINT32 __stack_chk_guard;
|
||||||
|
|
||||||
extern VOID __stack_chk_fail(VOID);
|
extern VOID __stack_chk_fail(VOID);
|
||||||
|
#if (LOSCFG_DEBUG_TOOLS == 1)
|
||||||
UINT32 ArchIsIntActive(VOID);
|
extern UINT32 OsGetHwiFormCnt(UINT32 index);
|
||||||
#define OS_INT_ACTIVE (ArchIsIntActive())
|
extern CHAR *OsGetHwiFormName(UINT32 index);
|
||||||
#define OS_INT_INACTIVE (!(OS_INT_ACTIVE))
|
extern BOOL OsHwiIsCreated(UINT32 index);
|
||||||
#define LOS_HwiCreate ArchHwiCreate
|
#endif
|
||||||
#define LOS_HwiDelete ArchHwiDelete
|
|
||||||
#define LOS_HwiTrigger ArchIntTrigger
|
|
||||||
#define LOS_HwiEnable ArchIntEnable
|
|
||||||
#define LOS_HwiDisable ArchIntDisable
|
|
||||||
#define LOS_HwiClear ArchIntClear
|
|
||||||
#define LOS_HwiSetPriority ArchIntSetPriority
|
|
||||||
#define LOS_HwiCurIrqNum ArchIntCurIrqNum
|
|
||||||
|
|
||||||
UINT32 ArchIntLock(VOID);
|
|
||||||
#define LOS_IntLock ArchIntLock
|
|
||||||
|
|
||||||
VOID ArchIntRestore(UINT32 intSave);
|
|
||||||
#define LOS_IntRestore ArchIntRestore
|
|
||||||
|
|
||||||
UINT32 ArchIntUnLock(VOID);
|
|
||||||
#define LOS_IntUnLock ArchIntUnLock
|
|
||||||
|
|
||||||
#define LOS_HwiOpsGet ArchIntOpsGet
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ingroup los_interrupt
|
* @ingroup los_interrupt
|
||||||
@@ -162,70 +141,34 @@ UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam);
|
|||||||
* <ul><li>los_interrupt.h: the header file that contains the API declaration.</li></ul>
|
* <ul><li>los_interrupt.h: the header file that contains the API declaration.</li></ul>
|
||||||
* @see None.
|
* @see None.
|
||||||
*/
|
*/
|
||||||
UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum, HWI_PRIOR_T hwiPrio, HWI_MODE_T mode,
|
||||||
HWI_PRIOR_T hwiPrio,
|
HWI_PROC_FUNC handler, HwiIrqParam *irqParam);
|
||||||
HWI_MODE_T mode,
|
UINT32 ArchIsIntActive(VOID);
|
||||||
HWI_PROC_FUNC handler,
|
UINT32 ArchIntLock(VOID);
|
||||||
HwiIrqParam *irqParam);
|
UINT32 ArchIntUnLock(VOID);
|
||||||
|
VOID ArchIntRestore(UINT32 intSave);
|
||||||
|
UINT32 ArchIntTrigger(HWI_HANDLE_T hwiNum);
|
||||||
|
UINT32 ArchIntEnable(HWI_HANDLE_T hwiNum);
|
||||||
|
UINT32 ArchIntDisable(HWI_HANDLE_T hwiNum);
|
||||||
|
UINT32 ArchIntClear(HWI_HANDLE_T hwiNum);
|
||||||
|
UINT32 ArchIntSetPriority(HWI_HANDLE_T hwiNum, HWI_PRIOR_T priority);
|
||||||
|
UINT32 ArchIntCurIrqNum(VOID);
|
||||||
|
HwiControllerOps *ArchIntOpsGet(VOID);
|
||||||
|
|
||||||
STATIC INLINE UINT32 ArchIntTrigger(HWI_HANDLE_T hwiNum)
|
#define OS_INT_ACTIVE (ArchIsIntActive())
|
||||||
{
|
#define OS_INT_INACTIVE (!(OS_INT_ACTIVE))
|
||||||
if (g_archHwiOps.triggerIrq == NULL) {
|
#define LOS_IntLock ArchIntLock
|
||||||
return LOS_NOK;
|
#define LOS_IntRestore ArchIntRestore
|
||||||
}
|
#define LOS_IntUnLock ArchIntUnLock
|
||||||
return g_archHwiOps.triggerIrq(hwiNum);
|
#define LOS_HwiDelete ArchHwiDelete
|
||||||
}
|
#define LOS_HwiCreate ArchHwiCreate
|
||||||
|
#define LOS_HwiTrigger ArchIntTrigger
|
||||||
STATIC INLINE UINT32 ArchIntEnable(HWI_HANDLE_T hwiNum)
|
#define LOS_HwiEnable ArchIntEnable
|
||||||
{
|
#define LOS_HwiDisable ArchIntDisable
|
||||||
if (g_archHwiOps.enableIrq == NULL) {
|
#define LOS_HwiClear ArchIntClear
|
||||||
return LOS_NOK;
|
#define LOS_HwiSetPriority ArchIntSetPriority
|
||||||
}
|
#define LOS_HwiCurIrqNum ArchIntCurIrqNum
|
||||||
return g_archHwiOps.enableIrq(hwiNum);
|
#define LOS_HwiOpsGet ArchIntOpsGet
|
||||||
}
|
|
||||||
|
|
||||||
STATIC INLINE UINT32 ArchIntDisable(HWI_HANDLE_T hwiNum)
|
|
||||||
{
|
|
||||||
if (g_archHwiOps.disableIrq == NULL) {
|
|
||||||
return LOS_NOK;
|
|
||||||
}
|
|
||||||
return g_archHwiOps.disableIrq(hwiNum);
|
|
||||||
}
|
|
||||||
|
|
||||||
STATIC INLINE UINT32 ArchIntClear(HWI_HANDLE_T hwiNum)
|
|
||||||
{
|
|
||||||
if (g_archHwiOps.clearIrq == NULL) {
|
|
||||||
return LOS_NOK;
|
|
||||||
}
|
|
||||||
return g_archHwiOps.clearIrq(hwiNum);
|
|
||||||
}
|
|
||||||
|
|
||||||
STATIC INLINE UINT32 ArchIntSetPriority(HWI_HANDLE_T hwiNum, HWI_PRIOR_T priority)
|
|
||||||
{
|
|
||||||
if (g_archHwiOps.setIrqPriority == NULL) {
|
|
||||||
return LOS_NOK;
|
|
||||||
}
|
|
||||||
return g_archHwiOps.setIrqPriority(hwiNum, priority);
|
|
||||||
}
|
|
||||||
|
|
||||||
STATIC INLINE UINT32 ArchIntCurIrqNum(VOID)
|
|
||||||
{
|
|
||||||
if (g_archHwiOps.getCurIrqNum == NULL) {
|
|
||||||
return LOS_NOK;
|
|
||||||
}
|
|
||||||
return g_archHwiOps.getCurIrqNum();
|
|
||||||
}
|
|
||||||
|
|
||||||
STATIC INLINE HwiControllerOps *ArchIntOpsGet(VOID)
|
|
||||||
{
|
|
||||||
return &g_archHwiOps;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if (LOSCFG_DEBUG_TOOLS == 1)
|
|
||||||
extern UINT32 OsGetHwiFormCnt(UINT32 index);
|
|
||||||
extern CHAR *OsGetHwiFormName(UINT32 index);
|
|
||||||
extern BOOL OsGetHwiCreated(UINT32 index);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
|
|||||||
@@ -30,5 +30,8 @@
|
|||||||
import("//kernel/liteos_m/liteos.gni")
|
import("//kernel/liteos_m/liteos.gni")
|
||||||
|
|
||||||
module_group("risc-v") {
|
module_group("risc-v") {
|
||||||
modules = [ "riscv32/gcc" ]
|
modules = [
|
||||||
|
"common",
|
||||||
|
"riscv32/gcc",
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
# Copyright (c) 2023-2023 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 = "common"
|
||||||
|
kernel_module(module_name) {
|
||||||
|
sources = [ "los_common_interrupt.c" ]
|
||||||
|
configs += [ "$LITEOSTOPDIR:warn_config" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
config("public") {
|
||||||
|
include_dirs = [ "." ]
|
||||||
|
}
|
||||||
@@ -0,0 +1,103 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2023-2023 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_arch_interrupt.h"
|
||||||
|
#include "los_debug.h"
|
||||||
|
|
||||||
|
LITE_OS_SEC_BSS UINT32 g_intCount = 0;
|
||||||
|
|
||||||
|
UINT32 ArchIsIntActive(VOID)
|
||||||
|
{
|
||||||
|
return (g_intCount > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
LITE_OS_SEC_TEXT_INIT VOID HalHwiDefaultHandler(VOID *arg)
|
||||||
|
{
|
||||||
|
(VOID)arg;
|
||||||
|
PRINT_ERR("default handler\n");
|
||||||
|
while (1) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
UINT32 ArchIntTrigger(HWI_HANDLE_T hwiNum)
|
||||||
|
{
|
||||||
|
HwiControllerOps *hwiOps = ArchIntOpsGet();
|
||||||
|
if (hwiOps->triggerIrq == NULL) {
|
||||||
|
return OS_ERRNO_HWI_OPS_FUNC_NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return hwiOps->triggerIrq(hwiNum);
|
||||||
|
}
|
||||||
|
|
||||||
|
UINT32 ArchIntEnable(HWI_HANDLE_T hwiNum)
|
||||||
|
{
|
||||||
|
HwiControllerOps *hwiOps = ArchIntOpsGet();
|
||||||
|
if (hwiOps->enableIrq == NULL) {
|
||||||
|
return OS_ERRNO_HWI_OPS_FUNC_NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return hwiOps->enableIrq(hwiNum);
|
||||||
|
}
|
||||||
|
|
||||||
|
UINT32 ArchIntDisable(HWI_HANDLE_T hwiNum)
|
||||||
|
{
|
||||||
|
HwiControllerOps *hwiOps = ArchIntOpsGet();
|
||||||
|
if (hwiOps->disableIrq == NULL) {
|
||||||
|
return OS_ERRNO_HWI_OPS_FUNC_NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return hwiOps->disableIrq(hwiNum);
|
||||||
|
}
|
||||||
|
|
||||||
|
UINT32 ArchIntClear(HWI_HANDLE_T hwiNum)
|
||||||
|
{
|
||||||
|
HwiControllerOps *hwiOps = ArchIntOpsGet();
|
||||||
|
if (hwiOps->clearIrq == NULL) {
|
||||||
|
return OS_ERRNO_HWI_OPS_FUNC_NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return hwiOps->clearIrq(hwiNum);
|
||||||
|
}
|
||||||
|
|
||||||
|
UINT32 ArchIntSetPriority(HWI_HANDLE_T hwiNum, HWI_PRIOR_T priority)
|
||||||
|
{
|
||||||
|
HwiControllerOps *hwiOps = ArchIntOpsGet();
|
||||||
|
if (hwiOps->setIrqPriority == NULL) {
|
||||||
|
return OS_ERRNO_HWI_OPS_FUNC_NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return hwiOps->setIrqPriority(hwiNum, priority);
|
||||||
|
}
|
||||||
|
|
||||||
|
UINT32 ArchIntCurIrqNum(VOID)
|
||||||
|
{
|
||||||
|
HwiControllerOps *hwiOps = ArchIntOpsGet();
|
||||||
|
return hwiOps->getCurIrqNum();
|
||||||
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2023-2023 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_COMMON_INTERRUPT_H
|
||||||
|
#define _LOS_COMMON_INTERRUPT_H
|
||||||
|
|
||||||
|
#include "los_config.h"
|
||||||
|
#include "los_compiler.h"
|
||||||
|
#include "los_interrupt.h"
|
||||||
|
#include "los_arch_context.h"
|
||||||
|
#include "los_error.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#if __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Count of interrupts.
|
||||||
|
*/
|
||||||
|
extern UINT32 g_intCount;
|
||||||
|
|
||||||
|
extern VOID HalHwiDefaultHandler(VOID *arg);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#if __cplusplus
|
||||||
|
}
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
#endif /* _LOS_COMMON_INTERRUPT_H */
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2013-2020, Huawei Technologies Co., Ltd. All rights reserved.
|
* Copyright (c) 2013-2020, Huawei Technologies Co., Ltd. All rights reserved.
|
||||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
* Copyright (c) 2020-2023 Huawei Device Co., Ltd. All rights reserved.
|
||||||
* Copyright (c) 2021 Nuclei Limited. All rights reserved.
|
* Copyright (c) 2021 Nuclei Limited. 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,
|
||||||
@@ -29,14 +29,12 @@
|
|||||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
#ifndef _LOS_HWI_H
|
|
||||||
#define _LOS_HWI_H
|
|
||||||
|
|
||||||
|
#ifndef _LOS_ARCH_INTERRUPT_H
|
||||||
|
#define _LOS_ARCH_INTERRUPT_H
|
||||||
|
|
||||||
|
#include "los_common_interrupt.h"
|
||||||
#include "nuclei_sdk_soc.h"
|
#include "nuclei_sdk_soc.h"
|
||||||
#include "los_compiler.h"
|
|
||||||
#include "los_config.h"
|
|
||||||
#include "los_interrupt.h"
|
|
||||||
#include "los_arch_context.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
@@ -192,6 +190,16 @@ extern VOID HalHwiDefaultHandler(VOID);
|
|||||||
*/
|
*/
|
||||||
#define OS_ERRNO_HWI_HWINUM_UNCREATE LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x0b)
|
#define OS_ERRNO_HWI_HWINUM_UNCREATE LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x0b)
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Hardware interrupt error code: Invalid interrupt operation function.
|
||||||
|
*
|
||||||
|
* Value: 0x0200090c
|
||||||
|
*
|
||||||
|
* Solution: Set a valid interrupt operation function
|
||||||
|
*/
|
||||||
|
#define OS_ERRNO_HWI_OPS_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x0c)
|
||||||
|
|
||||||
extern UINT32 HalUnalignedAccessFix(UINTPTR mcause, UINTPTR mepc, UINTPTR mtval, VOID *sp);
|
extern UINT32 HalUnalignedAccessFix(UINTPTR mcause, UINTPTR mepc, UINTPTR mtval, VOID *sp);
|
||||||
|
|
||||||
extern VOID DisplayTaskInfo(VOID);
|
extern VOID DisplayTaskInfo(VOID);
|
||||||
@@ -202,4 +210,4 @@ extern VOID DisplayTaskInfo(VOID);
|
|||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
#endif /* _LOS_HWI_H */
|
#endif /* _LOS_ARCH_INTERRUPT_H */
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
|
* Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
|
||||||
* Copyright (c) 2021 Nuclei Limited. All rights reserved.
|
* Copyright (c) 2021 Nuclei Limited. 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,
|
||||||
@@ -37,8 +38,6 @@
|
|||||||
#include "los_debug.h"
|
#include "los_debug.h"
|
||||||
#include "nuclei_sdk_hal.h"
|
#include "nuclei_sdk_hal.h"
|
||||||
|
|
||||||
UINT32 g_intCount = 0;
|
|
||||||
|
|
||||||
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
|
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
|
||||||
{
|
{
|
||||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||||
@@ -150,20 +149,6 @@ LITE_OS_SEC_TEXT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam
|
|||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ****************************************************************************
|
|
||||||
Function : HalHwiDefaultHandler
|
|
||||||
Description : default handler of the hardware interrupt
|
|
||||||
Input : None
|
|
||||||
Output : None
|
|
||||||
Return : None
|
|
||||||
**************************************************************************** */
|
|
||||||
LITE_OS_SEC_TEXT_INIT VOID HalHwiDefaultHandler(VOID)
|
|
||||||
{
|
|
||||||
PRINT_ERR("default handler\n");
|
|
||||||
while (1) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ****************************************************************************
|
/* ****************************************************************************
|
||||||
Function : HalDisplayTaskInfo
|
Function : HalDisplayTaskInfo
|
||||||
Description : display the task list
|
Description : display the task list
|
||||||
@@ -215,13 +200,13 @@ __attribute__((always_inline)) inline VOID HalIntExit(VOID)
|
|||||||
g_intCount -= 1;
|
g_intCount -= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
__attribute__((always_inline)) inline UINT32 ArchIsIntActive(VOID)
|
STATIC HwiControllerOps g_archHwiOps = {
|
||||||
{
|
|
||||||
return (g_intCount > 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
const HwiControllerOps g_archHwiOps = {
|
|
||||||
.enableIrq = HwiUnmask,
|
.enableIrq = HwiUnmask,
|
||||||
.disableIrq = HwiMask,
|
.disableIrq = HwiMask,
|
||||||
.setIrqPriority = HwiSetPriority,
|
.setIrqPriority = HwiSetPriority,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
HwiControllerOps *ArchIntOpsGet(VOID)
|
||||||
|
{
|
||||||
|
return &g_archHwiOps;
|
||||||
|
}
|
||||||
|
|||||||
@@ -31,11 +31,7 @@
|
|||||||
#ifndef _LOS_ARCH_INTERRUPT_H
|
#ifndef _LOS_ARCH_INTERRUPT_H
|
||||||
#define _LOS_ARCH_INTERRUPT_H
|
#define _LOS_ARCH_INTERRUPT_H
|
||||||
|
|
||||||
#include "los_compiler.h"
|
#include "los_common_interrupt.h"
|
||||||
#include "los_config.h"
|
|
||||||
#include "los_interrupt.h"
|
|
||||||
#include "los_arch_context.h"
|
|
||||||
#include "los_error.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
@@ -146,9 +142,6 @@ extern VOID HalHwiInit(VOID);
|
|||||||
extern UINT32 HalGetHwiFormCnt(HWI_HANDLE_T hwiNum);
|
extern UINT32 HalGetHwiFormCnt(HWI_HANDLE_T hwiNum);
|
||||||
extern HWI_HANDLE_FORM_S *HalGetHwiForm(VOID);
|
extern HWI_HANDLE_FORM_S *HalGetHwiForm(VOID);
|
||||||
extern VOID HalHwiInterruptDone(HWI_HANDLE_T hwiNum);
|
extern VOID HalHwiInterruptDone(HWI_HANDLE_T hwiNum);
|
||||||
extern VOID HalHwiDefaultHandler(VOID *arg);
|
|
||||||
|
|
||||||
extern UINT32 g_intCount;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ingroup los_arch_interrupt
|
* @ingroup los_arch_interrupt
|
||||||
@@ -273,6 +266,16 @@ extern UINT32 g_intCount;
|
|||||||
*/
|
*/
|
||||||
#define OS_ERRNO_HWI_HWINUM_UNCREATE LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x0b)
|
#define OS_ERRNO_HWI_HWINUM_UNCREATE LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x0b)
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Hardware interrupt error code: Invalid interrupt operation function.
|
||||||
|
*
|
||||||
|
* Value: 0x0200090c
|
||||||
|
*
|
||||||
|
* Solution: Set a valid interrupt operation function
|
||||||
|
*/
|
||||||
|
#define OS_ERRNO_HWI_OPS_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x0c)
|
||||||
|
|
||||||
extern UINT32 HalUnalignedAccessFix(UINTPTR mcause, UINTPTR mepc, UINTPTR mtval, VOID *sp);
|
extern UINT32 HalUnalignedAccessFix(UINTPTR mcause, UINTPTR mepc, UINTPTR mtval, VOID *sp);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
@@ -40,7 +40,6 @@
|
|||||||
#include "los_hook.h"
|
#include "los_hook.h"
|
||||||
#include "riscv_hal.h"
|
#include "riscv_hal.h"
|
||||||
|
|
||||||
|
|
||||||
LosExcInfo g_excInfo;
|
LosExcInfo g_excInfo;
|
||||||
#define RISCV_EXC_TYPE_NUM 16
|
#define RISCV_EXC_TYPE_NUM 16
|
||||||
#define RISCV_EXC_LOAD_MISALIGNED 4
|
#define RISCV_EXC_LOAD_MISALIGNED 4
|
||||||
@@ -64,7 +63,6 @@ const CHAR g_excInformation[RISCV_EXC_TYPE_NUM][50] = {
|
|||||||
{ "Store/AMO page fault!" },
|
{ "Store/AMO page fault!" },
|
||||||
};
|
};
|
||||||
|
|
||||||
LITE_OS_SEC_BSS UINT32 g_intCount = 0;
|
|
||||||
LITE_OS_SEC_BSS UINT32 g_hwiFormCnt[OS_HWI_MAX_NUM];
|
LITE_OS_SEC_BSS UINT32 g_hwiFormCnt[OS_HWI_MAX_NUM];
|
||||||
LITE_OS_SEC_DATA_INIT HWI_HANDLE_FORM_S g_hwiForm[OS_HWI_MAX_NUM] = {
|
LITE_OS_SEC_DATA_INIT HWI_HANDLE_FORM_S g_hwiForm[OS_HWI_MAX_NUM] = {
|
||||||
{ .pfnHook = NULL, .uwParam = 0 }, // 0 User software interrupt handler
|
{ .pfnHook = NULL, .uwParam = 0 }, // 0 User software interrupt handler
|
||||||
@@ -95,14 +93,6 @@ LITE_OS_SEC_DATA_INIT HWI_HANDLE_FORM_S g_hwiForm[OS_HWI_MAX_NUM] = {
|
|||||||
{ .pfnHook = NULL, .uwParam = 0 }, // 25 Reserved
|
{ .pfnHook = NULL, .uwParam = 0 }, // 25 Reserved
|
||||||
};
|
};
|
||||||
|
|
||||||
LITE_OS_SEC_TEXT_INIT VOID HalHwiDefaultHandler(VOID *arg)
|
|
||||||
{
|
|
||||||
(VOID)arg;
|
|
||||||
PRINT_ERR("default handler\n");
|
|
||||||
while (1) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
|
LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
|
||||||
{
|
{
|
||||||
UINT32 index;
|
UINT32 index;
|
||||||
@@ -144,12 +134,6 @@ LITE_OS_SEC_TEXT HWI_HANDLE_FORM_S *HalGetHwiForm(VOID)
|
|||||||
return g_hwiForm;
|
return g_hwiForm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline UINT32 ArchIsIntActive(VOID)
|
|
||||||
{
|
|
||||||
return (g_intCount > 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
Function : ArchHwiCreate
|
Function : ArchHwiCreate
|
||||||
Description : create hardware interrupt
|
Description : create hardware interrupt
|
||||||
@@ -348,3 +332,9 @@ SYSTEM_DEATH:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LITE_OS_SEC_BSS STATIC HwiControllerOps g_archHwiOps;
|
||||||
|
|
||||||
|
HwiControllerOps *ArchIntOpsGet(VOID)
|
||||||
|
{
|
||||||
|
return &g_archHwiOps;
|
||||||
|
}
|
||||||
|
|||||||
@@ -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-2023 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:
|
||||||
@@ -30,5 +30,8 @@
|
|||||||
import("//kernel/liteos_m/liteos.gni")
|
import("//kernel/liteos_m/liteos.gni")
|
||||||
|
|
||||||
module_group("xtensa") {
|
module_group("xtensa") {
|
||||||
modules = [ "lx6/gcc" ]
|
modules = [
|
||||||
|
"common",
|
||||||
|
"lx6/gcc",
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
# Copyright (c) 2023-2023 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 = "common"
|
||||||
|
kernel_module(module_name) {
|
||||||
|
sources = [ "los_common_interrupt.c" ]
|
||||||
|
configs += [ "$LITEOSTOPDIR:warn_config" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
config("public") {
|
||||||
|
include_dirs = [ "." ]
|
||||||
|
}
|
||||||
@@ -0,0 +1,275 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2023-2023 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_arch_interrupt.h"
|
||||||
|
#include "los_debug.h"
|
||||||
|
|
||||||
|
UINT32 g_intCount = 0;
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @ingroup los_hwi
|
||||||
|
* Hardware interrupt form mapping handling function array.
|
||||||
|
*/
|
||||||
|
HWI_PROC_FUNC __attribute__((aligned(LOSCFG_ARCH_HWI_VECTOR_ALIGN))) g_hwiForm[OS_VECTOR_CNT] = {0};
|
||||||
|
|
||||||
|
VOID *ArchGetHwiFrom(VOID)
|
||||||
|
{
|
||||||
|
return g_hwiForm;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ****************************************************************************
|
||||||
|
Function : HalHwiDefaultHandler
|
||||||
|
Description : default handler of the hardware interrupt
|
||||||
|
Input : None
|
||||||
|
Output : None
|
||||||
|
Return : None
|
||||||
|
**************************************************************************** */
|
||||||
|
VOID HalHwiDefaultHandler(VOID)
|
||||||
|
{
|
||||||
|
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, ArchIntCurIrqNum());
|
||||||
|
while (1) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
WEAK VOID HalPreInterruptHandler(UINT32 arg)
|
||||||
|
{
|
||||||
|
(VOID)arg;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
WEAK VOID HalAftInterruptHandler(UINT32 arg)
|
||||||
|
{
|
||||||
|
(VOID)arg;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC UINT32 HwiNumValid(UINT32 num)
|
||||||
|
{
|
||||||
|
return (num >= OS_SYS_VECTOR_CNT) && (num <= OS_VECTOR_CNT);
|
||||||
|
}
|
||||||
|
|
||||||
|
UINT32 ArchIntTrigger(HWI_HANDLE_T hwiNum)
|
||||||
|
{
|
||||||
|
if (!HwiNumValid(hwiNum)) {
|
||||||
|
return OS_ERRNO_HWI_NUM_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
HwiControllerOps *hwiOps = ArchIntOpsGet();
|
||||||
|
if (hwiOps->triggerIrq == NULL) {
|
||||||
|
return OS_ERRNO_HWI_OPS_FUNC_NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return hwiOps->triggerIrq(hwiNum);
|
||||||
|
}
|
||||||
|
|
||||||
|
UINT32 ArchIntEnable(HWI_HANDLE_T hwiNum)
|
||||||
|
{
|
||||||
|
if (!HwiNumValid(hwiNum)) {
|
||||||
|
return OS_ERRNO_HWI_NUM_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
HwiControllerOps *hwiOps = ArchIntOpsGet();
|
||||||
|
if (hwiOps->enableIrq == NULL) {
|
||||||
|
return OS_ERRNO_HWI_OPS_FUNC_NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return hwiOps->enableIrq(hwiNum);
|
||||||
|
}
|
||||||
|
|
||||||
|
UINT32 ArchIntDisable(HWI_HANDLE_T hwiNum)
|
||||||
|
{
|
||||||
|
if (!HwiNumValid(hwiNum)) {
|
||||||
|
return OS_ERRNO_HWI_NUM_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
HwiControllerOps *hwiOps = ArchIntOpsGet();
|
||||||
|
if (hwiOps->disableIrq == NULL) {
|
||||||
|
return OS_ERRNO_HWI_OPS_FUNC_NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return hwiOps->disableIrq(hwiNum);
|
||||||
|
}
|
||||||
|
|
||||||
|
UINT32 ArchIntClear(HWI_HANDLE_T hwiNum)
|
||||||
|
{
|
||||||
|
if (!HwiNumValid(hwiNum)) {
|
||||||
|
return OS_ERRNO_HWI_NUM_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
HwiControllerOps *hwiOps = ArchIntOpsGet();
|
||||||
|
if (hwiOps->clearIrq == NULL) {
|
||||||
|
return OS_ERRNO_HWI_OPS_FUNC_NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return hwiOps->clearIrq(hwiNum);
|
||||||
|
}
|
||||||
|
|
||||||
|
UINT32 ArchIntCurIrqNum(VOID)
|
||||||
|
{
|
||||||
|
HwiControllerOps *hwiOps = ArchIntOpsGet();
|
||||||
|
return hwiOps->getCurIrqNum();
|
||||||
|
}
|
||||||
|
|
||||||
|
#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.
|
||||||
|
*/
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
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
|
||||||
|
|
||||||
|
/* ****************************************************************************
|
||||||
|
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
|
||||||
|
**************************************************************************** */
|
||||||
|
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
|
||||||
|
|
||||||
|
HwiControllerOps *hwiOps = ArchIntOpsGet();
|
||||||
|
if (hwiOps->createIrq == NULL) {
|
||||||
|
LOS_IntRestore(intSave);
|
||||||
|
return OS_ERRNO_HWI_OPS_FUNC_NULL;
|
||||||
|
}
|
||||||
|
hwiOps->createIrq(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;
|
||||||
|
}
|
||||||
|
|
||||||
|
ArchIntDisable(hwiNum);
|
||||||
|
|
||||||
|
intSave = LOS_IntLock();
|
||||||
|
|
||||||
|
g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
|
||||||
|
|
||||||
|
LOS_IntRestore(intSave);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
UINT32 ArchIsIntActive(VOID)
|
||||||
|
{
|
||||||
|
return (g_intCount > 0);
|
||||||
|
}
|
||||||
@@ -0,0 +1,97 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2023-2023 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_COMMON_INTERRUPT_H
|
||||||
|
#define _LOS_COMMON_INTERRUPT_H
|
||||||
|
|
||||||
|
#include "los_config.h"
|
||||||
|
#include "los_compiler.h"
|
||||||
|
#include "los_interrupt.h"
|
||||||
|
#include "los_error.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#if __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @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
|
||||||
|
* Maximum number of used hardware interrupts.
|
||||||
|
*/
|
||||||
|
#ifndef OS_HWI_MAX_NUM
|
||||||
|
#define OS_HWI_MAX_NUM LOSCFG_PLATFORM_HWI_LIMIT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#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);
|
||||||
|
extern HWI_HANDLER_FUNC g_hwiHandlerForm[];
|
||||||
|
#else
|
||||||
|
/* *
|
||||||
|
* @ingroup los_arch_interrupt
|
||||||
|
* Set interrupt vector table.
|
||||||
|
*/
|
||||||
|
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
|
||||||
|
extern HWI_PROC_FUNC g_hwiHandlerForm[];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define OS_EXC_IN_INIT 0
|
||||||
|
#define OS_EXC_IN_TASK 1
|
||||||
|
#define OS_EXC_IN_HWI 2
|
||||||
|
|
||||||
|
extern VOID HalHwiDefaultHandler(VOID);
|
||||||
|
|
||||||
|
VOID HalPreInterruptHandler(UINT32 arg);
|
||||||
|
VOID HalAftInterruptHandler(UINT32 arg);
|
||||||
|
VOID *ArchGetHwiFrom(VOID);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#if __cplusplus
|
||||||
|
}
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
#endif /* _LOS_COMMON_INTERRUPT_H */
|
||||||
@@ -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-2023 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:
|
||||||
@@ -32,9 +32,7 @@
|
|||||||
#ifndef _LOS_ARCH_INTERRUPT_H
|
#ifndef _LOS_ARCH_INTERRUPT_H
|
||||||
#define _LOS_ARCH_INTERRUPT_H
|
#define _LOS_ARCH_INTERRUPT_H
|
||||||
|
|
||||||
#include "los_config.h"
|
#include "los_common_interrupt.h"
|
||||||
#include "los_compiler.h"
|
|
||||||
#include "los_interrupt.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
@@ -67,14 +65,6 @@ typedef struct {
|
|||||||
extern CHAR *VECTOR_START;
|
extern CHAR *VECTOR_START;
|
||||||
#define INIT_VECTOR_START ((UINTPTR)&VECTOR_START)
|
#define INIT_VECTOR_START ((UINTPTR)&VECTOR_START)
|
||||||
|
|
||||||
/* *
|
|
||||||
* @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
|
* @ingroup los_arch_interrupt
|
||||||
* Highest priority of a hardware interrupt.
|
* Highest priority of a hardware interrupt.
|
||||||
@@ -91,22 +81,6 @@ extern CHAR *VECTOR_START;
|
|||||||
#define OS_HWI_PRIO_LOWEST 7
|
#define OS_HWI_PRIO_LOWEST 7
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define OS_EXC_IN_INIT 0
|
|
||||||
#define OS_EXC_IN_TASK 1
|
|
||||||
#define OS_EXC_IN_HWI 2
|
|
||||||
|
|
||||||
/* *
|
|
||||||
* @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
|
* @ingroup los_arch_interrupt
|
||||||
* Count of Xtensa system interrupt vector.
|
* Count of Xtensa system interrupt vector.
|
||||||
@@ -199,22 +173,17 @@ extern UINT32 g_intCount;
|
|||||||
*/
|
*/
|
||||||
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
|
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
|
||||||
|
|
||||||
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_arch_interrupt
|
* @ingroup los_arch_interrupt
|
||||||
* Set interrupt vector table.
|
* Hardware interrupt error code: Invalid interrupt operation function.
|
||||||
|
*
|
||||||
|
* Value: 0x0200090c
|
||||||
|
*
|
||||||
|
* Solution: Set a valid interrupt operation function
|
||||||
*/
|
*/
|
||||||
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg);
|
#define OS_ERRNO_HWI_OPS_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x0c)
|
||||||
#else
|
|
||||||
/* *
|
|
||||||
* @ingroup los_arch_interrupt
|
|
||||||
* Set interrupt vector table.
|
|
||||||
*/
|
|
||||||
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
VOID HalInterrupt(VOID);
|
VOID HalInterrupt(VOID);
|
||||||
VOID HalHwiDefaultHandler(VOID);
|
|
||||||
VOID HalExcHandleEntry(UINTPTR faultAddr, EXC_CONTEXT_S *excBufAddr, UINT32 type);
|
VOID HalExcHandleEntry(UINTPTR faultAddr, EXC_CONTEXT_S *excBufAddr, UINT32 type);
|
||||||
VOID HalHwiInit(VOID);
|
VOID HalHwiInit(VOID);
|
||||||
|
|
||||||
|
|||||||
@@ -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-2023 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:
|
||||||
@@ -29,7 +29,6 @@
|
|||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "los_interrupt.h"
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include "securec.h"
|
#include "securec.h"
|
||||||
#include "los_context.h"
|
#include "los_context.h"
|
||||||
@@ -42,65 +41,6 @@
|
|||||||
#include "los_membox.h"
|
#include "los_membox.h"
|
||||||
#include "los_arch_regs.h"
|
#include "los_arch_regs.h"
|
||||||
|
|
||||||
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_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
|
|
||||||
|
|
||||||
UINT32 HwiNumValid(UINT32 num)
|
|
||||||
{
|
|
||||||
return (num >= OS_SYS_VECTOR_CNT) && (num <= OS_VECTOR_CNT);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
* @ingroup los_hwi
|
* @ingroup los_hwi
|
||||||
* Lock all interrupt.
|
* Lock all interrupt.
|
||||||
@@ -154,37 +94,24 @@ STATIC INLINE UINT32 ArchIntLocked(VOID)
|
|||||||
*/
|
*/
|
||||||
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
|
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
|
||||||
{
|
{
|
||||||
if (!HwiNumValid(hwiNum)) {
|
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
__asm__ __volatile__("wsr %0, intset; rsync" : : "a"(0x1U << hwiNum));
|
__asm__ __volatile__("wsr %0, intset; rsync" : : "a"(0x1U << hwiNum));
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
|
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
|
||||||
{
|
{
|
||||||
UINT32 ier;
|
UINT32 ier;
|
||||||
|
|
||||||
if (!HwiNumValid(hwiNum)) {
|
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
__asm__ __volatile__("rsr %0, intenable" : "=a"(ier) : : "memory");
|
__asm__ __volatile__("rsr %0, intenable" : "=a"(ier) : : "memory");
|
||||||
__asm__ __volatile__("wsr %0, intenable; rsync" : : "a"(ier | ((UINT32)0x1U << hwiNum)));
|
__asm__ __volatile__("wsr %0, intenable; rsync" : : "a"(ier | ((UINT32)0x1U << hwiNum)));
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
UINT32 HwiMask(HWI_HANDLE_T hwiNum)
|
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
|
||||||
{
|
{
|
||||||
UINT32 ier;
|
UINT32 ier;
|
||||||
|
|
||||||
if (!HwiNumValid(hwiNum)) {
|
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
__asm__ __volatile__("rsr %0, intenable" : "=a"(ier) : : "memory");
|
__asm__ __volatile__("rsr %0, intenable" : "=a"(ier) : : "memory");
|
||||||
__asm__ __volatile__("wsr %0, intenable; rsync" : : "a"(ier & ~((UINT32)0x1U << hwiNum)));
|
__asm__ __volatile__("wsr %0, intenable; rsync" : : "a"(ier & ~((UINT32)0x1U << hwiNum)));
|
||||||
|
|
||||||
@@ -216,53 +143,32 @@ STATIC UINT32 HwiNumGet(VOID)
|
|||||||
* @ingroup los_hwi
|
* @ingroup los_hwi
|
||||||
* Clear the interrupt
|
* Clear the interrupt
|
||||||
*/
|
*/
|
||||||
STATIC UINT32 HwiClear(HWI_HANDLE_T vector)
|
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
|
||||||
{
|
{
|
||||||
if (!HwiNumValid(vector)) {
|
__asm__ __volatile__("wsr %0, intclear; rsync" : : "a"(0x1U << hwiNum));
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
__asm__ __volatile__("wsr %0, intclear; rsync" : : "a"(0x1U << vector));
|
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
HwiControllerOps g_archHwiOps = {
|
STATIC UINT32 HwiCreate(HWI_HANDLE_T hwiNum, HWI_PRIOR_T hwiPrio)
|
||||||
|
{
|
||||||
|
(VOID)hwiPrio;
|
||||||
|
HwiUnmask(hwiNum);
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC HwiControllerOps g_archHwiOps = {
|
||||||
.triggerIrq = HwiPending,
|
.triggerIrq = HwiPending,
|
||||||
.enableIrq = HwiUnmask,
|
.enableIrq = HwiUnmask,
|
||||||
.disableIrq = HwiMask,
|
.disableIrq = HwiMask,
|
||||||
.getCurIrqNum = HwiNumGet,
|
.getCurIrqNum = HwiNumGet,
|
||||||
.clearIrq = HwiClear,
|
.clearIrq = HwiClear,
|
||||||
|
.createIrq = HwiCreate,
|
||||||
};
|
};
|
||||||
|
|
||||||
INLINE UINT32 ArchIsIntActive(VOID)
|
HwiControllerOps *ArchIntOpsGet(VOID)
|
||||||
{
|
{
|
||||||
return (g_intCount > 0);
|
return &g_archHwiOps;
|
||||||
}
|
|
||||||
|
|
||||||
/* ****************************************************************************
|
|
||||||
Function : HalHwiDefaultHandler
|
|
||||||
Description : default handler of the hardware interrupt
|
|
||||||
Input : None
|
|
||||||
Output : None
|
|
||||||
Return : None
|
|
||||||
**************************************************************************** */
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ****************************************************************************
|
/* ****************************************************************************
|
||||||
@@ -308,88 +214,6 @@ VOID HalInterrupt(VOID)
|
|||||||
HalIrqEndCheckNeedSched();
|
HalIrqEndCheckNeedSched();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ****************************************************************************
|
|
||||||
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
|
|
||||||
**************************************************************************** */
|
|
||||||
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
|
|
||||||
HwiUnmask(hwiNum);
|
|
||||||
|
|
||||||
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(hwiNum);
|
|
||||||
|
|
||||||
intSave = LOS_IntLock();
|
|
||||||
|
|
||||||
g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
|
|
||||||
|
|
||||||
LOS_IntRestore(intSave);
|
|
||||||
|
|
||||||
return LOS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
ExcInfo g_excInfo = {0};
|
ExcInfo g_excInfo = {0};
|
||||||
|
|
||||||
#if (LOSCFG_KERNEL_PRINTF != 0)
|
#if (LOSCFG_KERNEL_PRINTF != 0)
|
||||||
@@ -559,8 +383,9 @@ WEAK VOID __stack_chk_fail(VOID)
|
|||||||
VOID HalHwiInit(VOID)
|
VOID HalHwiInit(VOID)
|
||||||
{
|
{
|
||||||
EnableExceptionInterface();
|
EnableExceptionInterface();
|
||||||
|
HWI_PROC_FUNC *hwiForm = (HWI_PROC_FUNC *)ArchGetHwiFrom();
|
||||||
for (UINT32 i = 0; i < OS_HWI_MAX_NUM; i++) {
|
for (UINT32 i = 0; i < OS_HWI_MAX_NUM; i++) {
|
||||||
g_hwiForm[i + OS_SYS_VECTOR_CNT] = HalHwiDefaultHandler;
|
hwiForm[i + OS_SYS_VECTOR_CNT] = HalHwiDefaultHandler;
|
||||||
HwiMask(i);
|
HwiMask(i);
|
||||||
}
|
}
|
||||||
asm volatile ("wsr %0, vecbase" : : "r"(INIT_VECTOR_START));
|
asm volatile ("wsr %0, vecbase" : : "r"(INIT_VECTOR_START));
|
||||||
|
|||||||
@@ -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-2023 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:
|
||||||
@@ -74,7 +74,7 @@ STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler)
|
|||||||
__asm__ __volatile__("wsr %0, ccompare1; rsync" : : "a"(0));
|
__asm__ __volatile__("wsr %0, ccompare1; rsync" : : "a"(0));
|
||||||
__asm__ __volatile__("wsr %0, ccompare2; rsync" : : "a"(0));
|
__asm__ __volatile__("wsr %0, ccompare2; rsync" : : "a"(0));
|
||||||
|
|
||||||
HwiUnmask(tick->irqNum);
|
LOS_HwiEnable(tick->irqNum);
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,12 +115,12 @@ STATIC UINT64 SysTickCycleGet(UINT32 *period)
|
|||||||
|
|
||||||
STATIC VOID SysTickLock(VOID)
|
STATIC VOID SysTickLock(VOID)
|
||||||
{
|
{
|
||||||
HwiMask(OS_TICK_INT_NUM);
|
LOS_HwiDisable(OS_TICK_INT_NUM);
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC VOID SysTickUnlock(VOID)
|
STATIC VOID SysTickUnlock(VOID)
|
||||||
{
|
{
|
||||||
HwiUnmask(OS_TICK_INT_NUM);
|
LOS_HwiEnable(OS_TICK_INT_NUM);
|
||||||
}
|
}
|
||||||
|
|
||||||
ArchTickTimer *ArchSysTickTimerGet(VOID)
|
ArchTickTimer *ArchSysTickTimerGet(VOID)
|
||||||
|
|||||||
+1
-1
@@ -43,7 +43,7 @@
|
|||||||
"third_party": [
|
"third_party": [
|
||||||
"bounds_checking_function",
|
"bounds_checking_function",
|
||||||
"cmsis",
|
"cmsis",
|
||||||
"fatfs",
|
"FatFs",
|
||||||
"littlefs",
|
"littlefs",
|
||||||
"lwip",
|
"lwip",
|
||||||
"musl"
|
"musl"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
|
* Copyright (c) 2022-2023 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,7 +63,7 @@ STATIC VOID ShellCmdHwiInfoShow(OsIrqCpupCB *irqData, CPUP_INFO_S *hwiCpup1s,
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < LOSCFG_PLATFORM_HWI_LIMIT; i++) {
|
for (i = 0; i < LOSCFG_PLATFORM_HWI_LIMIT; i++) {
|
||||||
if ((OsGetHwiCreated(i) != TRUE) || (OsGetHwiFormCnt(i) == 0)) {
|
if ((OsHwiIsCreated(i) != TRUE) || (OsGetHwiFormCnt(i) == 0)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,9 +118,9 @@ STATIC VOID HwiInfoDump(VOID)
|
|||||||
{
|
{
|
||||||
INT32 i;
|
INT32 i;
|
||||||
|
|
||||||
PRINTK(" InterruptNo Count Name\n");
|
PRINTK(" InterruptNo Count Name\n");
|
||||||
for (i = 0; i < LOSCFG_PLATFORM_HWI_LIMIT; i++) {
|
for (i = 0; i < LOSCFG_PLATFORM_HWI_LIMIT; i++) {
|
||||||
if ((OsGetHwiCreated(i) != TRUE) || (OsGetHwiFormCnt(i) == 0)) {
|
if ((OsHwiIsCreated(i) != TRUE) || (OsGetHwiFormCnt(i) == 0)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,8 +128,8 @@ STATIC VOID HwiInfoDump(VOID)
|
|||||||
PRINTK(" %8d:%10d %-s\n", i - OS_SYS_VECTOR_CNT, OsGetHwiFormCnt(i), OsGetHwiFormName(i));
|
PRINTK(" %8d:%10d %-s\n", i - OS_SYS_VECTOR_CNT, OsGetHwiFormCnt(i), OsGetHwiFormName(i));
|
||||||
} else {
|
} else {
|
||||||
PRINTK(" %8d:%10d\n", i - OS_SYS_VECTOR_CNT, OsGetHwiFormCnt(i));
|
PRINTK(" %8d:%10d\n", i - OS_SYS_VECTOR_CNT, OsGetHwiFormCnt(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -144,6 +144,6 @@ UINT32 OsShellCmdHwiDump(INT32 argc, const CHAR **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
HwiInfoDump();
|
HwiInfoDump();
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
#endif /* LOSCFG_STACK_DUMP == 1 */
|
#endif /* LOSCFG_STACK_DUMP == 1 */
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ extern "C" {
|
|||||||
#else
|
#else
|
||||||
#define MAX_SWITCH_INFO_SIZE (0)
|
#define MAX_SWITCH_INFO_SIZE (0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define MAX_MEM_INFO_SIZE (INFO_TYPE_AND_SIZE + sizeof(MemInfoCB) * OS_SYS_MEM_NUM)
|
#define MAX_MEM_INFO_SIZE (INFO_TYPE_AND_SIZE + sizeof(MemInfoCB) * OS_SYS_MEM_NUM)
|
||||||
#define MAX_EXC_MEM_SIZE (INFO_TYPE_AND_SIZE + MAX_SCENE_INFO_SIZE + MAX_TSK_INFO_SIZE + MAX_QUEUE_INFO_SIZE \
|
#define MAX_EXC_MEM_SIZE (INFO_TYPE_AND_SIZE + MAX_SCENE_INFO_SIZE + MAX_TSK_INFO_SIZE + MAX_QUEUE_INFO_SIZE \
|
||||||
+ MAX_INT_INFO_SIZE + MAX_SWITCH_INFO_SIZE + MAX_MEM_INFO_SIZE)
|
+ MAX_INT_INFO_SIZE + MAX_SWITCH_INFO_SIZE + MAX_MEM_INFO_SIZE)
|
||||||
|
|||||||
@@ -31,11 +31,4 @@ config LMS_CHECK_STRICT
|
|||||||
default n
|
default n
|
||||||
depends on KERNEL_LMS
|
depends on KERNEL_LMS
|
||||||
help
|
help
|
||||||
Select y to enable byte-by-byte check in lms
|
Select y to enable byte-by-byte check in Lms
|
||||||
|
|
||||||
config LMS_LIBC_FULL_CHECK
|
|
||||||
bool "Enable libc all function do lms check"
|
|
||||||
default n
|
|
||||||
depends on KERNEL_LMS
|
|
||||||
help
|
|
||||||
Select y to enable libc full check
|
|
||||||
|
|||||||
@@ -162,7 +162,8 @@ UINT32 LOS_LmsCheckPoolAdd(const VOID *pool, UINT32 size)
|
|||||||
lmsPoolNode->shadowStart = (UINTPTR)poolAddr + realSize;
|
lmsPoolNode->shadowStart = (UINTPTR)poolAddr + realSize;
|
||||||
lmsPoolNode->shadowSize = poolAddr + size - lmsPoolNode->shadowStart;
|
lmsPoolNode->shadowSize = poolAddr + size - lmsPoolNode->shadowStart;
|
||||||
/* init shadow value */
|
/* init shadow value */
|
||||||
(VOID)memset_s((VOID *)lmsPoolNode->shadowStart, lmsPoolNode->shadowSize, LMS_SHADOW_AFTERFREE_U8, lmsPoolNode->shadowSize);
|
(VOID)memset_s((VOID *)lmsPoolNode->shadowStart, lmsPoolNode->shadowSize, LMS_SHADOW_AFTERFREE_U8,
|
||||||
|
lmsPoolNode->shadowSize);
|
||||||
|
|
||||||
LOS_ListAdd(&g_lmsCheckPoolList, &(lmsPoolNode->node));
|
LOS_ListAdd(&g_lmsCheckPoolList, &(lmsPoolNode->node));
|
||||||
|
|
||||||
|
|||||||
@@ -147,7 +147,6 @@ STATIC BOOL OsPmTickTimerStop(LosPmCB *pm)
|
|||||||
realSleepTime = expireTime - currTime;
|
realSleepTime = expireTime - currTime;
|
||||||
sleepCycle = OS_SYS_CYCLE_TO_NS(realSleepTime, g_sysClock);
|
sleepCycle = OS_SYS_CYCLE_TO_NS(realSleepTime, g_sysClock);
|
||||||
sleepCycle = OS_SYS_NS_TO_CYCLE(sleepCycle, tickTimer->freq);
|
sleepCycle = OS_SYS_NS_TO_CYCLE(sleepCycle, tickTimer->freq);
|
||||||
|
|
||||||
if (sleepCycle == 0) {
|
if (sleepCycle == 0) {
|
||||||
pm->sysMode = LOS_SYS_NORMAL_SLEEP;
|
pm->sysMode = LOS_SYS_NORMAL_SLEEP;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|||||||
@@ -24,18 +24,4 @@ config SHELL_STACK_SIZE
|
|||||||
default 4096
|
default 4096
|
||||||
depends on SHELL
|
depends on SHELL
|
||||||
|
|
||||||
config SHELL_LK
|
|
||||||
bool "Enable Shell lk"
|
|
||||||
default y
|
|
||||||
depends on DEBUG_VERSION && SHELL
|
|
||||||
help
|
|
||||||
Answer Y to enable LiteOS support shell lk.
|
|
||||||
|
|
||||||
config SHELL_DMESG
|
|
||||||
bool "Enable Shell dmesg"
|
|
||||||
default n
|
|
||||||
depends on DEBUG_VERSION && SHELL && SHELL_CMD_DEBUG
|
|
||||||
help
|
|
||||||
Answer Y to enable LiteOS support shell dmesg.
|
|
||||||
|
|
||||||
endmenu
|
endmenu
|
||||||
|
|||||||
@@ -72,7 +72,4 @@ config TRACE_CONTROL_VIA_SHELL
|
|||||||
config TRACE_CONTROL_AGENT
|
config TRACE_CONTROL_AGENT
|
||||||
bool "Via Trace Agent Task"
|
bool "Via Trace Agent Task"
|
||||||
|
|
||||||
config TRACE_NO_CONTROL
|
|
||||||
bool "No Control"
|
|
||||||
|
|
||||||
endchoice
|
endchoice
|
||||||
+2
-1
@@ -206,5 +206,6 @@ toochain_config_objdump = "${compile_prefix}objdump$toolchain_cmd_suffix"
|
|||||||
toochain_config_command =
|
toochain_config_command =
|
||||||
"$toochain_config_objcopy -O binary $liteos_name $liteos_name.bin"
|
"$toochain_config_objcopy -O binary $liteos_name $liteos_name.bin"
|
||||||
toochain_config_command += " && sh -c '$toochain_config_objdump -t $liteos_name | sort >$liteos_name.sym.sorted'"
|
toochain_config_command += " && sh -c '$toochain_config_objdump -t $liteos_name | sort >$liteos_name.sym.sorted'"
|
||||||
toochain_config_command +=
|
|
||||||
|
toochain_asm_command =
|
||||||
" && sh -c '$toochain_config_objdump -d $liteos_name >$liteos_name.asm'"
|
" && sh -c '$toochain_config_objdump -d $liteos_name >$liteos_name.asm'"
|
||||||
|
|||||||
+2
-1
@@ -149,4 +149,5 @@ toochain_config_objdump = "${compile_prefix}ielfdumparm$toolchain_cmd_suffix"
|
|||||||
|
|
||||||
toochain_config_command =
|
toochain_config_command =
|
||||||
"$toochain_config_objcopy --bin --verbose $liteos_name $liteos_name.bin"
|
"$toochain_config_objcopy --bin --verbose $liteos_name $liteos_name.bin"
|
||||||
toochain_config_command += " && sh -c '$toochain_config_objdump --source --all $liteos_name -o $liteos_name.asm'"
|
|
||||||
|
toochain_asm_command = " && sh -c '$toochain_config_objdump --source --all $liteos_name -o $liteos_name.asm'"
|
||||||
|
|||||||
+5
-1
@@ -48,7 +48,10 @@ kernel_module("test_init") {
|
|||||||
"src/osTest.c",
|
"src/osTest.c",
|
||||||
]
|
]
|
||||||
|
|
||||||
include_dirs = [ "unittest/posix/src" ]
|
include_dirs = [
|
||||||
|
"unittest/posix/src",
|
||||||
|
"unittest/xts",
|
||||||
|
]
|
||||||
|
|
||||||
configs += [ ":include" ]
|
configs += [ ":include" ]
|
||||||
}
|
}
|
||||||
@@ -69,6 +72,7 @@ group("testsuites") {
|
|||||||
"sample/kernel/task:test_task",
|
"sample/kernel/task:test_task",
|
||||||
"sample/posix:test_posix",
|
"sample/posix:test_posix",
|
||||||
"unittest/posix:posix_test",
|
"unittest/posix:posix_test",
|
||||||
|
"unittest/xts:xts_test",
|
||||||
]
|
]
|
||||||
if (defined(LOSCFG_DYNLINK)) {
|
if (defined(LOSCFG_DYNLINK)) {
|
||||||
deps += [ "sample/kernel/dynlink:test_dynlink" ]
|
deps += [ "sample/kernel/dynlink:test_dynlink" ]
|
||||||
|
|||||||
@@ -96,6 +96,7 @@ extern "C" {
|
|||||||
#define LOS_KERNEL_LMK_TEST 0
|
#define LOS_KERNEL_LMK_TEST 0
|
||||||
#define LOS_KERNEL_SIGNAL_TEST 0
|
#define LOS_KERNEL_SIGNAL_TEST 0
|
||||||
|
|
||||||
|
#define LOS_XTS_TEST 1
|
||||||
#define LOS_POSIX_TEST 1
|
#define LOS_POSIX_TEST 1
|
||||||
#define LOS_CMSIS_TEST 1
|
#define LOS_CMSIS_TEST 1
|
||||||
#define LOS_CMSIS2_CORE_TASK_TEST 0
|
#define LOS_CMSIS2_CORE_TASK_TEST 0
|
||||||
|
|||||||
@@ -85,7 +85,7 @@
|
|||||||
#define ICUNIT_GOTO_WITHIN_EQUAL(param, value1, value2, retcode, label) \
|
#define ICUNIT_GOTO_WITHIN_EQUAL(param, value1, value2, retcode, label) \
|
||||||
do { \
|
do { \
|
||||||
if ((param) < (value1) || (param) > (value2)) { \
|
if ((param) < (value1) || (param) > (value2)) { \
|
||||||
ICunitSaveErr(__LINE__, (iiUINT32)retcode); \
|
ICunitSaveErr(__LINE__, (iiUINT32)(retcode)); \
|
||||||
goto label; \
|
goto label; \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ static VOID *PthreadF01(VOID *argument)
|
|||||||
|
|
||||||
g_testCount = 2; // 2, Init test count value.
|
g_testCount = 2; // 2, Init test count value.
|
||||||
|
|
||||||
EXIT1:
|
EXIT1:
|
||||||
return NULL;
|
return NULL;
|
||||||
EXIT2:
|
EXIT2:
|
||||||
g_testCount = 0;
|
g_testCount = 0;
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ static UINT32 Testcase(VOID)
|
|||||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||||
|
|
||||||
ret = mq_close(mqdes);
|
ret = mq_close(mqdes);
|
||||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
|
||||||
|
|
||||||
ret = mq_unlink(mqname);
|
ret = mq_unlink(mqname);
|
||||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
|
||||||
|
|||||||
@@ -38,6 +38,9 @@
|
|||||||
#if (LOS_POSIX_TEST == 1)
|
#if (LOS_POSIX_TEST == 1)
|
||||||
#include "posix_test.h"
|
#include "posix_test.h"
|
||||||
#endif
|
#endif
|
||||||
|
#if (LOS_XTS_TEST == 1)
|
||||||
|
#include "xts_test.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
UINT32 volatile g_testCount;
|
UINT32 volatile g_testCount;
|
||||||
UINT32 g_testTskHandle;
|
UINT32 g_testTskHandle;
|
||||||
@@ -246,6 +249,10 @@ VOID TestTaskEntry(VOID)
|
|||||||
CmsisFuncTestSuite();
|
CmsisFuncTestSuite();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if(LOS_XTS_TEST == 1)
|
||||||
|
XtsTestSuite();
|
||||||
|
#endif
|
||||||
|
|
||||||
/* The log is used for testing entrance guard, please do not make any changes. */
|
/* The log is used for testing entrance guard, please do not make any changes. */
|
||||||
PRINTF("\nfailed count:%d, success count:%d\n", g_failResult, g_passResult);
|
PRINTF("\nfailed count:%d, success count:%d\n", g_failResult, g_passResult);
|
||||||
PRINTF("--- Test End ---\n");
|
PRINTF("--- Test End ---\n");
|
||||||
|
|||||||
@@ -135,8 +135,8 @@ static char *TmToStr(const struct tm *timePtr, char *timeStr, unsigned len)
|
|||||||
if (timePtr == NULL || timeStr == NULL) {
|
if (timePtr == NULL || timeStr == NULL) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
sprintf_s(timeStr, len, "%ld/%d/%d %02d:%02d:%02d WEEK(%d)", timePtr->tm_year + TM_BASE_YEAR, timePtr->tm_mon + 1,
|
(VOID)sprintf_s(timeStr, len, "%ld/%d/%d %02d:%02d:%02d WEEK(%d)", timePtr->tm_year + TM_BASE_YEAR,
|
||||||
timePtr->tm_mday, timePtr->tm_hour, timePtr->tm_min, timePtr->tm_sec, timePtr->tm_wday);
|
timePtr->tm_mon + 1, timePtr->tm_mday, timePtr->tm_hour, timePtr->tm_min, timePtr->tm_sec, timePtr->tm_wday);
|
||||||
return timeStr;
|
return timeStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
# Copyright (c) 2023-2023 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")
|
||||||
|
|
||||||
|
static_library("xts_test") {
|
||||||
|
sources = [ "xts_test.c" ]
|
||||||
|
deps = [
|
||||||
|
"cmsis:cmsis_test",
|
||||||
|
"io:io_test",
|
||||||
|
"ipc:ipc_test",
|
||||||
|
"math:math_test",
|
||||||
|
"mem:mem_test",
|
||||||
|
"net:net_test",
|
||||||
|
"process:pthread_test",
|
||||||
|
"sched:sched_test",
|
||||||
|
"sys:system_test",
|
||||||
|
"time:time_test",
|
||||||
|
]
|
||||||
|
configs += [ "$LITEOSTOPDIR/testsuites:include" ]
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
# Copyright (c) 2023-2023 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")
|
||||||
|
|
||||||
|
static_library("cmsis_test") {
|
||||||
|
sources = [
|
||||||
|
"cmsis_event_func_test.c",
|
||||||
|
"cmsis_msg_func_test.c",
|
||||||
|
"cmsis_mutex_func_test.c",
|
||||||
|
"cmsis_sem_func_test.c",
|
||||||
|
"cmsis_task_func_test.c",
|
||||||
|
"cmsis_task_pri_func_test.c",
|
||||||
|
"cmsis_timer_func_test.c",
|
||||||
|
"xts_cmsis.c",
|
||||||
|
]
|
||||||
|
|
||||||
|
include_dirs = [
|
||||||
|
".",
|
||||||
|
"$LITEOSTOPDIR/testsuites/include",
|
||||||
|
"$LITEOSTOPDIR/testsuites/unittest/xts",
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,364 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2023-2023 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 "xts_cmsis.h"
|
||||||
|
|
||||||
|
osEventFlagsId_t g_eventId;
|
||||||
|
UINT16 g_cmsisTestEventCount;
|
||||||
|
|
||||||
|
LITE_TEST_SUIT(Cmsis, Cmsisevent, CmsisEventFuncTestSuite);
|
||||||
|
|
||||||
|
static BOOL CmsisEventFuncTestSuiteSetUp(void)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static BOOL CmsisEventFuncTestSuiteTearDown(void)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void CmsisEventFlagsWaitFunc001(void const *argument)
|
||||||
|
{
|
||||||
|
(void)argument;
|
||||||
|
g_cmsisTestEventCount++;
|
||||||
|
UINT32 ret = osEventFlagsWait(g_eventId, EVENT_MASK_HEX_11, (osFlagsWaitAll | osFlagsNoClear), osWaitForever);
|
||||||
|
ICUNIT_ASSERT_EQUAL_VOID(ret, EVENT_MASK_HEX_11, ret);
|
||||||
|
g_cmsisTestEventCount++;
|
||||||
|
osThreadExit();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void CmsisEventFlagsSetFunc002(void const *argument)
|
||||||
|
{
|
||||||
|
(void)argument;
|
||||||
|
UINT32 ret;
|
||||||
|
g_cmsisTestEventCount++;
|
||||||
|
ret = osEventFlagsWait(g_eventId, EVENT_MASK_HEX_11, (osFlagsWaitAll | osFlagsNoClear), TIMEOUT_NUM_3);
|
||||||
|
ICUNIT_ASSERT_EQUAL_VOID(ret, osErrorTimeout, ret);
|
||||||
|
g_cmsisTestEventCount++;
|
||||||
|
|
||||||
|
ret = osEventFlagsWait(g_eventId, EVENT_MASK_HEX_4, (osFlagsWaitAll | osFlagsNoClear), osWaitForever);
|
||||||
|
ICUNIT_ASSERT_EQUAL_VOID(ret, TESTCOUNT_NUM_4, ret);
|
||||||
|
g_cmsisTestEventCount++;
|
||||||
|
osThreadExit();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void CmsisEventFlagsClearFunc001(void const *argument)
|
||||||
|
{
|
||||||
|
(void)argument;
|
||||||
|
g_cmsisTestEventCount++;
|
||||||
|
UINT32 ret = osEventFlagsWait(g_eventId, EVENT_MASK_HEX_1, osFlagsWaitAll, osWaitForever);
|
||||||
|
ICUNIT_ASSERT_EQUAL_VOID(ret, EVENT_MASK_HEX_1, ret);
|
||||||
|
g_cmsisTestEventCount++;
|
||||||
|
osThreadExit();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_EVENT_OPERATION_0100
|
||||||
|
* @tc.name : event operation for creat
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisEventFuncTestSuite, testOsEventFlagsNew001, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
g_eventId = osEventFlagsNew(NULL);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(g_eventId, NULL, g_eventId);
|
||||||
|
(void)osEventFlagsDelete(g_eventId);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_EVENT_OPERATION_0200
|
||||||
|
* @tc.name : event operation for delete
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisEventFuncTestSuite, testOsEventFlagsDelete001, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
UINT32 ret;
|
||||||
|
g_eventId = osEventFlagsNew(NULL);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(g_eventId, NULL, g_eventId);
|
||||||
|
ret = osEventFlagsDelete(g_eventId);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_EVENT_OPERATION_0300
|
||||||
|
* @tc.name : event delete operation with EventFlagsId = NULL
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisEventFuncTestSuite, testOsEventFlagsDelete002, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
UINT32 ret = osEventFlagsDelete(NULL);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, osErrorParameter, ret);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_EVENT_OPERATION_0400
|
||||||
|
* @tc.name : event operation for flags set
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisEventFuncTestSuite, testOsEventFlagsSet001, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
UINT32 ret;
|
||||||
|
g_eventId = osEventFlagsNew(NULL);
|
||||||
|
ret = osEventFlagsSet(g_eventId, EVENT_MASK_HEX_10);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, EVENT_MASK_HEX_10, ret);
|
||||||
|
ret = osEventFlagsDelete(g_eventId);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_EVENT_OPERATION_0500
|
||||||
|
* @tc.name : event reliability test for flags set
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisEventFuncTestSuite, testOsEventFlagsSet002, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
UINT32 ret;
|
||||||
|
osThreadId_t id;
|
||||||
|
osStatus_t status;
|
||||||
|
osThreadAttr_t attr;
|
||||||
|
attr.name = "test";
|
||||||
|
attr.attr_bits = 0U;
|
||||||
|
attr.cb_mem = NULL;
|
||||||
|
attr.cb_size = 0U;
|
||||||
|
attr.stack_mem = NULL;
|
||||||
|
attr.stack_size = TEST_TASK_STACK_SIZE;
|
||||||
|
attr.priority = osPriorityAboveNormal;
|
||||||
|
|
||||||
|
g_cmsisTestEventCount = 0;
|
||||||
|
g_eventId = osEventFlagsNew(NULL);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(g_eventId, NULL, g_eventId);
|
||||||
|
id = osThreadNew((osThreadFunc_t)CmsisEventFlagsSetFunc002, NULL, &attr);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
|
||||||
|
ICUNIT_ASSERT_EQUAL(g_cmsisTestEventCount, EVENT_MASK_HEX_1, g_cmsisTestEventCount);
|
||||||
|
g_cmsisTestEventCount++;
|
||||||
|
ret = osEventFlagsSet(g_eventId, EVENT_MASK_HEX_2);
|
||||||
|
status = osDelay(DELAY_TICKS_5);
|
||||||
|
ICUNIT_ASSERT_EQUAL(status, osOK, status);
|
||||||
|
ICUNIT_ASSERT_EQUAL(g_cmsisTestEventCount, TESTCOUNT_NUM_3, g_cmsisTestEventCount);
|
||||||
|
|
||||||
|
g_cmsisTestEventCount++;
|
||||||
|
ret = osEventFlagsSet(g_eventId, EVENT_MASK_HEX_11);
|
||||||
|
status = osDelay(DELAY_TICKS_5);
|
||||||
|
ICUNIT_ASSERT_EQUAL(status, osOK, status);
|
||||||
|
|
||||||
|
ICUNIT_ASSERT_EQUAL(g_cmsisTestEventCount, TESTCOUNT_NUM_4, g_cmsisTestEventCount);
|
||||||
|
ret = osEventFlagsSet(g_eventId, EVENT_MASK_HEX_4);
|
||||||
|
ICUNIT_ASSERT_EQUAL(g_cmsisTestEventCount, TESTCOUNT_NUM_5, g_cmsisTestEventCount);
|
||||||
|
ret = osEventFlagsDelete(g_eventId);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_EVENT_OPERATION_0600
|
||||||
|
* @tc.name : event flags set operation with EventFlagsId = NULL
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisEventFuncTestSuite, testOsEventFlagsSet003, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
UINT32 ret = osEventFlagsSet(NULL, EVENT_MASK_HEX_10);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, osFlagsErrorParameter, ret);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_EVENT_OPERATION_0700
|
||||||
|
* @tc.name : event operation for wait
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisEventFuncTestSuite, testOsEventFlagsWait001, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
UINT32 ret;
|
||||||
|
osThreadId_t id;
|
||||||
|
osThreadAttr_t attr;
|
||||||
|
attr.name = "test";
|
||||||
|
attr.attr_bits = 0U;
|
||||||
|
attr.cb_mem = NULL;
|
||||||
|
attr.cb_size = 0U;
|
||||||
|
attr.stack_mem = NULL;
|
||||||
|
attr.stack_size = TEST_TASK_STACK_SIZE;
|
||||||
|
attr.priority = osPriorityAboveNormal;
|
||||||
|
|
||||||
|
g_cmsisTestEventCount = 0;
|
||||||
|
g_eventId = osEventFlagsNew(NULL);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(g_eventId, NULL, g_eventId);
|
||||||
|
id = osThreadNew((osThreadFunc_t)CmsisEventFlagsWaitFunc001, NULL, &attr);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
|
||||||
|
|
||||||
|
ret = osEventFlagsSet(g_eventId, EVENT_MASK_HEX_10);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, EVENT_MASK_HEX_10, ret);
|
||||||
|
ICUNIT_ASSERT_EQUAL(g_cmsisTestEventCount, EVENT_MASK_HEX_1, g_cmsisTestEventCount);
|
||||||
|
|
||||||
|
ret = osEventFlagsSet(g_eventId, EVENT_MASK_HEX_1);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, EVENT_MASK_HEX_11, ret);
|
||||||
|
ICUNIT_ASSERT_EQUAL(g_cmsisTestEventCount, TESTCOUNT_NUM_2, g_cmsisTestEventCount);
|
||||||
|
|
||||||
|
ret = osEventFlagsDelete(g_eventId);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_EVENT_OPERATION_0800
|
||||||
|
* @tc.name : event operation for invalid option
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisEventFuncTestSuite, testOsEventFlagsWait002, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
UINT32 ret;
|
||||||
|
g_eventId = osEventFlagsNew(NULL);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(g_eventId, NULL, g_eventId);
|
||||||
|
|
||||||
|
ret = osEventFlagsWait(g_eventId, EVENT_MASK_HEX_11, INVALID_FLAG_OPTION, osWaitForever);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, osFlagsErrorParameter, ret);
|
||||||
|
|
||||||
|
ret = osEventFlagsDelete(g_eventId);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_EVENT_OPERATION_0900
|
||||||
|
* @tc.name : event wait operation with EventFlagsId = NULL
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisEventFuncTestSuite, testOsEventFlagsWait003, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
UINT32 ret = osEventFlagsWait(NULL, EVENT_MASK_HEX_11, (osFlagsWaitAll | osFlagsNoClear), osWaitForever);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, osFlagsErrorParameter, ret);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_EVENT_OPERATION_1000
|
||||||
|
* @tc.name : event operation for flags get
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisEventFuncTestSuite, testOsEventFlagsGet001, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
UINT32 ret;
|
||||||
|
g_eventId = osEventFlagsNew(NULL);
|
||||||
|
ret = osEventFlagsSet(g_eventId, EVENT_MASK_HEX_10);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, EVENT_MASK_HEX_10, ret);
|
||||||
|
ret = osEventFlagsGet(g_eventId);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, EVENT_MASK_HEX_10, ret);
|
||||||
|
|
||||||
|
ret = osEventFlagsDelete(g_eventId);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_EVENT_OPERATION_1100
|
||||||
|
* @tc.name : event flags get operation with EventFlagsId = NULL
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisEventFuncTestSuite, testOsEventFlagsGet002, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
UINT32 ret = osEventFlagsGet(NULL);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_EVENT_OPERATION_1200
|
||||||
|
* @tc.name : event operation for flags clear
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisEventFuncTestSuite, testOsEventFlagsClear001, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
UINT32 ret;
|
||||||
|
osThreadId_t id;
|
||||||
|
|
||||||
|
osThreadAttr_t attr;
|
||||||
|
attr.name = "test";
|
||||||
|
attr.attr_bits = 0U;
|
||||||
|
attr.cb_mem = NULL;
|
||||||
|
attr.cb_size = 0U;
|
||||||
|
attr.stack_mem = NULL;
|
||||||
|
attr.stack_size = TEST_TASK_STACK_SIZE;
|
||||||
|
attr.priority = osPriorityAboveNormal;
|
||||||
|
|
||||||
|
g_cmsisTestEventCount = 0;
|
||||||
|
g_eventId = osEventFlagsNew(NULL);
|
||||||
|
id = osThreadNew((osThreadFunc_t)CmsisEventFlagsClearFunc001, NULL, &attr);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
|
||||||
|
ret = osEventFlagsSet(g_eventId, EVENT_MASK_HEX_10);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, EVENT_MASK_HEX_10, ret);
|
||||||
|
ICUNIT_ASSERT_EQUAL(g_cmsisTestEventCount, EVENT_MASK_HEX_1, g_cmsisTestEventCount);
|
||||||
|
|
||||||
|
ret = osEventFlagsClear(g_eventId, 0xffff);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, EVENT_MASK_HEX_10, ret);
|
||||||
|
ret = osEventFlagsGet(g_eventId);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ret = osEventFlagsSet(g_eventId, EVENT_MASK_HEX_1);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ICUNIT_ASSERT_EQUAL(g_cmsisTestEventCount, TESTCOUNT_NUM_2, g_cmsisTestEventCount);
|
||||||
|
ret = osEventFlagsDelete(g_eventId);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_EVENT_OPERATION_1300
|
||||||
|
* @tc.name : event flags clear operation with EventFlagsId = NULL
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisEventFuncTestSuite, testOsEventFlagsClear002, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
UINT32 ret = osEventFlagsClear(NULL, 0xffff);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, osFlagsErrorParameter, ret);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
RUN_TEST_SUITE(CmsisEventFuncTestSuite);
|
||||||
|
|
||||||
|
void CmsisEventFuncTest(void)
|
||||||
|
{
|
||||||
|
RUN_ONE_TESTCASE(testOsEventFlagsNew001);
|
||||||
|
RUN_ONE_TESTCASE(testOsEventFlagsDelete001);
|
||||||
|
RUN_ONE_TESTCASE(testOsEventFlagsDelete002);
|
||||||
|
RUN_ONE_TESTCASE(testOsEventFlagsSet001);
|
||||||
|
RUN_ONE_TESTCASE(testOsEventFlagsSet002);
|
||||||
|
RUN_ONE_TESTCASE(testOsEventFlagsSet003);
|
||||||
|
RUN_ONE_TESTCASE(testOsEventFlagsWait001);
|
||||||
|
RUN_ONE_TESTCASE(testOsEventFlagsWait002);
|
||||||
|
RUN_ONE_TESTCASE(testOsEventFlagsWait003);
|
||||||
|
RUN_ONE_TESTCASE(testOsEventFlagsGet001);
|
||||||
|
RUN_ONE_TESTCASE(testOsEventFlagsGet002);
|
||||||
|
RUN_ONE_TESTCASE(testOsEventFlagsClear001);
|
||||||
|
RUN_ONE_TESTCASE(testOsEventFlagsClear002);
|
||||||
|
}
|
||||||
@@ -0,0 +1,419 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2023-2023 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 "xts_cmsis.h"
|
||||||
|
|
||||||
|
osMessageQueueId_t g_cmsisMqId;
|
||||||
|
static char *g_cmsisMessageInfo[] = {"msg1", "msg2", "msg3", "msg4", "msg5", "msg6", "msg7", "msg8"};
|
||||||
|
|
||||||
|
LITE_TEST_SUIT(Cmsis, Cmsismsg, CmsisMsgFuncTestSuite);
|
||||||
|
|
||||||
|
static BOOL CmsisMsgFuncTestSuiteSetUp(void)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static BOOL CmsisMsgFuncTestSuiteTearDown(void)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void CmsisMessageQueueGetFunc001(void const *argument)
|
||||||
|
{
|
||||||
|
(void)argument;
|
||||||
|
osStatus_t uwRet;
|
||||||
|
UINT8 msgPrio = 0;
|
||||||
|
CHAR ucTemp[MSGINFO_LEN] = "";
|
||||||
|
UINT32 uwCmp;
|
||||||
|
uwRet = osMessageQueueGet(g_cmsisMqId, ucTemp, &msgPrio, TIMEOUT_COUNT);
|
||||||
|
ICUNIT_ASSERT_EQUAL(uwRet, osOK, uwRet);
|
||||||
|
uwCmp = memcmp(ucTemp, g_cmsisMessageInfo[MSGQUEUE_COUNT_INDEX_0], MSGINFO_LEN);
|
||||||
|
ICUNIT_ASSERT_EQUAL(uwRet, 0, uwCmp);
|
||||||
|
|
||||||
|
uwRet = osMessageQueueDelete(g_cmsisMqId);
|
||||||
|
ICUNIT_ASSERT_EQUAL(uwRet, osOK, uwRet);
|
||||||
|
osThreadExit();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_MSG_OPERATION_0100
|
||||||
|
* @tc.name : message queue operation for creat
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisMsgFuncTestSuite, testOsMessageQueueNew001, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
osStatus_t status;
|
||||||
|
g_cmsisMqId = osMessageQueueNew(MSGQUEUE_COUNT, MSG_SIZE, NULL);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisMqId, NULL, g_cmsisMqId);
|
||||||
|
(void)osMessageQueueDelete(g_cmsisMqId);
|
||||||
|
status = osDelay(DELAY_TICKS_5);
|
||||||
|
ICUNIT_ASSERT_EQUAL(status, osOK, status);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_MSG_OPERATION_0200
|
||||||
|
* @tc.name : message queue operation for creat when msg_count = 0
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisMsgFuncTestSuite, testOsMessageQueueNew002, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
osStatus_t status;
|
||||||
|
g_cmsisMqId = osMessageQueueNew(0, MSG_SIZE, NULL);
|
||||||
|
ICUNIT_ASSERT_EQUAL(g_cmsisMqId, NULL, g_cmsisMqId);
|
||||||
|
status = osDelay(DELAY_TICKS_5);
|
||||||
|
ICUNIT_ASSERT_EQUAL(status, osOK, status);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_MSG_OPERATION_0300
|
||||||
|
* @tc.name : message queue operation for creat when msg_size = 0
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisMsgFuncTestSuite, testOsMessageQueueNew003, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
osStatus_t status;
|
||||||
|
g_cmsisMqId = osMessageQueueNew(MSGQUEUE_COUNT, 0, NULL);
|
||||||
|
ICUNIT_ASSERT_EQUAL(g_cmsisMqId, NULL, g_cmsisMqId);
|
||||||
|
status = osDelay(DELAY_TICKS_5);
|
||||||
|
ICUNIT_ASSERT_EQUAL(status, osOK, status);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_MSG_OPERATION_0400
|
||||||
|
* @tc.name : message queue operation for delete
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisMsgFuncTestSuite, testOsMessageQueueDelete001, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
osStatus_t uwRet;
|
||||||
|
g_cmsisMqId = osMessageQueueNew(MSGQUEUE_COUNT, MSG_SIZE, NULL);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisMqId, NULL, g_cmsisMqId);
|
||||||
|
uwRet = osMessageQueueDelete(g_cmsisMqId);
|
||||||
|
ICUNIT_ASSERT_EQUAL(uwRet, osOK, uwRet);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_MSG_OPERATION_0500
|
||||||
|
* @tc.name : message queue delete operation with mq_id = NULL
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisMsgFuncTestSuite, testOsMessageQueueDelete002, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
osStatus_t uwRet = osMessageQueueDelete(NULL);
|
||||||
|
ICUNIT_ASSERT_EQUAL(uwRet, osErrorParameter, uwRet);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_MSG_OPERATION_0600
|
||||||
|
* @tc.name : message queue operation for put
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisMsgFuncTestSuite, testOsMessageQueuePut001, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
osStatus_t uwRet;
|
||||||
|
g_cmsisMqId = osMessageQueueNew(MSGQUEUE_COUNT, MSG_SIZE, NULL);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisMqId, NULL, g_cmsisMqId);
|
||||||
|
|
||||||
|
uwRet = osMessageQueuePut(g_cmsisMqId, g_cmsisMessageInfo[MSGQUEUE_COUNT_INDEX_0], 0, 0);
|
||||||
|
ICUNIT_ASSERT_EQUAL(uwRet, osOK, uwRet);
|
||||||
|
|
||||||
|
uwRet = osMessageQueueDelete(g_cmsisMqId);
|
||||||
|
ICUNIT_ASSERT_EQUAL(uwRet, osOK, uwRet);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_MSG_OPERATION_0700
|
||||||
|
* @tc.name : message queue put operation with mq_id = NULL
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisMsgFuncTestSuite, testOsMessageQueuePut002, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
osStatus_t uwRet = osMessageQueuePut(NULL, g_cmsisMessageInfo[MSGQUEUE_COUNT_INDEX_0], 0, 0);
|
||||||
|
ICUNIT_ASSERT_EQUAL(uwRet, osErrorParameter, uwRet);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_MSG_OPERATION_0800
|
||||||
|
* @tc.name : message queue operation for put when msg_ptr = 0
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisMsgFuncTestSuite, testOsMessageQueuePut003, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
osStatus_t uwRet;
|
||||||
|
g_cmsisMqId = osMessageQueueNew(MSGQUEUE_COUNT, MSG_SIZE, NULL);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisMqId, NULL, g_cmsisMqId);
|
||||||
|
|
||||||
|
uwRet = osMessageQueuePut(g_cmsisMqId, NULL, 0, 0);
|
||||||
|
ICUNIT_ASSERT_EQUAL(uwRet, osErrorParameter, uwRet);
|
||||||
|
|
||||||
|
uwRet = osMessageQueueDelete(g_cmsisMqId);
|
||||||
|
ICUNIT_ASSERT_EQUAL(uwRet, osOK, uwRet);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_MSG_OPERATION_0900
|
||||||
|
* @tc.name : message queue operation for get
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisMsgFuncTestSuite, testOsMessageQueueGet001, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
osStatus_t uwRet;
|
||||||
|
UINT32 uId;
|
||||||
|
osThreadId_t id;
|
||||||
|
osThreadAttr_t attr;
|
||||||
|
attr.name = "test";
|
||||||
|
attr.attr_bits = 0U;
|
||||||
|
attr.cb_mem = NULL;
|
||||||
|
attr.cb_size = 0U;
|
||||||
|
attr.stack_mem = NULL;
|
||||||
|
attr.stack_size = TEST_TASK_STACK_SIZE;
|
||||||
|
attr.priority = osPriorityAboveNormal;
|
||||||
|
uId = osKernelLock();
|
||||||
|
ICUNIT_ASSERT_EQUAL(uId, 0, uId); /* 1, common data for test, no special meaning */
|
||||||
|
g_cmsisMqId = osMessageQueueNew(MSGQUEUE_COUNT, MSG_SIZE, NULL);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisMqId, NULL, g_cmsisMqId);
|
||||||
|
|
||||||
|
id = osThreadNew((osThreadFunc_t)CmsisMessageQueueGetFunc001, NULL, &attr);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
|
||||||
|
uwRet = osMessageQueuePut(g_cmsisMqId, g_cmsisMessageInfo[MSGQUEUE_COUNT_INDEX_0], 0, 0);
|
||||||
|
ICUNIT_ASSERT_EQUAL(uwRet, osOK, uwRet);
|
||||||
|
uId = osKernelUnlock();
|
||||||
|
ICUNIT_ASSERT_EQUAL(uId, 1, uId); /* 1, common data for test, no special meaning */
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_MSG_OPERATION_1000
|
||||||
|
* @tc.name : message queue get operation with mq_id = NULL
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisMsgFuncTestSuite, testOsMessageQueueGet002, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
osStatus_t uwRet;
|
||||||
|
UINT8 msgPrio = 0;
|
||||||
|
CHAR ucTemp[MSGINFO_LEN] = "";
|
||||||
|
uwRet = osMessageQueueGet(NULL, ucTemp, &msgPrio, TIMEOUT_COUNT);
|
||||||
|
ICUNIT_ASSERT_EQUAL(uwRet, osErrorParameter, uwRet);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_MSG_OPERATION_1100
|
||||||
|
* @tc.name : message queue operation for get when msg_ptr = 0
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisMsgFuncTestSuite, testOsMessageQueueGet003, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
osStatus_t uwRet;
|
||||||
|
UINT8 msgPrio = 0;
|
||||||
|
g_cmsisMqId = osMessageQueueNew(MSGQUEUE_COUNT, MSG_SIZE, NULL);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisMqId, NULL, g_cmsisMqId);
|
||||||
|
|
||||||
|
uwRet = osMessageQueueGet(g_cmsisMqId, NULL, &msgPrio, TIMEOUT_COUNT);
|
||||||
|
ICUNIT_ASSERT_EQUAL(uwRet, osErrorParameter, uwRet);
|
||||||
|
|
||||||
|
uwRet = osMessageQueueDelete(g_cmsisMqId);
|
||||||
|
ICUNIT_ASSERT_EQUAL(uwRet, osOK, uwRet);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_MSG_OPERATION_1200
|
||||||
|
* @tc.name : message queue operation for get msg size
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisMsgFuncTestSuite, testOsMessageQueueGetMsgSize001, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
UINT32 uwRet;
|
||||||
|
g_cmsisMqId = osMessageQueueNew(MSGQUEUE_COUNT, MSG_SIZE, NULL);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisMqId, NULL, g_cmsisMqId);
|
||||||
|
|
||||||
|
uwRet = osMessageQueueGetMsgSize(g_cmsisMqId);
|
||||||
|
ICUNIT_ASSERT_EQUAL(uwRet, MSG_SIZE, uwRet);
|
||||||
|
|
||||||
|
uwRet = osMessageQueueDelete(g_cmsisMqId);
|
||||||
|
ICUNIT_ASSERT_EQUAL(uwRet, osOK, uwRet);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_MSG_OPERATION_1300
|
||||||
|
* @tc.name : message queue get msg size with mq_id = NULL
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisMsgFuncTestSuite, testOsMessageQueueGetMsgSize002, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
UINT32 uwRet = osMessageQueueGetMsgSize(NULL);
|
||||||
|
ICUNIT_ASSERT_EQUAL(uwRet, 0, uwRet);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_MSG_OPERATION_1400
|
||||||
|
* @tc.name : message queue operation for get capacity
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisMsgFuncTestSuite, testOsMessageQueueGetCapacity001, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
UINT32 uwRet;
|
||||||
|
g_cmsisMqId = osMessageQueueNew(MSGQUEUE_COUNT, MSG_SIZE, NULL);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisMqId, NULL, g_cmsisMqId);
|
||||||
|
uwRet = osMessageQueueGetCapacity(g_cmsisMqId);
|
||||||
|
ICUNIT_ASSERT_EQUAL(uwRet, MSGQUEUE_COUNT, uwRet);
|
||||||
|
|
||||||
|
uwRet = osMessageQueueDelete(g_cmsisMqId);
|
||||||
|
ICUNIT_ASSERT_EQUAL(uwRet, osOK, uwRet);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_MSG_OPERATION_1500
|
||||||
|
* @tc.name : message queue get capacity with mq_id = NULL
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisMsgFuncTestSuite, testOsMessageQueueGetCapacity002, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
UINT32 uwRet = osMessageQueueGetCapacity(NULL);
|
||||||
|
ICUNIT_ASSERT_EQUAL(uwRet, 0, uwRet);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_MSG_OPERATION_1600
|
||||||
|
* @tc.name : message queue operation for get count
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisMsgFuncTestSuite, testOsMessageQueueGetCount001, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
UINT32 uwRet;
|
||||||
|
g_cmsisMqId = osMessageQueueNew(MSGQUEUE_COUNT, MSG_SIZE, NULL);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisMqId, NULL, g_cmsisMqId);
|
||||||
|
|
||||||
|
uwRet = osMessageQueuePut(g_cmsisMqId, g_cmsisMessageInfo[MSGQUEUE_COUNT_INDEX_0], 0, 0);
|
||||||
|
ICUNIT_ASSERT_EQUAL(uwRet, osOK, uwRet);
|
||||||
|
|
||||||
|
uwRet = osMessageQueuePut(g_cmsisMqId, g_cmsisMessageInfo[MSGQUEUE_COUNT_INDEX_1], 0, 0);
|
||||||
|
ICUNIT_ASSERT_EQUAL(uwRet, osOK, uwRet);
|
||||||
|
|
||||||
|
uwRet = osMessageQueuePut(g_cmsisMqId, g_cmsisMessageInfo[MSGQUEUE_COUNT_INDEX_2], 0, 0);
|
||||||
|
ICUNIT_ASSERT_EQUAL(uwRet, osOK, uwRet);
|
||||||
|
|
||||||
|
uwRet = osMessageQueueGetCount(g_cmsisMqId);
|
||||||
|
ICUNIT_ASSERT_EQUAL(uwRet, MSGQUEUE_PUT_COUNT, uwRet);
|
||||||
|
|
||||||
|
uwRet = osMessageQueueDelete(g_cmsisMqId);
|
||||||
|
ICUNIT_ASSERT_EQUAL(uwRet, osOK, uwRet);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_MSG_OPERATION_1700
|
||||||
|
* @tc.name : message queue get count with mq_id = NULL
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisMsgFuncTestSuite, testOsMessageQueueGetCount002, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
UINT32 uwRet = osMessageQueueGetCount(NULL);
|
||||||
|
ICUNIT_ASSERT_EQUAL(uwRet, 0, uwRet);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_MSG_OPERATION_1800
|
||||||
|
* @tc.name : message queue operation for get space
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisMsgFuncTestSuite, testOsMessageQueueGetSpace001, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
UINT32 uwRet;
|
||||||
|
g_cmsisMqId = osMessageQueueNew(MSGQUEUE_COUNT, MSG_SIZE, NULL);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisMqId, NULL, g_cmsisMqId);
|
||||||
|
|
||||||
|
uwRet = osMessageQueuePut(g_cmsisMqId, g_cmsisMessageInfo[MSGQUEUE_COUNT_INDEX_0], 0, 0);
|
||||||
|
ICUNIT_ASSERT_EQUAL(uwRet, osOK, uwRet);
|
||||||
|
|
||||||
|
uwRet = osMessageQueuePut(g_cmsisMqId, g_cmsisMessageInfo[MSGQUEUE_COUNT_INDEX_1], 0, 0);
|
||||||
|
ICUNIT_ASSERT_EQUAL(uwRet, osOK, uwRet);
|
||||||
|
|
||||||
|
uwRet = osMessageQueuePut(g_cmsisMqId, g_cmsisMessageInfo[MSGQUEUE_COUNT_INDEX_2], 0, 0);
|
||||||
|
ICUNIT_ASSERT_EQUAL(uwRet, osOK, uwRet);
|
||||||
|
|
||||||
|
uwRet = osMessageQueueGetSpace(g_cmsisMqId);
|
||||||
|
ICUNIT_ASSERT_EQUAL(uwRet, MSGQUEUE_SPACE_COUNT, uwRet);
|
||||||
|
|
||||||
|
uwRet = osMessageQueueDelete(g_cmsisMqId);
|
||||||
|
ICUNIT_ASSERT_EQUAL(uwRet, osOK, uwRet);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_MSG_OPERATION_1900
|
||||||
|
* @tc.name : message queue get space with mq_id = NULL
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisMsgFuncTestSuite, testOsMessageQueueGetSpace002, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
UINT32 uwRet = osMessageQueueGetSpace(NULL);
|
||||||
|
ICUNIT_ASSERT_EQUAL(uwRet, 0, uwRet);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
RUN_TEST_SUITE(CmsisMsgFuncTestSuite);
|
||||||
|
|
||||||
|
void CmsisMsgFuncTest(void)
|
||||||
|
{
|
||||||
|
RUN_ONE_TESTCASE(testOsMessageQueueNew001);
|
||||||
|
RUN_ONE_TESTCASE(testOsMessageQueueNew002);
|
||||||
|
RUN_ONE_TESTCASE(testOsMessageQueueNew003);
|
||||||
|
RUN_ONE_TESTCASE(testOsMessageQueueDelete001);
|
||||||
|
RUN_ONE_TESTCASE(testOsMessageQueueDelete002);
|
||||||
|
RUN_ONE_TESTCASE(testOsMessageQueuePut001);
|
||||||
|
RUN_ONE_TESTCASE(testOsMessageQueuePut002);
|
||||||
|
RUN_ONE_TESTCASE(testOsMessageQueuePut003);
|
||||||
|
RUN_ONE_TESTCASE(testOsMessageQueueGet001);
|
||||||
|
RUN_ONE_TESTCASE(testOsMessageQueueGet002);
|
||||||
|
RUN_ONE_TESTCASE(testOsMessageQueueGet003);
|
||||||
|
RUN_ONE_TESTCASE(testOsMessageQueueGetMsgSize001);
|
||||||
|
RUN_ONE_TESTCASE(testOsMessageQueueGetMsgSize002);
|
||||||
|
RUN_ONE_TESTCASE(testOsMessageQueueGetCapacity001);
|
||||||
|
RUN_ONE_TESTCASE(testOsMessageQueueGetCapacity002);
|
||||||
|
RUN_ONE_TESTCASE(testOsMessageQueueGetCount001);
|
||||||
|
RUN_ONE_TESTCASE(testOsMessageQueueGetCount002);
|
||||||
|
RUN_ONE_TESTCASE(testOsMessageQueueGetSpace001);
|
||||||
|
RUN_ONE_TESTCASE(testOsMessageQueueGetSpace002);
|
||||||
|
}
|
||||||
@@ -0,0 +1,296 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2023-2023 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 "xts_cmsis.h"
|
||||||
|
|
||||||
|
UINT16 g_cmsisTestMutexCount;
|
||||||
|
osMutexId_t g_cmsisOsMutexId;
|
||||||
|
osMutexAttr_t g_cmsisMutexAttr;
|
||||||
|
|
||||||
|
LITE_TEST_SUIT(Cmsis, Cmsismutex, CmsisMutexFuncTestSuite);
|
||||||
|
|
||||||
|
static BOOL CmsisMutexFuncTestSuiteSetUp(void)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static BOOL CmsisMutexFuncTestSuiteTearDown(void)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void CmsisMutexGetOwnerFunc001(void const *argument)
|
||||||
|
{
|
||||||
|
(void)argument;
|
||||||
|
osStatus_t ret;
|
||||||
|
osThreadId_t id1;
|
||||||
|
osThreadId_t id2;
|
||||||
|
osThreadAttr_t attr;
|
||||||
|
g_cmsisOsMutexId = osMutexNew(&g_cmsisMutexAttr);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisOsMutexId, NULL, g_cmsisOsMutexId);
|
||||||
|
|
||||||
|
ret = osMutexAcquire(g_cmsisOsMutexId, LOS_WAIT_FOREVER);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||||
|
|
||||||
|
id1 = osMutexGetOwner(g_cmsisOsMutexId);
|
||||||
|
id2 = osThreadGetId();
|
||||||
|
ICUNIT_ASSERT_STRING_EQUAL(id1, id2, id1);
|
||||||
|
|
||||||
|
attr.name = osThreadGetName(id1);
|
||||||
|
ICUNIT_ASSERT_STRING_EQUAL("testMutexGetOwner001", attr.name, attr.name);
|
||||||
|
|
||||||
|
ret = osMutexRelease(g_cmsisOsMutexId);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||||
|
|
||||||
|
ret = osMutexDelete(g_cmsisOsMutexId);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||||
|
osThreadExit();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_MUTEX_OPERATION_0100
|
||||||
|
* @tc.name : mutex operation for creat with NULL para
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisMutexFuncTestSuite, testOsMutexNew001, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
osStatus_t status;
|
||||||
|
g_cmsisOsMutexId = osMutexNew(NULL);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisOsMutexId, NULL, g_cmsisOsMutexId);
|
||||||
|
(void)osMutexDelete(g_cmsisOsMutexId);
|
||||||
|
status = osDelay(DELAY_TICKS_5);
|
||||||
|
ICUNIT_ASSERT_EQUAL(status, osOK, status);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_MUTEX_OPERATION_0200
|
||||||
|
* @tc.name : mutex operation for creat
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisMutexFuncTestSuite, testOsMutexNew002, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
osStatus_t status;
|
||||||
|
g_cmsisOsMutexId = osMutexNew(&g_cmsisMutexAttr);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisOsMutexId, NULL, g_cmsisOsMutexId);
|
||||||
|
(void)osMutexDelete(g_cmsisOsMutexId);
|
||||||
|
status = osDelay(DELAY_TICKS_5);
|
||||||
|
ICUNIT_ASSERT_EQUAL(status, osOK, status);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_MUTEX_OPERATION_0300
|
||||||
|
* @tc.name : mutex operation for delete after creat mutex with NULL parameter
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisMutexFuncTestSuite, testOsMutexDelete001, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
osStatus_t ret;
|
||||||
|
g_cmsisOsMutexId = osMutexNew(NULL);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisOsMutexId, NULL, g_cmsisOsMutexId);
|
||||||
|
ret = osMutexDelete(g_cmsisOsMutexId);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||||
|
|
||||||
|
ret = osMutexDelete(g_cmsisOsMutexId);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, osErrorParameter, ret);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_MUTEX_OPERATION_0400
|
||||||
|
* @tc.name : mutex operation for delete
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisMutexFuncTestSuite, testOsMutexDelete002, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
osStatus_t ret;
|
||||||
|
g_cmsisOsMutexId = osMutexNew(&g_cmsisMutexAttr);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisOsMutexId, NULL, g_cmsisOsMutexId);
|
||||||
|
ret = osMutexDelete(g_cmsisOsMutexId);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||||
|
|
||||||
|
ret = osMutexDelete(g_cmsisOsMutexId);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, osErrorParameter, ret);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_MUTEX_OPERATION_0500
|
||||||
|
* @tc.name : mutex operation for delete after mutex acquire and release
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisMutexFuncTestSuite, testOsMutexDelete003, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
osStatus_t ret;
|
||||||
|
g_cmsisOsMutexId = osMutexNew(NULL);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisOsMutexId, NULL, g_cmsisOsMutexId);
|
||||||
|
|
||||||
|
osMutexAcquire(g_cmsisOsMutexId, LOS_WAIT_FOREVER);
|
||||||
|
ret = osMutexDelete(g_cmsisOsMutexId);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, osErrorResource, ret);
|
||||||
|
|
||||||
|
(void)osMutexRelease(g_cmsisOsMutexId);
|
||||||
|
ret = osMutexDelete(g_cmsisOsMutexId);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_MUTEX_OPERATION_0600
|
||||||
|
* @tc.name : mutex delete operation with mutex_id = NULL
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisMutexFuncTestSuite, testOsMutexDelete004, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
osStatus_t ret = osMutexDelete(NULL);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, osErrorParameter, ret);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_MUTEX_OPERATION_0700
|
||||||
|
* @tc.name : mutex acquire operation with mutex_id = NULL
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisMutexFuncTestSuite, testOsMutexAcquire001, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
osStatus_t ret = osMutexAcquire(NULL, LOS_WAIT_FOREVER);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, osErrorParameter, ret);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_MUTEX_OPERATION_0800
|
||||||
|
* @tc.name : mutex operation for acquire
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisMutexFuncTestSuite, testOsMutexAcquire002, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
osStatus_t ret;
|
||||||
|
g_cmsisOsMutexId = osMutexNew(&g_cmsisMutexAttr);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisOsMutexId, NULL, g_cmsisOsMutexId);
|
||||||
|
|
||||||
|
ret = osMutexAcquire(g_cmsisOsMutexId, LOS_WAIT_FOREVER);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||||
|
|
||||||
|
(void)osMutexRelease(g_cmsisOsMutexId);
|
||||||
|
ret = osMutexDelete(g_cmsisOsMutexId);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_MUTEX_OPERATION_0900
|
||||||
|
* @tc.name : mutex operation for release
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisMutexFuncTestSuite, testOsMutexRelease001, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
osStatus_t ret;
|
||||||
|
g_cmsisOsMutexId = osMutexNew(&g_cmsisMutexAttr);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisOsMutexId, NULL, g_cmsisOsMutexId);
|
||||||
|
|
||||||
|
ret = osMutexAcquire(g_cmsisOsMutexId, LOS_WAIT_FOREVER);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||||
|
|
||||||
|
ret = osMutexDelete(g_cmsisOsMutexId);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, osErrorResource, ret);
|
||||||
|
|
||||||
|
ret = osMutexRelease(g_cmsisOsMutexId);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||||
|
|
||||||
|
ret = osMutexDelete(g_cmsisOsMutexId);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_MUTEX_OPERATION_1000
|
||||||
|
* @tc.name : mutex release operation with mutex_id = NULL
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisMutexFuncTestSuite, testOsMutexRelease002, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
osStatus_t ret = osMutexRelease(NULL);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, osErrorParameter, ret);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_MUTEX_OPERATION_1100
|
||||||
|
* @tc.name : mutex operation for get owner
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisMutexFuncTestSuite, testOsMutexGetOwner001, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
osThreadId_t id;
|
||||||
|
osThreadAttr_t osAttr;
|
||||||
|
osAttr.name = "testMutexGetOwner001";
|
||||||
|
osAttr.attr_bits = 0U;
|
||||||
|
osAttr.cb_mem = NULL;
|
||||||
|
osAttr.cb_size = 0U;
|
||||||
|
osAttr.stack_mem = NULL;
|
||||||
|
osAttr.stack_size = TEST_TASK_STACK_SIZE;
|
||||||
|
osAttr.priority = osPriorityAboveNormal;
|
||||||
|
id = osThreadNew((osThreadFunc_t)CmsisMutexGetOwnerFunc001, NULL, &osAttr);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_MUTEX_OPERATION_1200
|
||||||
|
* @tc.name : mutex get owner operation with mutex_id = NULL
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisMutexFuncTestSuite, testOsMutexGetOwner002, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
osThreadId_t id = osMutexGetOwner(NULL);
|
||||||
|
ICUNIT_ASSERT_EQUAL(id, NULL, id);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
RUN_TEST_SUITE(CmsisMutexFuncTestSuite);
|
||||||
|
|
||||||
|
void CmsisMutexFuncTest(void)
|
||||||
|
{
|
||||||
|
RUN_ONE_TESTCASE(testOsMutexNew001);
|
||||||
|
RUN_ONE_TESTCASE(testOsMutexNew002);
|
||||||
|
RUN_ONE_TESTCASE(testOsMutexDelete001);
|
||||||
|
RUN_ONE_TESTCASE(testOsMutexDelete002);
|
||||||
|
RUN_ONE_TESTCASE(testOsMutexDelete003);
|
||||||
|
RUN_ONE_TESTCASE(testOsMutexDelete004);
|
||||||
|
RUN_ONE_TESTCASE(testOsMutexAcquire001);
|
||||||
|
RUN_ONE_TESTCASE(testOsMutexAcquire002);
|
||||||
|
RUN_ONE_TESTCASE(testOsMutexRelease001);
|
||||||
|
RUN_ONE_TESTCASE(testOsMutexRelease002);
|
||||||
|
RUN_ONE_TESTCASE(testOsMutexGetOwner001);
|
||||||
|
RUN_ONE_TESTCASE(testOsMutexGetOwner002);
|
||||||
|
}
|
||||||
@@ -0,0 +1,466 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2023-2023 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 "xts_cmsis.h"
|
||||||
|
|
||||||
|
osSemaphoreId_t g_cmsisSemSemaph;
|
||||||
|
|
||||||
|
LITE_TEST_SUIT(Cmsis, CmsisSem, CmsisSemFuncTestSuite);
|
||||||
|
|
||||||
|
static BOOL CmsisSemFuncTestSuiteSetUp(void)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static BOOL CmsisSemFuncTestSuiteTearDown(void)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_0100
|
||||||
|
* @tc.name : semaphore operation for creat when Semaphhore count = 1 and 0
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreNew001, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
osStatus_t status;
|
||||||
|
g_cmsisSemSemaph = osSemaphoreNew(SEMAPHHORE_COUNT_INT1, SEMAPHHORE_COUNT_INT0, NULL);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisSemSemaph, NULL, g_cmsisSemSemaph);
|
||||||
|
(void)osSemaphoreDelete(g_cmsisSemSemaph);
|
||||||
|
status = osDelay(DELAY_TICKS_5);
|
||||||
|
ICUNIT_ASSERT_EQUAL(status, osOK, status);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_0200
|
||||||
|
* @tc.name : semaphore operation for creat when Semaphhore count = 10 and 1
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreNew002, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
osStatus_t status;
|
||||||
|
g_cmsisSemSemaph = osSemaphoreNew(SEMAPHHORE_COUNT_INT10, SEMAPHHORE_COUNT_INT1, NULL);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisSemSemaph, NULL, g_cmsisSemSemaph);
|
||||||
|
(void)osSemaphoreDelete(g_cmsisSemSemaph);
|
||||||
|
status = osDelay(DELAY_TICKS_5);
|
||||||
|
ICUNIT_ASSERT_EQUAL(status, osOK, status);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_0300
|
||||||
|
* @tc.name : semaphore operation for creat when Semaphhore count = 0 and 10
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreNew003, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
osStatus_t status;
|
||||||
|
g_cmsisSemSemaph = osSemaphoreNew(SEMAPHHORE_COUNT_INT0, SEMAPHHORE_COUNT_INT10, NULL);
|
||||||
|
ICUNIT_ASSERT_EQUAL(g_cmsisSemSemaph, NULL, g_cmsisSemSemaph);
|
||||||
|
(void)osSemaphoreDelete(g_cmsisSemSemaph);
|
||||||
|
status = osDelay(DELAY_TICKS_5);
|
||||||
|
ICUNIT_ASSERT_EQUAL(status, osOK, status);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_0400
|
||||||
|
* @tc.name : semaphore operation for creat when Semaphhore count = 0 and 0
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreNew004, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
osStatus_t status;
|
||||||
|
g_cmsisSemSemaph = osSemaphoreNew(SEMAPHHORE_COUNT_INT0, SEMAPHHORE_COUNT_INT0, NULL);
|
||||||
|
ICUNIT_ASSERT_EQUAL(g_cmsisSemSemaph, NULL, g_cmsisSemSemaph);
|
||||||
|
(void)osSemaphoreDelete(g_cmsisSemSemaph);
|
||||||
|
status = osDelay(DELAY_TICKS_5);
|
||||||
|
ICUNIT_ASSERT_EQUAL(status, osOK, status);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_0500
|
||||||
|
* @tc.name : semaphore operation for creat when Semaphhore count = 1 and 1
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreNew005, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
osStatus_t status;
|
||||||
|
g_cmsisSemSemaph = osSemaphoreNew(SEMAPHHORE_COUNT_INT1, SEMAPHHORE_COUNT_INT1, NULL);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisSemSemaph, NULL, g_cmsisSemSemaph);
|
||||||
|
(void)osSemaphoreDelete(g_cmsisSemSemaph);
|
||||||
|
status = osDelay(DELAY_TICKS_5);
|
||||||
|
ICUNIT_ASSERT_EQUAL(status, osOK, status);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_0600
|
||||||
|
* @tc.name : semaphore operation for creat when Semaphhore count = 10 and 10
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreNew006, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
osStatus_t status;
|
||||||
|
g_cmsisSemSemaph = osSemaphoreNew(SEMAPHHORE_COUNT_INT10, SEMAPHHORE_COUNT_INT10, NULL);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisSemSemaph, NULL, g_cmsisSemSemaph);
|
||||||
|
(void)osSemaphoreDelete(g_cmsisSemSemaph);
|
||||||
|
status = osDelay(DELAY_TICKS_5);
|
||||||
|
ICUNIT_ASSERT_EQUAL(status, osOK, status);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_0700
|
||||||
|
* @tc.name : semaphore operation for creat when Semaphhore count = 0xFE and 0
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreNew007, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
osStatus_t status;
|
||||||
|
g_cmsisSemSemaph = osSemaphoreNew(SEMAPHHORE_COUNT_HEX_MAX, SEMAPHHORE_COUNT_INT0, NULL);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisSemSemaph, NULL, g_cmsisSemSemaph);
|
||||||
|
(void)osSemaphoreDelete(g_cmsisSemSemaph);
|
||||||
|
status = osDelay(DELAY_TICKS_5);
|
||||||
|
ICUNIT_ASSERT_EQUAL(status, osOK, status);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_0800
|
||||||
|
* @tc.name : semaphore operation for creat when Semaphhore count = 0 and 0xFE
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreNew008, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
osStatus_t status;
|
||||||
|
g_cmsisSemSemaph = osSemaphoreNew(SEMAPHHORE_COUNT_INT0, SEMAPHHORE_COUNT_HEX_MAX, NULL);
|
||||||
|
ICUNIT_ASSERT_EQUAL(g_cmsisSemSemaph, NULL, g_cmsisSemSemaph);
|
||||||
|
(void)osSemaphoreDelete(g_cmsisSemSemaph);
|
||||||
|
status = osDelay(DELAY_TICKS_5);
|
||||||
|
ICUNIT_ASSERT_EQUAL(status, osOK, status);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_0900
|
||||||
|
* @tc.name : semaphore operation for delete
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreDelete001, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
osStatus_t ret;
|
||||||
|
g_cmsisSemSemaph = osSemaphoreNew(SEMAPHHORE_COUNT_INT10, SEMAPHHORE_COUNT_INT0, NULL);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisSemSemaph, NULL, g_cmsisSemSemaph);
|
||||||
|
ret = osSemaphoreDelete(g_cmsisSemSemaph);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_1000
|
||||||
|
* @tc.name : semaphore delete operation twice
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreDelete002, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
osStatus_t ret;
|
||||||
|
g_cmsisSemSemaph = osSemaphoreNew(SEMAPHHORE_COUNT_INT10, SEMAPHHORE_COUNT_INT0, NULL);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisSemSemaph, NULL, g_cmsisSemSemaph);
|
||||||
|
|
||||||
|
ret = osSemaphoreDelete(g_cmsisSemSemaph);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||||
|
|
||||||
|
ret = osSemaphoreDelete(g_cmsisSemSemaph);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, osErrorParameter, ret);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_1100
|
||||||
|
* @tc.name : semaphore delete operation with semaphore_id = NULL
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreDelete003, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
osStatus_t ret = osSemaphoreDelete(NULL);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, osErrorParameter, ret);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_1200
|
||||||
|
* @tc.name : semaphore operation for acquire when Semaphhore count = 1 and 1
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreAcquire001, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
osStatus_t ret;
|
||||||
|
g_cmsisSemSemaph = osSemaphoreNew(SEMAPHHORE_COUNT_INT1, SEMAPHHORE_COUNT_INT1, NULL);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisSemSemaph, NULL, g_cmsisSemSemaph);
|
||||||
|
ret = osSemaphoreAcquire(g_cmsisSemSemaph, 0);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||||
|
|
||||||
|
ret = osSemaphoreDelete(g_cmsisSemSemaph);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_1300
|
||||||
|
* @tc.name : semaphore operation for acquire when Semaphhore count = 1 and 0
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreAcquire002, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
osStatus_t ret;
|
||||||
|
g_cmsisSemSemaph = osSemaphoreNew(SEMAPHHORE_COUNT_INT1, SEMAPHHORE_COUNT_INT0, NULL);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisSemSemaph, NULL, g_cmsisSemSemaph);
|
||||||
|
ret = osSemaphoreAcquire(g_cmsisSemSemaph, 0);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, osErrorResource, ret);
|
||||||
|
|
||||||
|
ret = osSemaphoreDelete(g_cmsisSemSemaph);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_1400
|
||||||
|
* @tc.name : semaphore operation for acquire when Semaphhore count = 0 and 1
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreAcquire003, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
g_cmsisSemSemaph = osSemaphoreNew(SEMAPHHORE_COUNT_INT0, SEMAPHHORE_COUNT_INT1, NULL);
|
||||||
|
ICUNIT_ASSERT_EQUAL(g_cmsisSemSemaph, NULL, g_cmsisSemSemaph);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_1500
|
||||||
|
* @tc.name : semaphore acquire operation with semaphore_id = NULL
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreAcquire004, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
osStatus_t ret = osSemaphoreAcquire(NULL, 0);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, osErrorParameter, ret);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_1600
|
||||||
|
* @tc.name : semaphore operation for release
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreRelease001, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
osStatus_t ret;
|
||||||
|
g_cmsisSemSemaph = osSemaphoreNew(SEMAPHHORE_COUNT_INT1, SEMAPHHORE_COUNT_INT0, NULL);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisSemSemaph, NULL, g_cmsisSemSemaph);
|
||||||
|
|
||||||
|
ret = osSemaphoreAcquire(g_cmsisSemSemaph, 0);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, osErrorResource, ret);
|
||||||
|
|
||||||
|
ret = osSemaphoreRelease(g_cmsisSemSemaph);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||||
|
|
||||||
|
ret = osSemaphoreDelete(g_cmsisSemSemaph);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_1700
|
||||||
|
* @tc.name : semaphore release operation twice
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreRelease002, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
osStatus_t ret;
|
||||||
|
g_cmsisSemSemaph = osSemaphoreNew(SEMAPHHORE_COUNT_INT1, SEMAPHHORE_COUNT_INT0, NULL);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisSemSemaph, NULL, g_cmsisSemSemaph);
|
||||||
|
|
||||||
|
ret = osSemaphoreRelease(g_cmsisSemSemaph);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||||
|
ret = osSemaphoreRelease(g_cmsisSemSemaph);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, osErrorResource, ret);
|
||||||
|
|
||||||
|
ret = osSemaphoreDelete(g_cmsisSemSemaph);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_1800
|
||||||
|
* @tc.name : semaphore operation for release after semaphore acquire
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreRelease003, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
osStatus_t ret;
|
||||||
|
g_cmsisSemSemaph = osSemaphoreNew(SEMAPHHORE_COUNT_INT1, SEMAPHHORE_COUNT_INT1, NULL);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisSemSemaph, NULL, g_cmsisSemSemaph);
|
||||||
|
|
||||||
|
ret = osSemaphoreRelease(g_cmsisSemSemaph);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, osErrorResource, ret);
|
||||||
|
|
||||||
|
ret = osSemaphoreAcquire(g_cmsisSemSemaph, 0);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||||
|
|
||||||
|
ret = osSemaphoreRelease(g_cmsisSemSemaph);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||||
|
ret = osSemaphoreRelease(g_cmsisSemSemaph);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, osErrorResource, ret);
|
||||||
|
|
||||||
|
ret = osSemaphoreDelete(g_cmsisSemSemaph);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_1900
|
||||||
|
* @tc.name : semaphore release operation with semaphore_id = NULL
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreRelease004, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
osStatus_t ret = osSemaphoreRelease(NULL);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, osErrorParameter, ret);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_2000
|
||||||
|
* @tc.name : semaphore operation for get count when Semaphhore count = 1 or 0xFE
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreGetCount001, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
osStatus_t ret;
|
||||||
|
g_cmsisSemSemaph = osSemaphoreNew(SEMAPHHORE_COUNT_INT1, SEMAPHHORE_COUNT_INT1, NULL);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisSemSemaph, NULL, g_cmsisSemSemaph);
|
||||||
|
ret = osSemaphoreGetCount(g_cmsisSemSemaph);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 1, ret); /* 1, common data for test, no special meaning */
|
||||||
|
ret = osSemaphoreDelete(g_cmsisSemSemaph);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||||
|
|
||||||
|
g_cmsisSemSemaph = osSemaphoreNew(SEMAPHHORE_COUNT_HEX_MAX, SEMAPHHORE_COUNT_HEX_MAX, NULL);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisSemSemaph, NULL, g_cmsisSemSemaph);
|
||||||
|
ret = osSemaphoreGetCount(g_cmsisSemSemaph);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, SEMAPHHORE_COUNT_HEX_MAX, ret);
|
||||||
|
ret = osSemaphoreDelete(g_cmsisSemSemaph);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_2100
|
||||||
|
* @tc.name : semaphore operation for get count when Semaphhore count = 1 or 0
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreGetCount002, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
osStatus_t ret;
|
||||||
|
g_cmsisSemSemaph = osSemaphoreNew(SEMAPHHORE_COUNT_INT1, SEMAPHHORE_COUNT_INT0, NULL);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisSemSemaph, NULL, g_cmsisSemSemaph);
|
||||||
|
ret = osSemaphoreGetCount(g_cmsisSemSemaph);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ret = osSemaphoreDelete(g_cmsisSemSemaph);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||||
|
|
||||||
|
g_cmsisSemSemaph = osSemaphoreNew(SEMAPHHORE_COUNT_INT0, SEMAPHHORE_COUNT_INT1, NULL);
|
||||||
|
ICUNIT_ASSERT_EQUAL(g_cmsisSemSemaph, NULL, g_cmsisSemSemaph);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_2200
|
||||||
|
* @tc.name : semaphore operation for get count
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreGetCount003, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
osStatus_t ret;
|
||||||
|
g_cmsisSemSemaph = osSemaphoreNew(SEMAPHHORE_COUNT_HEX_MAX, SEMAPHHORE_COUNT_HEX_MAX, NULL);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisSemSemaph, NULL, g_cmsisSemSemaph);
|
||||||
|
ret = osSemaphoreAcquire(g_cmsisSemSemaph, osWaitForever);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||||
|
|
||||||
|
ret = osSemaphoreGetCount(g_cmsisSemSemaph);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, SEMAPHHORE_COUNT_HEX_MAX - 1, ret); /* 1, common data for test, no special meaning */
|
||||||
|
ret = osSemaphoreDelete(g_cmsisSemSemaph);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_2300
|
||||||
|
* @tc.name : semaphore get count operation with semaphore_id = NULL
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreGetCount004, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
osStatus_t ret = osSemaphoreGetCount(NULL);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
RUN_TEST_SUITE(CmsisSemFuncTestSuite);
|
||||||
|
|
||||||
|
void CmsisSemFuncTest(void)
|
||||||
|
{
|
||||||
|
RUN_ONE_TESTCASE(testOsSemaphoreNew001);
|
||||||
|
RUN_ONE_TESTCASE(testOsSemaphoreNew002);
|
||||||
|
RUN_ONE_TESTCASE(testOsSemaphoreNew003);
|
||||||
|
RUN_ONE_TESTCASE(testOsSemaphoreNew004);
|
||||||
|
RUN_ONE_TESTCASE(testOsSemaphoreNew005);
|
||||||
|
RUN_ONE_TESTCASE(testOsSemaphoreNew006);
|
||||||
|
RUN_ONE_TESTCASE(testOsSemaphoreNew007);
|
||||||
|
RUN_ONE_TESTCASE(testOsSemaphoreNew008);
|
||||||
|
RUN_ONE_TESTCASE(testOsSemaphoreDelete001);
|
||||||
|
RUN_ONE_TESTCASE(testOsSemaphoreDelete002);
|
||||||
|
RUN_ONE_TESTCASE(testOsSemaphoreDelete003);
|
||||||
|
RUN_ONE_TESTCASE(testOsSemaphoreAcquire001);
|
||||||
|
RUN_ONE_TESTCASE(testOsSemaphoreAcquire002);
|
||||||
|
RUN_ONE_TESTCASE(testOsSemaphoreAcquire003);
|
||||||
|
RUN_ONE_TESTCASE(testOsSemaphoreAcquire004);
|
||||||
|
RUN_ONE_TESTCASE(testOsSemaphoreRelease001);
|
||||||
|
RUN_ONE_TESTCASE(testOsSemaphoreRelease002);
|
||||||
|
RUN_ONE_TESTCASE(testOsSemaphoreRelease003);
|
||||||
|
RUN_ONE_TESTCASE(testOsSemaphoreRelease004);
|
||||||
|
RUN_ONE_TESTCASE(testOsSemaphoreGetCount001);
|
||||||
|
RUN_ONE_TESTCASE(testOsSemaphoreGetCount002);
|
||||||
|
RUN_ONE_TESTCASE(testOsSemaphoreGetCount003);
|
||||||
|
RUN_ONE_TESTCASE(testOsSemaphoreGetCount004);
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,768 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2023-2023 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 "xts_cmsis.h"
|
||||||
|
|
||||||
|
UINT16 g_cmsisTestTimeCount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.desc : register a test suite, this suite is used to test basic flow and interface dependency
|
||||||
|
* @param : subsystem name is utils
|
||||||
|
* @param : module name is utilsFile
|
||||||
|
* @param : test suit name is CmsisTaskFuncTestSuite
|
||||||
|
*/
|
||||||
|
LITE_TEST_SUIT(Cmsis, Cmsistimer, CmsisTimerFuncTestSuite);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.setup : setup for all testcases
|
||||||
|
* @return : setup result, TRUE is success, FALSE is fail
|
||||||
|
*/
|
||||||
|
static BOOL CmsisTimerFuncTestSuiteSetUp(void)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.teardown : teardown for all testcases
|
||||||
|
* @return : teardown result, TRUE is success, FALSE is fail
|
||||||
|
*/
|
||||||
|
static BOOL CmsisTimerFuncTestSuiteTearDown(void)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void CmsisTimerFunc001(void const *argument)
|
||||||
|
{
|
||||||
|
(void)argument;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void CmsisTimerFunc002(void const *argument)
|
||||||
|
{
|
||||||
|
(void)argument;
|
||||||
|
g_cmsisTestTimeCount++;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_0100
|
||||||
|
* @tc.name : timer operation for creat with parameter osTimerOnce
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsTimerNew001, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
osTimerId_t id;
|
||||||
|
osStatus_t status;
|
||||||
|
UINT32 value = 0xffff;
|
||||||
|
id = osTimerNew((osTimerFunc_t)CmsisTimerFunc001, osTimerOnce, &value, NULL);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
|
||||||
|
(void)osTimerDelete(id);
|
||||||
|
status = osDelay(DELAY_TICKS_5);
|
||||||
|
ICUNIT_ASSERT_EQUAL(status, osOK, status);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_0200
|
||||||
|
* @tc.name : timer operation for creat with parameter osTimerPeriodic
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsTimerNew002, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
osTimerId_t id;
|
||||||
|
osStatus_t status;
|
||||||
|
UINT32 value = 0xffff;
|
||||||
|
id = osTimerNew((osTimerFunc_t)CmsisTimerFunc001, osTimerPeriodic, &value, NULL);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
|
||||||
|
(void)osTimerDelete(id);
|
||||||
|
status = osDelay(DELAY_TICKS_5);
|
||||||
|
ICUNIT_ASSERT_EQUAL(status, osOK, status);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_0300
|
||||||
|
* @tc.name : timer creat operation with NULL func and parameter osTimerOnce
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsTimerNew003, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
osTimerId_t id;
|
||||||
|
osStatus_t status;
|
||||||
|
UINT32 value = 0xffff;
|
||||||
|
id = osTimerNew(NULL, osTimerOnce, &value, NULL);
|
||||||
|
ICUNIT_ASSERT_EQUAL(id, NULL, id);
|
||||||
|
status = osDelay(DELAY_TICKS_5);
|
||||||
|
ICUNIT_ASSERT_EQUAL(status, osOK, status);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_0400
|
||||||
|
* @tc.name : timer creat operation with NULL func and parameter osTimerPeriodic
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsTimerNew004, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
osTimerId_t id;
|
||||||
|
osStatus_t status;
|
||||||
|
UINT32 value = 0xffff;
|
||||||
|
id = osTimerNew(NULL, osTimerPeriodic, &value, NULL);
|
||||||
|
ICUNIT_ASSERT_EQUAL(id, NULL, id);
|
||||||
|
status = osDelay(DELAY_TICKS_5);
|
||||||
|
ICUNIT_ASSERT_EQUAL(status, osOK, status);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_0500
|
||||||
|
* @tc.name : timer operation for invalid timer type
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsTimerNew005, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
osTimerId_t id;
|
||||||
|
osStatus_t status;
|
||||||
|
UINT32 value = 0xffff;
|
||||||
|
id = osTimerNew((osTimerFunc_t)CmsisTimerFunc001, INVALID_TIMER_TYPE, &value, NULL);
|
||||||
|
ICUNIT_ASSERT_EQUAL(id, NULL, id);
|
||||||
|
status = osDelay(DELAY_TICKS_5);
|
||||||
|
ICUNIT_ASSERT_EQUAL(status, osOK, status);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_0600
|
||||||
|
* @tc.name : timer operation for start with parameter osTimerOnce
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsTimerStart001, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
UINT32 uwRet;
|
||||||
|
osTimerId_t id;
|
||||||
|
UINT32 value = 0xffff;
|
||||||
|
UINT32 millisec = MILLISEC_NUM_INT4;
|
||||||
|
id = osTimerNew((osTimerFunc_t)CmsisTimerFunc001, osTimerOnce, &value, NULL);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
|
||||||
|
uwRet = osTimerStart(id, millisec);
|
||||||
|
ICUNIT_ASSERT_EQUAL(osOK, uwRet, uwRet);
|
||||||
|
(void)osTimerDelete(id);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_0700
|
||||||
|
* @tc.name : timer operation for start with parameter osTimerPeriodic
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsTimerStart002, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
UINT32 uwRet;
|
||||||
|
osTimerId_t id;
|
||||||
|
UINT32 value = 0xffff;
|
||||||
|
UINT32 millisec = MILLISEC_NUM_INT4;
|
||||||
|
id = osTimerNew((osTimerFunc_t)CmsisTimerFunc001, osTimerPeriodic, &value, NULL);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
|
||||||
|
uwRet = osTimerStart(id, millisec);
|
||||||
|
ICUNIT_ASSERT_EQUAL(osOK, uwRet, uwRet);
|
||||||
|
(void)osTimerDelete(id);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_0800
|
||||||
|
* @tc.name : timer operation for start with callback func and parameter osTimerOnce
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsTimerStart003, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
UINT32 uwRet;
|
||||||
|
osTimerId_t id;
|
||||||
|
osStatus_t status;
|
||||||
|
UINT32 value = 0xffff;
|
||||||
|
UINT32 millisec = MILLISEC_NUM_INT4;
|
||||||
|
g_cmsisTestTimeCount = 0;
|
||||||
|
id = osTimerNew((osTimerFunc_t)CmsisTimerFunc002, osTimerOnce, &value, NULL);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
|
||||||
|
uwRet = osTimerStart(id, millisec);
|
||||||
|
ICUNIT_ASSERT_EQUAL(osOK, uwRet, uwRet);
|
||||||
|
|
||||||
|
status = osDelay(DELAY_TICKS_10);
|
||||||
|
ICUNIT_ASSERT_EQUAL(status, osOK, status);
|
||||||
|
ICUNIT_ASSERT_EQUAL(1, g_cmsisTestTimeCount, g_cmsisTestTimeCount); /* 1, common data for test, no special meaning */
|
||||||
|
(void)osTimerDelete(id);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_0900
|
||||||
|
* @tc.name : timer operation for start with callback func and parameter osTimerPeriodic
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsTimerStart004, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
UINT32 uwRet;
|
||||||
|
osTimerId_t id;
|
||||||
|
osStatus_t status;
|
||||||
|
UINT32 value = 0xffff;
|
||||||
|
UINT32 millisec = MILLISEC_NUM_INT4;
|
||||||
|
g_cmsisTestTimeCount = 0;
|
||||||
|
id = osTimerNew((osTimerFunc_t)CmsisTimerFunc002, osTimerPeriodic, &value, NULL);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
|
||||||
|
uwRet = osTimerStart(id, millisec);
|
||||||
|
ICUNIT_ASSERT_EQUAL(osOK, uwRet, uwRet);
|
||||||
|
|
||||||
|
status = osDelay(DELAY_TICKS_10);
|
||||||
|
ICUNIT_ASSERT_EQUAL(status, osOK, status);
|
||||||
|
ICUNIT_ASSERT_EQUAL(TIMER_PERIODIC_COUNT, g_cmsisTestTimeCount, g_cmsisTestTimeCount);
|
||||||
|
(void)osTimerDelete(id);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_1000
|
||||||
|
* @tc.name : timer start operation with ticks = 0 and parameter osTimerOnce
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsTimerStart005, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
UINT32 uwRet;
|
||||||
|
osTimerId_t id;
|
||||||
|
UINT32 value = 0xffff;
|
||||||
|
id = osTimerNew((osTimerFunc_t)CmsisTimerFunc001, osTimerOnce, &value, NULL);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
|
||||||
|
uwRet = osTimerStart(id, 0);
|
||||||
|
ICUNIT_ASSERT_EQUAL(osErrorParameter, uwRet, uwRet);
|
||||||
|
(void)osTimerDelete(id);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_1100
|
||||||
|
* @tc.name : timer start operation with ticks = 0 and parameter osTimerPeriodic
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsTimerStart006, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
UINT32 uwRet;
|
||||||
|
osTimerId_t id;
|
||||||
|
UINT32 value = 0xffff;
|
||||||
|
id = osTimerNew((osTimerFunc_t)CmsisTimerFunc001, osTimerPeriodic, &value, NULL);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
|
||||||
|
uwRet = osTimerStart(id, 0);
|
||||||
|
ICUNIT_ASSERT_EQUAL(osErrorParameter, uwRet, uwRet);
|
||||||
|
(void)osTimerDelete(id);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_1200
|
||||||
|
* @tc.name : timer start operation with timer_id = NULL
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsTimerStart007, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
UINT32 millisec = MILLISEC_NUM_INT4;
|
||||||
|
UINT32 uwRet = osTimerStart(NULL, millisec);
|
||||||
|
ICUNIT_ASSERT_EQUAL(osErrorParameter, uwRet, uwRet);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_1300
|
||||||
|
* @tc.name : timer operation for delete with parameter osTimerOnce
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsTimerDelete001, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
UINT32 uwRet;
|
||||||
|
osTimerId_t id;
|
||||||
|
osStatus_t status;
|
||||||
|
UINT32 value = 0xffff;
|
||||||
|
id = osTimerNew((osTimerFunc_t)CmsisTimerFunc001, osTimerOnce, &value, NULL);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
|
||||||
|
|
||||||
|
status = osDelay(1); /* 1, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(status, osOK, status);
|
||||||
|
uwRet = osTimerDelete(id);
|
||||||
|
ICUNIT_ASSERT_EQUAL(osOK, uwRet, uwRet);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_1400
|
||||||
|
* @tc.name : timer operation for delete with parameter osTimerPeriodic
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsTimerDelete002, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
UINT32 uwRet;
|
||||||
|
osTimerId_t id;
|
||||||
|
osStatus_t status;
|
||||||
|
UINT32 value = 0xffff;
|
||||||
|
id = osTimerNew((osTimerFunc_t)CmsisTimerFunc001, osTimerPeriodic, &value, NULL);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
|
||||||
|
|
||||||
|
status = osDelay(1); /* 1, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(status, osOK, status);
|
||||||
|
uwRet = osTimerDelete(id);
|
||||||
|
ICUNIT_ASSERT_EQUAL(osOK, uwRet, uwRet);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_1500
|
||||||
|
* @tc.name : timer operation for delete after osTimerStart with parameter osTimerOnce
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsTimerDelete003, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
UINT32 uwRet;
|
||||||
|
osTimerId_t id;
|
||||||
|
osStatus_t status;
|
||||||
|
UINT32 value = 0xffff;
|
||||||
|
UINT32 millisec = MILLISEC_NUM_INT10;
|
||||||
|
id = osTimerNew((osTimerFunc_t)CmsisTimerFunc001, osTimerOnce, &value, NULL);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
|
||||||
|
|
||||||
|
osTimerStart(id, millisec);
|
||||||
|
status = osDelay(1); /* 1, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(status, osOK, status);
|
||||||
|
uwRet = osTimerDelete(id);
|
||||||
|
ICUNIT_ASSERT_EQUAL(osOK, uwRet, uwRet);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_1600
|
||||||
|
* @tc.name : timer operation for delete after osTimerStart with parameter osTimerPeriodic
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsTimerDelete004, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
UINT32 uwRet;
|
||||||
|
osTimerId_t id;
|
||||||
|
osStatus_t status;
|
||||||
|
UINT32 value = 0xffff;
|
||||||
|
UINT32 millisec = MILLISEC_NUM_INT10;
|
||||||
|
id = osTimerNew((osTimerFunc_t)CmsisTimerFunc001, osTimerPeriodic, &value, NULL);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
|
||||||
|
|
||||||
|
uwRet = osTimerStart(id, millisec);
|
||||||
|
ICUNIT_ASSERT_EQUAL(uwRet, osOK, uwRet);
|
||||||
|
status = osDelay(1); /* 1, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(status, osOK, status);
|
||||||
|
uwRet = osTimerDelete(id);
|
||||||
|
ICUNIT_ASSERT_EQUAL(osOK, uwRet, uwRet);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_1700
|
||||||
|
* @tc.name : timer delete operation with timer_id = NULL
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsTimerDelete005, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
UINT32 uwRet = osTimerDelete(NULL);
|
||||||
|
ICUNIT_ASSERT_EQUAL(osErrorParameter, uwRet, uwRet);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_1800
|
||||||
|
* @tc.name : timer operation for stop after osTimerStart with parameter osTimerOnce
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsTimerStop001, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
UINT32 uwRet;
|
||||||
|
osTimerId_t id;
|
||||||
|
osStatus_t status;
|
||||||
|
UINT32 value = 0xffff;
|
||||||
|
UINT32 millisec = MILLISEC_NUM_INT10;
|
||||||
|
id = osTimerNew((osTimerFunc_t)CmsisTimerFunc001, osTimerOnce, &value, NULL);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
|
||||||
|
|
||||||
|
uwRet = osTimerStart(id, millisec);
|
||||||
|
ICUNIT_ASSERT_EQUAL(uwRet, osOK, uwRet);
|
||||||
|
status = osDelay(1); /* 1, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(status, osOK, status);
|
||||||
|
uwRet = osTimerStop(id);
|
||||||
|
ICUNIT_ASSERT_EQUAL(osOK, uwRet, uwRet);
|
||||||
|
(void)osTimerDelete(id);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_1900
|
||||||
|
* @tc.name : timer operation for stop after osTimerStart with parameter osTimerPeriodic
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsTimerStop002, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
UINT32 uwRet;
|
||||||
|
osTimerId_t id;
|
||||||
|
osStatus_t status;
|
||||||
|
UINT32 value = 0xffff;
|
||||||
|
UINT32 millisec = MILLISEC_NUM_INT10;
|
||||||
|
id = osTimerNew((osTimerFunc_t)CmsisTimerFunc001, osTimerPeriodic, &value, NULL);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
|
||||||
|
|
||||||
|
uwRet = osTimerStart(id, millisec);
|
||||||
|
ICUNIT_ASSERT_EQUAL(uwRet, osOK, uwRet);
|
||||||
|
status = osDelay(1); /* 1, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(status, osOK, status);
|
||||||
|
uwRet = osTimerStop(id);
|
||||||
|
ICUNIT_ASSERT_EQUAL(osOK, uwRet, uwRet);
|
||||||
|
(void)osTimerDelete(id);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_2000
|
||||||
|
* @tc.name : timer operation for stop with parameter osTimerOnce
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsTimerStop003, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
UINT32 uwRet;
|
||||||
|
osTimerId_t id;
|
||||||
|
osStatus_t status;
|
||||||
|
UINT32 value = 0xffff;
|
||||||
|
id = osTimerNew((osTimerFunc_t)CmsisTimerFunc001, osTimerOnce, &value, NULL);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
|
||||||
|
|
||||||
|
status = osDelay(1); /* 1, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(status, osOK, status);
|
||||||
|
uwRet = osTimerStop(id);
|
||||||
|
ICUNIT_ASSERT_EQUAL(osErrorResource, uwRet, uwRet);
|
||||||
|
(void)osTimerDelete(id);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_2100
|
||||||
|
* @tc.name : timer operation for stop with parameter osTimerPeriodic
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsTimerStop004, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
UINT32 uwRet;
|
||||||
|
osTimerId_t id;
|
||||||
|
osStatus_t status;
|
||||||
|
UINT32 value = 0xffff;
|
||||||
|
id = osTimerNew((osTimerFunc_t)CmsisTimerFunc001, osTimerPeriodic, &value, NULL);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
|
||||||
|
|
||||||
|
status = osDelay(1); /* 1, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(status, osOK, status);
|
||||||
|
uwRet = osTimerStop(id);
|
||||||
|
ICUNIT_ASSERT_EQUAL(osErrorResource, uwRet, uwRet);
|
||||||
|
(void)osTimerDelete(id);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_2200
|
||||||
|
* @tc.name : timer stop operation with timer_id = NULL
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsTimerStop005, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
UINT32 uwRet = osTimerStop(NULL);
|
||||||
|
ICUNIT_ASSERT_EQUAL(osErrorParameter, uwRet, uwRet);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_2300
|
||||||
|
* @tc.name : timer operation for running
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsTimerIsRunning001, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
UINT32 uwRet;
|
||||||
|
osTimerId_t id;
|
||||||
|
UINT32 value = 0xffff;
|
||||||
|
id = osTimerNew((osTimerFunc_t)CmsisTimerFunc001, osTimerOnce, &value, NULL);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
|
||||||
|
|
||||||
|
uwRet = osTimerIsRunning(id);
|
||||||
|
ICUNIT_ASSERT_EQUAL(uwRet, 0, uwRet);
|
||||||
|
(void)osTimerDelete(id);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_2400
|
||||||
|
* @tc.name : timer operation for running after osTimerStart
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsTimerIsRunning002, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
UINT32 uwRet;
|
||||||
|
osTimerId_t id;
|
||||||
|
UINT32 value = 0xffff;
|
||||||
|
UINT32 millisec = MILLISEC_NUM_INT10;
|
||||||
|
id = osTimerNew((osTimerFunc_t)CmsisTimerFunc001, osTimerOnce, &value, NULL);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
|
||||||
|
|
||||||
|
uwRet = osTimerStart(id, millisec);
|
||||||
|
ICUNIT_ASSERT_EQUAL(uwRet, osOK, uwRet);
|
||||||
|
uwRet = osTimerIsRunning(id);
|
||||||
|
ICUNIT_ASSERT_EQUAL(uwRet, 1, uwRet); /* 1, common data for test, no special meaning */
|
||||||
|
(void)osTimerDelete(id);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_2500
|
||||||
|
* @tc.name : timer operation for running after osTimerStart and osTimerStop
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsTimerIsRunning003, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
UINT32 uwRet;
|
||||||
|
osTimerId_t id;
|
||||||
|
UINT32 value = 0xffff;
|
||||||
|
UINT32 millisec = MILLISEC_NUM_INT10;
|
||||||
|
id = osTimerNew((osTimerFunc_t)CmsisTimerFunc001, osTimerOnce, &value, NULL);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
|
||||||
|
|
||||||
|
uwRet = osTimerStart(id, millisec);
|
||||||
|
ICUNIT_ASSERT_EQUAL(uwRet, osOK, uwRet);
|
||||||
|
uwRet = osTimerStop(id);
|
||||||
|
ICUNIT_ASSERT_EQUAL(uwRet, osOK, uwRet);
|
||||||
|
|
||||||
|
uwRet = osTimerIsRunning(id);
|
||||||
|
ICUNIT_ASSERT_EQUAL(uwRet, 0, uwRet);
|
||||||
|
(void)osTimerDelete(id);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_2600
|
||||||
|
* @tc.name : timer operation for running after osTimerStart and osTimerDelete
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsTimerIsRunning004, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
UINT32 uwRet;
|
||||||
|
osTimerId_t id;
|
||||||
|
UINT32 value = 0xffff;
|
||||||
|
UINT32 millisec = MILLISEC_NUM_INT10;
|
||||||
|
id = osTimerNew((osTimerFunc_t)CmsisTimerFunc001, osTimerOnce, &value, NULL);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
|
||||||
|
|
||||||
|
uwRet = osTimerStart(id, millisec);
|
||||||
|
ICUNIT_ASSERT_EQUAL(uwRet, osOK, uwRet);
|
||||||
|
uwRet = osTimerDelete(id);
|
||||||
|
ICUNIT_ASSERT_EQUAL(uwRet, osOK, uwRet);
|
||||||
|
uwRet = osTimerIsRunning(id);
|
||||||
|
ICUNIT_ASSERT_EQUAL(uwRet, 0, uwRet);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_2700
|
||||||
|
* @tc.name : timer operation for running with parameter osTimerPeriodic
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsTimerIsRunning005, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
UINT32 uwRet;
|
||||||
|
osTimerId_t id;
|
||||||
|
UINT32 value = 0xffff;
|
||||||
|
id = osTimerNew((osTimerFunc_t)CmsisTimerFunc001, osTimerPeriodic, &value, NULL);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
|
||||||
|
|
||||||
|
uwRet = osTimerIsRunning(id);
|
||||||
|
ICUNIT_ASSERT_EQUAL(uwRet, 0, uwRet);
|
||||||
|
(void)osTimerDelete(id);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_2800
|
||||||
|
* @tc.name : timer operation for running after osTimerStart with parameter osTimerPeriodic
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsTimerIsRunning006, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
UINT32 uwRet;
|
||||||
|
osTimerId_t id;
|
||||||
|
UINT32 value = 0xffff;
|
||||||
|
UINT32 millisec = MILLISEC_NUM_INT10;
|
||||||
|
id = osTimerNew((osTimerFunc_t)CmsisTimerFunc001, osTimerPeriodic, &value, NULL);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
|
||||||
|
|
||||||
|
uwRet = osTimerStart(id, millisec);
|
||||||
|
ICUNIT_ASSERT_EQUAL(uwRet, osOK, uwRet);
|
||||||
|
uwRet = osTimerIsRunning(id);
|
||||||
|
ICUNIT_ASSERT_EQUAL(uwRet, 1, uwRet); /* 1, common data for test, no special meaning */
|
||||||
|
(void)osTimerDelete(id);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_2900
|
||||||
|
* @tc.name : timer operation for running after osTimerStart and osTimerStop with parameter osTimerPeriodic
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsTimerIsRunning007, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
UINT32 uwRet;
|
||||||
|
osTimerId_t id;
|
||||||
|
UINT32 value = 0xffff;
|
||||||
|
UINT32 millisec = MILLISEC_NUM_INT10;
|
||||||
|
id = osTimerNew((osTimerFunc_t)CmsisTimerFunc001, osTimerPeriodic, &value, NULL);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
|
||||||
|
|
||||||
|
uwRet = osTimerStart(id, millisec);
|
||||||
|
ICUNIT_ASSERT_EQUAL(uwRet, 0, uwRet);
|
||||||
|
uwRet = osTimerStop(id);
|
||||||
|
ICUNIT_ASSERT_EQUAL(uwRet, 0, uwRet);
|
||||||
|
uwRet = osTimerIsRunning(id);
|
||||||
|
ICUNIT_ASSERT_EQUAL(uwRet, 0, uwRet);
|
||||||
|
(void)osTimerDelete(id);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_3000
|
||||||
|
* @tc.name : timer operation for running after osTimerStart and osTimerDelete with parameter osTimerPeriodic
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsTimerIsRunning008, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
UINT32 uwRet;
|
||||||
|
osTimerId_t id;
|
||||||
|
UINT32 value = 0xffff;
|
||||||
|
UINT32 millisec = MILLISEC_NUM_INT10;
|
||||||
|
id = osTimerNew((osTimerFunc_t)CmsisTimerFunc001, osTimerPeriodic, &value, NULL);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
|
||||||
|
|
||||||
|
uwRet = osTimerStart(id, millisec);
|
||||||
|
ICUNIT_ASSERT_EQUAL(uwRet, 0, uwRet);
|
||||||
|
uwRet = osTimerDelete(id);
|
||||||
|
ICUNIT_ASSERT_EQUAL(uwRet, 0, uwRet);
|
||||||
|
uwRet = osTimerIsRunning(id);
|
||||||
|
ICUNIT_ASSERT_EQUAL(uwRet, 0, uwRet);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_3100
|
||||||
|
* @tc.name : timer running inquiry with timer_id = NULL
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsTimerIsRunning009, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
UINT32 uwRet = osTimerIsRunning(NULL);
|
||||||
|
ICUNIT_ASSERT_EQUAL(uwRet, 0, uwRet);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_3200
|
||||||
|
* @tc.name : os operation for get tick freq
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsKernelGetTickFreq001, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
UINT32 uwRet = osKernelGetTickFreq();
|
||||||
|
ICUNIT_ASSERT_EQUAL(uwRet, LOSCFG_BASE_CORE_TICK_PER_SECOND, uwRet);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_3300
|
||||||
|
* @tc.name : os operation for get sys time freq
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsKernelGetSysTimerFreq001, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
UINT32 uwRet = osKernelGetSysTimerFreq();
|
||||||
|
ICUNIT_ASSERT_EQUAL(uwRet, OS_SYS_CLOCK, uwRet);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_3400
|
||||||
|
* @tc.name : os operation for get sys time count
|
||||||
|
* @tc.desc : [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsKernelGetSysTimerCount001, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
UINT32 uwRet = osKernelGetSysTimerCount();
|
||||||
|
ICUNIT_ASSERT_WITHIN_EQUAL(uwRet, 0, UINT_MAX, uwRet);
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
RUN_TEST_SUITE(CmsisTimerFuncTestSuite);
|
||||||
|
|
||||||
|
void CmsisTimerFuncTest(void)
|
||||||
|
{
|
||||||
|
RUN_ONE_TESTCASE(testOsTimerNew001);
|
||||||
|
RUN_ONE_TESTCASE(testOsTimerNew002);
|
||||||
|
RUN_ONE_TESTCASE(testOsTimerNew003);
|
||||||
|
RUN_ONE_TESTCASE(testOsTimerNew004);
|
||||||
|
RUN_ONE_TESTCASE(testOsTimerNew005);
|
||||||
|
RUN_ONE_TESTCASE(testOsTimerStart001);
|
||||||
|
RUN_ONE_TESTCASE(testOsTimerStart002);
|
||||||
|
RUN_ONE_TESTCASE(testOsTimerStart003);
|
||||||
|
RUN_ONE_TESTCASE(testOsTimerStart004);
|
||||||
|
RUN_ONE_TESTCASE(testOsTimerStart005);
|
||||||
|
RUN_ONE_TESTCASE(testOsTimerStart006);
|
||||||
|
RUN_ONE_TESTCASE(testOsTimerStart007);
|
||||||
|
RUN_ONE_TESTCASE(testOsTimerDelete001);
|
||||||
|
RUN_ONE_TESTCASE(testOsTimerDelete002);
|
||||||
|
RUN_ONE_TESTCASE(testOsTimerDelete003);
|
||||||
|
RUN_ONE_TESTCASE(testOsTimerDelete004);
|
||||||
|
RUN_ONE_TESTCASE(testOsTimerDelete005);
|
||||||
|
RUN_ONE_TESTCASE(testOsTimerStop001);
|
||||||
|
RUN_ONE_TESTCASE(testOsTimerStop002);
|
||||||
|
RUN_ONE_TESTCASE(testOsTimerStop003);
|
||||||
|
RUN_ONE_TESTCASE(testOsTimerStop004);
|
||||||
|
RUN_ONE_TESTCASE(testOsTimerStop005);
|
||||||
|
RUN_ONE_TESTCASE(testOsTimerIsRunning001);
|
||||||
|
RUN_ONE_TESTCASE(testOsTimerIsRunning002);
|
||||||
|
RUN_ONE_TESTCASE(testOsTimerIsRunning003);
|
||||||
|
RUN_ONE_TESTCASE(testOsTimerIsRunning004);
|
||||||
|
RUN_ONE_TESTCASE(testOsTimerIsRunning005);
|
||||||
|
RUN_ONE_TESTCASE(testOsTimerIsRunning006);
|
||||||
|
RUN_ONE_TESTCASE(testOsTimerIsRunning007);
|
||||||
|
RUN_ONE_TESTCASE(testOsTimerIsRunning008);
|
||||||
|
RUN_ONE_TESTCASE(testOsTimerIsRunning009);
|
||||||
|
RUN_ONE_TESTCASE(testOsKernelGetTickFreq001);
|
||||||
|
RUN_ONE_TESTCASE(testOsKernelGetSysTimerFreq001);
|
||||||
|
RUN_ONE_TESTCASE(testOsKernelGetSysTimerCount001);
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2023-2023 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 "xts_test.h"
|
||||||
|
|
||||||
|
void CmsisFuncTest(void)
|
||||||
|
{
|
||||||
|
CmsisEventFuncTest();
|
||||||
|
CmsisMsgFuncTest();
|
||||||
|
CmsisMutexFuncTest();
|
||||||
|
CmsisSemFuncTest();
|
||||||
|
CmsisTaskFuncTest();
|
||||||
|
CmsisTaskPriFuncTest();
|
||||||
|
CmsisTimerFuncTest();
|
||||||
|
}
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2023-2023 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 XTS_CMSID_H
|
||||||
|
#define XTS_CMSID_H
|
||||||
|
|
||||||
|
#include "xts_test.h"
|
||||||
|
#include <securec.h>
|
||||||
|
#include <limits.h>
|
||||||
|
#include "cmsis_os2.h"
|
||||||
|
|
||||||
|
#define LOS_WAIT_FOREVER 0xFFFFFFFF
|
||||||
|
|
||||||
|
#define TESTCOUNT_NUM_1 1
|
||||||
|
#define TESTCOUNT_NUM_2 2
|
||||||
|
#define TESTCOUNT_NUM_3 3
|
||||||
|
#define TESTCOUNT_NUM_4 4
|
||||||
|
#define TESTCOUNT_NUM_5 5
|
||||||
|
|
||||||
|
#define MSGQUEUE_COUNT 16
|
||||||
|
#define MSGQUEUE_SPACE_COUNT 13
|
||||||
|
#define MSGQUEUE_PUT_COUNT 3
|
||||||
|
#define MSG_SIZE 4
|
||||||
|
#define MSGINFO_LEN 4
|
||||||
|
#define TIMEOUT_COUNT 1000
|
||||||
|
#define BUF_LEN 32
|
||||||
|
#define MSGQUEUE_COUNT_INDEX_0 0
|
||||||
|
#define MSGQUEUE_COUNT_INDEX_1 1
|
||||||
|
#define MSGQUEUE_COUNT_INDEX_2 2
|
||||||
|
|
||||||
|
#define SEMAPHHORE_COUNT_HEX_MAX 0xFE
|
||||||
|
#define SEMAPHHORE_COUNT_INT0 0
|
||||||
|
#define SEMAPHHORE_COUNT_INT1 1
|
||||||
|
#define SEMAPHHORE_COUNT_INT10 10
|
||||||
|
|
||||||
|
#define EVENT_MASK_HEX_1 0x01
|
||||||
|
#define EVENT_MASK_HEX_2 0x02
|
||||||
|
#define EVENT_MASK_HEX_4 0x04
|
||||||
|
#define EVENT_MASK_HEX_10 0x10
|
||||||
|
#define EVENT_MASK_HEX_11 0x11
|
||||||
|
#define TIMEOUT_NUM_3 3
|
||||||
|
#define TIMEOUT_NUM_10 10
|
||||||
|
#define INVALID_FLAG_OPTION 0x00000004U
|
||||||
|
|
||||||
|
#define MILLISEC_NUM_INT10 10U
|
||||||
|
#define MILLISEC_NUM_INT4 4U
|
||||||
|
#define INVALID_TIMER_TYPE 10
|
||||||
|
#define TIMER_PERIODIC_COUNT 2
|
||||||
|
|
||||||
|
#define DELAY_TICKS_1 1
|
||||||
|
#define DELAY_TICKS_5 5
|
||||||
|
#define DELAY_TICKS_10 10
|
||||||
|
|
||||||
|
#define PRIORITY_COUNT_NOT_MIN 3
|
||||||
|
#define PRIORITY_COUNT_MIN_1 4
|
||||||
|
#define PRIORITY_COUNT_MIN_2 5
|
||||||
|
#define PRIORITY_COUNT_MIN_3 6
|
||||||
|
#define PRIORITY_COUNT_MIN_4 7
|
||||||
|
#define MAX_UINT32 0xFFFFFFFF
|
||||||
|
#define ALIVE_INFO_DIS 10000
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
# Copyright (c) 2023-2023 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")
|
||||||
|
|
||||||
|
static_library("io_test") {
|
||||||
|
sources = [
|
||||||
|
"xts_io.c",
|
||||||
|
"xts_io_other_test.c",
|
||||||
|
"xts_io_stdio_test.c",
|
||||||
|
"xts_io_stdlib_test.c",
|
||||||
|
"xts_io_string_test.c",
|
||||||
|
"xts_io_strings_test.c",
|
||||||
|
]
|
||||||
|
|
||||||
|
include_dirs = [
|
||||||
|
".",
|
||||||
|
"$LITEOSTOPDIR/testsuites/include",
|
||||||
|
"$LITEOSTOPDIR/testsuites/unittest/xts",
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2023-2023 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 "xts_test.h"
|
||||||
|
|
||||||
|
void IoFuncTest(void)
|
||||||
|
{
|
||||||
|
XtsIoOtherTest();
|
||||||
|
XtsIoStdioFuncTest();
|
||||||
|
XtsIoStdlibFuncTest();
|
||||||
|
XtsIoStringFuncTest();
|
||||||
|
XtsIoStringsFuncTest();
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2023-2023 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 XTS_IO_H
|
||||||
|
#define XTS_IO_H
|
||||||
|
|
||||||
|
#include "xts_test.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <limits.h>
|
||||||
|
#include <pthread.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <securec.h>
|
||||||
|
#include <sys/uio.h>
|
||||||
|
#include <grp.h>
|
||||||
|
#include <shadow.h>
|
||||||
|
#include <pwd.h>
|
||||||
|
#include <inttypes.h>
|
||||||
|
#include <iconv.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <err.h>
|
||||||
|
#include <threads.h>
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2023-2023 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 "xts_io.h"
|
||||||
|
|
||||||
|
LITE_TEST_SUIT(IO, IoOther, IoOtherTestSuite);
|
||||||
|
|
||||||
|
static BOOL IoOtherTestSuiteSetUp(void)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static BOOL IoOtherTestSuiteTearDown(void)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number SUB_KERNEL_IO_OTHER_0900
|
||||||
|
* @tc.name strptime basic function test
|
||||||
|
* @tc.desc [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(IoOtherTestSuite, testStrptime, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
struct tm tm;
|
||||||
|
memset_s(&tm, sizeof(struct tm), 0, sizeof(struct tm));
|
||||||
|
char *ret = strptime("2020-10-29 21:24:00abc", "%Y-%m-%d %H:%M:%S", &tm);
|
||||||
|
ICUNIT_ASSERT_STRING_EQUAL(ret, "abc", ret);
|
||||||
|
ICUNIT_ASSERT_EQUAL(tm.tm_year, 120, tm.tm_year); /* 120 common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(tm.tm_mon, 9, tm.tm_mon); /* 9 common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(tm.tm_mday, 29, tm.tm_mday); /* 29 common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(tm.tm_hour, 21, tm.tm_hour); /* 21 common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(tm.tm_min, 24, tm.tm_min); /* 24 common data for test, no special meaning */
|
||||||
|
|
||||||
|
ret = strptime("14 Oct October 20 09:24:00 Sat Saturday 363", "%d %b %B %y %I:%M:%S %a %A %j", &tm);
|
||||||
|
ICUNIT_ASSERT_STRING_EQUAL(ret, "", ret);
|
||||||
|
ICUNIT_ASSERT_EQUAL(tm.tm_year, 120, tm.tm_year); /* 120 common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(tm.tm_mon, 9, tm.tm_mon); /* 9 common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(tm.tm_mday, 14, tm.tm_mday); /* 14 common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(tm.tm_hour, 9, tm.tm_hour); /* 9 common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(tm.tm_wday, 6, tm.tm_wday); /* 6 common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(tm.tm_yday, 362, tm.tm_yday); /* 362 common data for test, no special meaning */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
RUN_TEST_SUITE(IoOtherTestSuite);
|
||||||
|
|
||||||
|
void XtsIoOtherTest(void)
|
||||||
|
{
|
||||||
|
RUN_ONE_TESTCASE(testStrptime);
|
||||||
|
}
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2023-2023 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 "xts_io.h"
|
||||||
|
|
||||||
|
LITE_TEST_SUIT(IO, IoStdio, IoStdioTestSuite);
|
||||||
|
|
||||||
|
static BOOL IoStdioTestSuiteSetUp(void)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static BOOL IoStdioTestSuiteTearDown(void)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
int FormatVsnptf(char *format, ...)
|
||||||
|
{
|
||||||
|
va_list vArgList;
|
||||||
|
va_start(vArgList, format);
|
||||||
|
char str[50] = {0}; /* 50 common data for test, no special meaning */
|
||||||
|
int ret = vsnprintf_s(str, sizeof(str), sizeof(str), format, vArgList);
|
||||||
|
va_end(vArgList);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number SUB_KERNEL_IO_STDIO_2100
|
||||||
|
* @tc.name vsnprintf basic function test
|
||||||
|
* @tc.desc [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(IoStdioTestSuite, testVsnprintf, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
int ret = FormatVsnptf((char *)"%s has %d words", "hello world", 11); /* 11 common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 24, ret); /* 24 common data for test, no special meaning */
|
||||||
|
|
||||||
|
ret = FormatVsnptf((char *)"%f and %c as well as %ld\n", 2.2, 'c', 6); /* 2.2, 6 common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 28, ret); /* 28 common data for test, no special meaning */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
RUN_TEST_SUITE(IoStdioTestSuite);
|
||||||
|
|
||||||
|
void XtsIoStdioFuncTest(void)
|
||||||
|
{
|
||||||
|
RUN_ONE_TESTCASE(testVsnprintf);
|
||||||
|
}
|
||||||
@@ -0,0 +1,282 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2023-2023 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 "xts_io.h"
|
||||||
|
|
||||||
|
LITE_TEST_SUIT(IO, IoStdlibApi, IoStdlibApiTestSuite);
|
||||||
|
|
||||||
|
static BOOL IoStdlibApiTestSuiteSetUp(void)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static BOOL IoStdlibApiTestSuiteTearDown(void)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number SUB_KERNEL_IO_STDLIB_0400
|
||||||
|
* @tc.name strtof basic function test
|
||||||
|
* @tc.desc [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(IoStdlibApiTestSuite, testStrtof, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
char *endPtr = NULL;
|
||||||
|
float ret = strtof(" -3.40E+38 hello", &endPtr);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, (float)(-3.40E+38), ret);
|
||||||
|
ICUNIT_ASSERT_STRING_EQUAL(endPtr, " hello", endPtr);
|
||||||
|
|
||||||
|
ret = strtof(" 3.40E+38 ===", &endPtr);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, (float)(3.40E+38), ret);
|
||||||
|
ICUNIT_ASSERT_STRING_EQUAL(endPtr, " ===", endPtr);
|
||||||
|
|
||||||
|
ret = strtof("-9.6e17 this 123", &endPtr);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, (float)(-9.6e17), ret);
|
||||||
|
ICUNIT_ASSERT_STRING_EQUAL(endPtr, " this 123", endPtr);
|
||||||
|
|
||||||
|
ret = strtof("this is string", &endPtr);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ICUNIT_ASSERT_STRING_EQUAL(endPtr, "this is string", endPtr);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number SUB_KERNEL_IO_STDLIB_0500
|
||||||
|
* @tc.name strtod basic function test
|
||||||
|
* @tc.desc [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(IoStdlibApiTestSuite, testStrtod, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
char *endPtr = NULL;
|
||||||
|
double ret = strtod(" -1.79E+308 hello", &endPtr);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, -1.79E+308, ret);
|
||||||
|
ICUNIT_ASSERT_STRING_EQUAL(endPtr, " hello", endPtr);
|
||||||
|
|
||||||
|
ret = strtod("1.79E+308 ===", &endPtr);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 1.79E+308, ret);
|
||||||
|
ICUNIT_ASSERT_STRING_EQUAL(endPtr, " ===", endPtr);
|
||||||
|
|
||||||
|
ret = strtod("-9.6e17 this 123", &endPtr);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, -9.6e17, ret);
|
||||||
|
ICUNIT_ASSERT_STRING_EQUAL(endPtr, " this 123", endPtr);
|
||||||
|
|
||||||
|
ret = strtod("this is string", &endPtr);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ICUNIT_ASSERT_STRING_EQUAL(endPtr, "this is string", endPtr);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number SUB_KERNEL_IO_STDLIB_0600
|
||||||
|
* @tc.name strtold basic function test
|
||||||
|
* @tc.desc [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(IoStdlibApiTestSuite, testStrtold, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
char *endPtr = NULL;
|
||||||
|
long double ret = strtold(" 2.22507e-308 hello", &endPtr);
|
||||||
|
ICUNIT_ASSERT_STRING_EQUAL(endPtr, " hello", endPtr);
|
||||||
|
|
||||||
|
ret = strtold(" 1.79769e+308 ===", &endPtr);
|
||||||
|
ICUNIT_ASSERT_STRING_EQUAL(endPtr, " ===", endPtr);
|
||||||
|
|
||||||
|
ret = strtold("-9.6e17 this 123", &endPtr);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, -9.6e17, ret);
|
||||||
|
ICUNIT_ASSERT_STRING_EQUAL(endPtr, " this 123", endPtr);
|
||||||
|
|
||||||
|
ret = strtold("this is string", &endPtr);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ICUNIT_ASSERT_STRING_EQUAL(endPtr, "this is string", endPtr);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number SUB_KERNEL_IO_STDLIB_0700
|
||||||
|
* @tc.name strtol basic function test
|
||||||
|
* @tc.desc [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(IoStdlibApiTestSuite, testStrtol, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
char nPtr[] = "12 0110 0XDEFE 0666 -1.6";
|
||||||
|
char *endPtr = NULL;
|
||||||
|
long ret = strtol(nPtr, &endPtr, 10); /* 10 common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 12, ret); /* 12 common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_STRING_EQUAL(endPtr, " 0110 0XDEFE 0666 -1.6", endPtr);
|
||||||
|
|
||||||
|
ret = strtol(endPtr, &endPtr, 2); /* 2 common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 6, ret); /* 6 common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_STRING_EQUAL(endPtr, " 0XDEFE 0666 -1.6", endPtr);
|
||||||
|
|
||||||
|
ret = strtol(endPtr, &endPtr, 16); /* 16 common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0XDEFE, ret);
|
||||||
|
ICUNIT_ASSERT_STRING_EQUAL(endPtr, " 0666 -1.6", endPtr);
|
||||||
|
|
||||||
|
ret = strtol(endPtr, &endPtr, 8); /* 8 common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0666, ret);
|
||||||
|
ICUNIT_ASSERT_STRING_EQUAL(endPtr, " -1.6", endPtr);
|
||||||
|
|
||||||
|
ret = strtol(endPtr, &endPtr, 65); /* 65 common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ICUNIT_ASSERT_STRING_EQUAL(endPtr, " -1.6", endPtr);
|
||||||
|
|
||||||
|
ret = strtol(endPtr, &endPtr, 0);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1 common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_STRING_EQUAL(endPtr, ".6", endPtr);
|
||||||
|
|
||||||
|
ret = strtol(endPtr, &endPtr, 10); /* 10 common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ICUNIT_ASSERT_STRING_EQUAL(endPtr, ".6", endPtr);
|
||||||
|
|
||||||
|
char nPtr1[] = "2147483647 2147483648 -2147483648 -2147483649";
|
||||||
|
ret = strtol(nPtr1, &endPtr, 10); /* 10 common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 2147483647, ret); /* 2147483647 common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_STRING_EQUAL(endPtr, " 2147483648 -2147483648 -2147483649", endPtr);
|
||||||
|
|
||||||
|
ret = strtol(endPtr, &endPtr, 10); /* 10 common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 2147483647, ret); /* 2147483647 common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_STRING_EQUAL(endPtr, " -2147483648 -2147483649", endPtr);
|
||||||
|
|
||||||
|
ret = strtol(endPtr, &endPtr, 10); /* 10 common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, -2147483648, ret); /* -2147483648 common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_STRING_EQUAL(endPtr, " -2147483649", endPtr);
|
||||||
|
|
||||||
|
ret = strtol(endPtr, &endPtr, 10); /* 10 common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, -2147483648, ret); /* -2147483648 common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_STRING_EQUAL(endPtr, "", endPtr);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number SUB_KERNEL_IO_STDLIB_0800
|
||||||
|
* @tc.name strtoul basic function test
|
||||||
|
* @tc.desc [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(IoStdlibApiTestSuite, testStrtoul, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
char nPtr[] = "12 0110 0XDEFE 0666 4294967295 4294967296 12.34";
|
||||||
|
char *endPtr = NULL;
|
||||||
|
unsigned long ret = strtoul(nPtr, &endPtr, 10); /* 10 common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 12UL, ret);
|
||||||
|
ICUNIT_ASSERT_STRING_EQUAL(endPtr, " 0110 0XDEFE 0666 4294967295 4294967296 12.34", endPtr);
|
||||||
|
|
||||||
|
ret = strtoul(endPtr, &endPtr, 2); /* 2 common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 6UL, ret);
|
||||||
|
ICUNIT_ASSERT_STRING_EQUAL(endPtr, " 0XDEFE 0666 4294967295 4294967296 12.34", endPtr);
|
||||||
|
|
||||||
|
ret = strtoul(endPtr, &endPtr, 16); /* 16 common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0XDEFEUL, ret);
|
||||||
|
ICUNIT_ASSERT_STRING_EQUAL(endPtr, " 0666 4294967295 4294967296 12.34", endPtr);
|
||||||
|
|
||||||
|
ret = strtoul(endPtr, &endPtr, 8); /* 8 common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0666UL, ret);
|
||||||
|
ICUNIT_ASSERT_STRING_EQUAL(endPtr, " 4294967295 4294967296 12.34", endPtr);
|
||||||
|
|
||||||
|
ret = strtoul(endPtr, &endPtr, 0);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 4294967295UL, ret);
|
||||||
|
ICUNIT_ASSERT_STRING_EQUAL(endPtr, " 4294967296 12.34", endPtr);
|
||||||
|
|
||||||
|
ret = strtoul(endPtr, &endPtr, 0);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 4294967295UL, ret);
|
||||||
|
ICUNIT_ASSERT_STRING_EQUAL(endPtr, " 12.34", endPtr);
|
||||||
|
|
||||||
|
ret = strtoul(endPtr, &endPtr, 65); /* 65 common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0UL, ret);
|
||||||
|
ICUNIT_ASSERT_STRING_EQUAL(endPtr, " 12.34", endPtr);
|
||||||
|
|
||||||
|
ret = strtoul(endPtr, &endPtr, 0);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 12UL, ret);
|
||||||
|
ICUNIT_ASSERT_STRING_EQUAL(endPtr, ".34", endPtr);
|
||||||
|
|
||||||
|
ret = strtoul(endPtr, &endPtr, 0);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0UL, ret);
|
||||||
|
ICUNIT_ASSERT_STRING_EQUAL(endPtr, ".34", endPtr);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number SUB_KERNEL_IO_STDLIB_1000
|
||||||
|
* @tc.name strtoull basic function test
|
||||||
|
* @tc.desc [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(IoStdlibApiTestSuite, testStrtoull, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
char nPtr[] = "12 0110 0XDEFE 0666 1.6";
|
||||||
|
char *endPtr = NULL;
|
||||||
|
unsigned long long ret = strtoull(nPtr, &endPtr, 10); /* 10 common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 12ULL, ret);
|
||||||
|
ICUNIT_ASSERT_STRING_EQUAL(endPtr, " 0110 0XDEFE 0666 1.6", endPtr);
|
||||||
|
|
||||||
|
ret = strtoull(endPtr, &endPtr, 2); /* 2 common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 6ULL, ret);
|
||||||
|
ICUNIT_ASSERT_STRING_EQUAL(endPtr, " 0XDEFE 0666 1.6", endPtr);
|
||||||
|
|
||||||
|
ret = strtoull(endPtr, &endPtr, 16); /* 16 common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0XDEFEULL, ret);
|
||||||
|
ICUNIT_ASSERT_STRING_EQUAL(endPtr, " 0666 1.6", endPtr);
|
||||||
|
|
||||||
|
ret = strtoull(endPtr, &endPtr, 8); /* 8 common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0666ULL, ret);
|
||||||
|
ICUNIT_ASSERT_STRING_EQUAL(endPtr, " 1.6", endPtr);
|
||||||
|
|
||||||
|
ret = strtoull(endPtr, &endPtr, 65); /* 65 common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0ULL, ret);
|
||||||
|
ICUNIT_ASSERT_STRING_EQUAL(endPtr, " 1.6", endPtr);
|
||||||
|
|
||||||
|
ret = strtoull(endPtr, &endPtr, 0);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 1ULL, ret);
|
||||||
|
ICUNIT_ASSERT_STRING_EQUAL(endPtr, ".6", endPtr);
|
||||||
|
|
||||||
|
ret = strtoull(endPtr, &endPtr, 0);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0ULL, ret);
|
||||||
|
ICUNIT_ASSERT_STRING_EQUAL(endPtr, ".6", endPtr);
|
||||||
|
|
||||||
|
char nPtr1[] = "18446744073709551615 18446744073709551616";
|
||||||
|
ret = strtoull(nPtr1, &endPtr, 10); /* 10 common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 18446744073709551615ULL, ret);
|
||||||
|
ICUNIT_ASSERT_STRING_EQUAL(endPtr, " 18446744073709551616", endPtr);
|
||||||
|
|
||||||
|
ret = strtoull(endPtr, &endPtr, 10); /* 10 common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 18446744073709551615ULL, ret);
|
||||||
|
ICUNIT_ASSERT_STRING_EQUAL(endPtr, "", endPtr);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
RUN_TEST_SUITE(IoStdlibApiTestSuite);
|
||||||
|
|
||||||
|
void XtsIoStdlibFuncTest(void)
|
||||||
|
{
|
||||||
|
RUN_ONE_TESTCASE(testStrtof);
|
||||||
|
RUN_ONE_TESTCASE(testStrtod);
|
||||||
|
RUN_ONE_TESTCASE(testStrtold);
|
||||||
|
RUN_ONE_TESTCASE(testStrtol);
|
||||||
|
RUN_ONE_TESTCASE(testStrtoul);
|
||||||
|
RUN_ONE_TESTCASE(testStrtoull);
|
||||||
|
}
|
||||||
@@ -0,0 +1,374 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2023-2023 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 "xts_io.h"
|
||||||
|
|
||||||
|
LITE_TEST_SUIT(IO, IoStringApi, IoStringApiTestSuite);
|
||||||
|
|
||||||
|
static BOOL IoStringApiTestSuiteSetUp(void)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static BOOL IoStringApiTestSuiteTearDown(void)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number SUB_KERNEL_IO_STRING_0300
|
||||||
|
* @tc.name strcmp basic function test
|
||||||
|
* @tc.desc [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(IoStringApiTestSuite, testStrcmp, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
int ret = strcmp("abcdef", "ABCDEF");
|
||||||
|
ICUNIT_ASSERT_WITHIN_EQUAL(ret, 0, INT_MAX, ret);
|
||||||
|
|
||||||
|
ret = strcmp("123456", "654321");
|
||||||
|
ICUNIT_ASSERT_WITHIN_EQUAL(ret, INT_MIN, 0, ret);
|
||||||
|
|
||||||
|
ret = strcmp("~!@#$%^&*()_+", "~!@#$%^&*()_+");
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number SUB_KERNEL_IO_STRING_0400
|
||||||
|
* @tc.name strncmp basic function test
|
||||||
|
* @tc.desc [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(IoStringApiTestSuite, testStrncmp, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
const char dest[] = "abcdef";
|
||||||
|
const char src[] = "ABCDEF";
|
||||||
|
int ret = strncmp(dest, src, 1); /* 1 common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_WITHIN_EQUAL(ret, 0, INT_MAX, ret);
|
||||||
|
|
||||||
|
ret = strncmp("123456", "654321", 6); /* 6 common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_WITHIN_EQUAL(ret, INT_MIN, 0, ret);
|
||||||
|
|
||||||
|
ret = strncmp("~!@#$%^&*()_+", "~!@#$%^&*()_+", 8); /* 8 common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number SUB_KERNEL_IO_STRING_0700
|
||||||
|
* @tc.name stpcpy basic function test
|
||||||
|
* @tc.desc [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(IoStringApiTestSuite, testStpcpy, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
const char *src = "hello world !";
|
||||||
|
char dest[50] = {0}; /* 50 common data for test, no special meaning */
|
||||||
|
char *ret = stpcpy(dest, src);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(ret, NULL, ret);
|
||||||
|
ICUNIT_ASSERT_STRING_EQUAL(dest, src, dest);
|
||||||
|
|
||||||
|
const char *srcT = "~!@#$%%^&*()_+";
|
||||||
|
char destT[50] = {0}; /* 50 common data for test, no special meaning */
|
||||||
|
ret = stpcpy(destT, srcT);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(ret, NULL, ret);
|
||||||
|
ICUNIT_ASSERT_STRING_EQUAL(destT, srcT, destT);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number SUB_KERNEL_IO_STRING_0800
|
||||||
|
* @tc.name stpncpy basic function test
|
||||||
|
* @tc.desc [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(IoStringApiTestSuite, testStpncpy, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
char src[] = "hello world !";
|
||||||
|
char dest[50] = {0}; /* 50 common data for test, no special meaning */
|
||||||
|
char *ret = stpncpy(dest, src, 5); /* 5 common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_STRING_EQUAL(ret, "", ret);
|
||||||
|
ICUNIT_ASSERT_STRING_EQUAL(dest, "hello", dest);
|
||||||
|
|
||||||
|
char srcT[] = "~!@#$%%^&*()_+";
|
||||||
|
char destT[50] = {0}; /* 50 common data for test, no special meaning */
|
||||||
|
ret = stpncpy(destT, srcT, 15); /* 15 common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_STRING_EQUAL(ret, "", ret);
|
||||||
|
ICUNIT_ASSERT_STRING_EQUAL(destT, "~!@#$%%^&*()_+", destT);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number SUB_KERNEL_IO_STRING_1000
|
||||||
|
* @tc.name strcpy basic function test
|
||||||
|
* @tc.desc [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(IoStringApiTestSuite, testStrcpy, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
char src[] = "hello world !";
|
||||||
|
char dest[20] = {0}; /* 20 common data for test, no special meaning */
|
||||||
|
int ret = strcpy_s(dest, sizeof(dest), src);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
|
||||||
|
char srcT[] = "This is String1";
|
||||||
|
char destT[20] = {0}; /* 20 common data for test, no special meaning */
|
||||||
|
ret = strcpy_s(destT, sizeof(destT), srcT);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number SUB_KERNEL_IO_STRING_1100
|
||||||
|
* @tc.name strncpy basic function test
|
||||||
|
* @tc.desc [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(IoStringApiTestSuite, testStrncpy, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
char src[] = "hello world !";
|
||||||
|
char dest[20] = {0};
|
||||||
|
int ret = strncpy_s(dest, sizeof(dest), src, 6); /* 6 common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
|
||||||
|
char destT[] = "~!@#$%^&*()_+";
|
||||||
|
ret = strncpy_s(destT, sizeof(destT), "hello world", 0);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number SUB_KERNEL_IO_STRING_1400
|
||||||
|
* @tc.name strcat basic function test
|
||||||
|
* @tc.desc [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(IoStringApiTestSuite, testStrcat, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
char dest[50] = {0}; /* 50 common data for test, no special meaning */
|
||||||
|
int ret = strcat_s(dest, sizeof(dest), "hello world !");
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
|
||||||
|
char destT[50] = "hello world ! || "; /* 50 common data for test, no special meaning */
|
||||||
|
ret = strcat_s(destT, sizeof(destT), "This is String1");
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number SUB_KERNEL_IO_STRING_1500
|
||||||
|
* @tc.name strncat basic function test
|
||||||
|
* @tc.desc [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(IoStringApiTestSuite, testStrncat, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
char dest[50] = "hello world || "; /* 50 common data for test, no special meaning */
|
||||||
|
int ret = strncat_s(dest, sizeof(dest), "This is String1", 7); /* 7 common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
|
||||||
|
char destT[20] = "|/*"; /* 20 common data for test, no special meaning */
|
||||||
|
ret = strncat_s(destT, sizeof(destT), "~!@#$%^&*()_+", 13); /* 13 common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number SUB_KERNEL_IO_STRING_1600
|
||||||
|
* @tc.name strchr basic function test
|
||||||
|
* @tc.desc [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(IoStringApiTestSuite, testStrchr, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
char src[] = "hello !! world";
|
||||||
|
char *ret = strchr(src, '!');
|
||||||
|
ICUNIT_ASSERT_STRING_EQUAL(ret, "!! world", ret);
|
||||||
|
|
||||||
|
ret = strchr(src, '?');
|
||||||
|
ICUNIT_ASSERT_STRING_EQUAL(ret, NULL, ret);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number SUB_KERNEL_IO_STRING_1700
|
||||||
|
* @tc.name strrchr basic function test
|
||||||
|
* @tc.desc [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(IoStringApiTestSuite, testStrrchr, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
char src[] = "hello world & HEELO & WORLD";
|
||||||
|
char *ret = strrchr(src, '&');
|
||||||
|
ICUNIT_ASSERT_STRING_EQUAL(ret, "& WORLD", ret);
|
||||||
|
|
||||||
|
ret = strrchr(src, '?');
|
||||||
|
ICUNIT_ASSERT_STRING_EQUAL(ret, NULL, ret);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number SUB_KERNEL_IO_STRING_1800
|
||||||
|
* @tc.name strnlen basic function test
|
||||||
|
* @tc.desc [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(IoStringApiTestSuite, testStrnlen, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
char src[] = "hello world !";
|
||||||
|
unsigned int ltSrcSize = strlen(src) - 2; /* 2 common data for test, no special meaning */
|
||||||
|
unsigned int gtSrcSize = strlen(src) + 2; /* 2 common data for test, no special meaning */
|
||||||
|
|
||||||
|
size_t ret = strnlen(src, ltSrcSize);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, ltSrcSize, ret);
|
||||||
|
|
||||||
|
ret = strnlen(src, gtSrcSize);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, strlen(src), ret);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number SUB_KERNEL_IO_STRING_1900
|
||||||
|
* @tc.name strtok basic function test
|
||||||
|
* @tc.desc [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(IoStringApiTestSuite, testStrtok, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
char src[] = "hello world & This is-String1";
|
||||||
|
char *ret = strtok(src, "&");
|
||||||
|
ICUNIT_ASSERT_STRING_EQUAL(ret, src, ret);
|
||||||
|
|
||||||
|
ret = strtok(NULL, "-");
|
||||||
|
ICUNIT_ASSERT_STRING_EQUAL(ret, " This is", ret);
|
||||||
|
|
||||||
|
char srcS[] = "hello world !";
|
||||||
|
ret = strtok(srcS, "?");
|
||||||
|
ICUNIT_ASSERT_STRING_EQUAL(ret, srcS, ret);
|
||||||
|
|
||||||
|
char srcT[50] = {0}; /* 50 common data for test, no special meaning */
|
||||||
|
ret = strtok(srcT, "~");
|
||||||
|
ICUNIT_ASSERT_STRING_EQUAL(ret, NULL, ret);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number SUB_KERNEL_IO_STRING_2200
|
||||||
|
* @tc.name strdup basic function test
|
||||||
|
* @tc.desc [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(IoStringApiTestSuite, testStrdup, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
char src[] = "hello world !";
|
||||||
|
char *ret = strdup(src);
|
||||||
|
ICUNIT_ASSERT_STRING_EQUAL(ret, src, ret);
|
||||||
|
|
||||||
|
char srcS[] = "This is String1";
|
||||||
|
ret = strdup(srcS);
|
||||||
|
ICUNIT_ASSERT_STRING_EQUAL(ret, "This is String1", ret);
|
||||||
|
free(ret);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number SUB_KERNEL_IO_STRING_2500
|
||||||
|
* @tc.name strcspn basic function test
|
||||||
|
* @tc.desc [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(IoStringApiTestSuite, testStrcspn, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
const char dest[] = "hello world !";
|
||||||
|
const char src[] = "!";
|
||||||
|
size_t ret = strcspn(dest, src);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 12U, ret);
|
||||||
|
|
||||||
|
const char srcS[] = "a";
|
||||||
|
ret = strcspn(dest, srcS);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 13U, ret);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number SUB_KERNEL_IO_STRING_2600
|
||||||
|
* @tc.name strspn basic function test
|
||||||
|
* @tc.desc [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(IoStringApiTestSuite, testStrspn, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
const char dest[] = "hello world !";
|
||||||
|
const char src[] = "heAlo";
|
||||||
|
size_t ret = strspn(dest, src);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 5U, ret);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 5U, ret);
|
||||||
|
|
||||||
|
const char destS[] = "this is string";
|
||||||
|
const char srcS[] = "abc";
|
||||||
|
ret = strspn(destS, srcS);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0U, ret);
|
||||||
|
|
||||||
|
const char srcT[] = "helo\0 wal";
|
||||||
|
ret = strspn(dest, srcT);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 5U, ret);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number SUB_KERNEL_IO_STRING_2700
|
||||||
|
* @tc.name strstr basic function test
|
||||||
|
* @tc.desc [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(IoStringApiTestSuite, testStrstr, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
const char dest[] = "hello world !";
|
||||||
|
const char src[] = "heAlo";
|
||||||
|
const char *ret = strstr(dest, src);
|
||||||
|
ICUNIT_ASSERT_STRING_EQUAL(ret, NULL, ret);
|
||||||
|
|
||||||
|
const char destS[] = "string this is string";
|
||||||
|
const char srcS[] = "string";
|
||||||
|
ret = strstr(destS, srcS);
|
||||||
|
ICUNIT_ASSERT_STRING_EQUAL(ret, "string this is string", ret);
|
||||||
|
|
||||||
|
const char srcT[] = "\0hello";
|
||||||
|
ret = strstr(dest, srcT);
|
||||||
|
ICUNIT_ASSERT_STRING_EQUAL(ret, "hello world !", ret);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
RUN_TEST_SUITE(IoStringApiTestSuite);
|
||||||
|
|
||||||
|
void XtsIoStringFuncTest(void)
|
||||||
|
{
|
||||||
|
RUN_ONE_TESTCASE(testStrcmp);
|
||||||
|
RUN_ONE_TESTCASE(testStrncmp);
|
||||||
|
RUN_ONE_TESTCASE(testStpcpy);
|
||||||
|
RUN_ONE_TESTCASE(testStpncpy);
|
||||||
|
RUN_ONE_TESTCASE(testStrcpy);
|
||||||
|
RUN_ONE_TESTCASE(testStrncpy);
|
||||||
|
RUN_ONE_TESTCASE(testStrcat);
|
||||||
|
RUN_ONE_TESTCASE(testStrncat);
|
||||||
|
RUN_ONE_TESTCASE(testStrchr);
|
||||||
|
RUN_ONE_TESTCASE(testStrrchr);
|
||||||
|
RUN_ONE_TESTCASE(testStrnlen);
|
||||||
|
RUN_ONE_TESTCASE(testStrtok);
|
||||||
|
RUN_ONE_TESTCASE(testStrdup);
|
||||||
|
RUN_ONE_TESTCASE(testStrcspn);
|
||||||
|
RUN_ONE_TESTCASE(testStrspn);
|
||||||
|
RUN_ONE_TESTCASE(testStrstr);
|
||||||
|
}
|
||||||
@@ -0,0 +1,87 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2023-2023 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 "xts_io.h"
|
||||||
|
|
||||||
|
LITE_TEST_SUIT(IO, IoStringsApi, IoStringsApiTestSuite);
|
||||||
|
|
||||||
|
static BOOL IoStringsApiTestSuiteSetUp(void)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static BOOL IoStringsApiTestSuiteTearDown(void)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number SUB_KERNEL_IO_STRINGS_0200
|
||||||
|
* @tc.name strncasecmp basic function test
|
||||||
|
* @tc.desc [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(IoStringsApiTestSuite, testStrncasecmp, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
int ret = strncasecmp("abcdefg", "abcdEFg", 7); /* 7 common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
|
||||||
|
ret = strncasecmp("abcdefg", "abcdEF", 7); /* 7 common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_WITHIN_EQUAL(ret, 0, INT_MAX, ret);
|
||||||
|
|
||||||
|
ret = strncasecmp("abcdef", "abcdEFg", 7); /* 7 common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_WITHIN_EQUAL(ret, INT_MIN, 0, ret);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number SUB_KERNEL_IO_STRINGS_0300
|
||||||
|
* @tc.name strcasecmp basic function test
|
||||||
|
* @tc.desc [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(IoStringsApiTestSuite, testStrcasecmp, Function | MediumTest | Level2)
|
||||||
|
{
|
||||||
|
int ret = strcasecmp("abcdefg", "abcdEFg");
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
|
||||||
|
ret = strcasecmp("abcdefg", "abcdEF");
|
||||||
|
ICUNIT_ASSERT_WITHIN_EQUAL(ret, 0, INT_MAX, ret);
|
||||||
|
|
||||||
|
ret = strcasecmp("abcdef", "abcdEFg");
|
||||||
|
ICUNIT_ASSERT_WITHIN_EQUAL(ret, INT_MIN, 0, ret);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
RUN_TEST_SUITE(IoStringsApiTestSuite);
|
||||||
|
|
||||||
|
void XtsIoStringsFuncTest(void)
|
||||||
|
{
|
||||||
|
RUN_ONE_TESTCASE(testStrncasecmp);
|
||||||
|
RUN_ONE_TESTCASE(testStrcasecmp);
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
# Copyright (c) 2023-2023 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")
|
||||||
|
|
||||||
|
static_library("ipc_test") {
|
||||||
|
sources = [
|
||||||
|
"cond/pthread_cond_test.c",
|
||||||
|
"msg_queue/mq_exp_test.c",
|
||||||
|
"msg_queue/mq_test.c",
|
||||||
|
"mutex/pthread_mutex_test.c",
|
||||||
|
"semaphone/sem_abn_test.c",
|
||||||
|
"semaphone/sem_test.c",
|
||||||
|
"semaphone/sem_xts_test.c",
|
||||||
|
"xts_ipc.c",
|
||||||
|
]
|
||||||
|
|
||||||
|
include_dirs = [
|
||||||
|
".",
|
||||||
|
"$LITEOSTOPDIR/testsuites/include",
|
||||||
|
"$LITEOSTOPDIR/testsuites/unittest/xts",
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,196 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2023-2023 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 "xts_ipc.h"
|
||||||
|
|
||||||
|
pthread_mutex_t g_mtx3 = PTHREAD_MUTEX_INITIALIZER;
|
||||||
|
pthread_cond_t g_cond3 = PTHREAD_COND_INITIALIZER;
|
||||||
|
|
||||||
|
LITE_TEST_SUIT(FUTEX, PthreadCondApiTest, PthreadCondApiTestSuite);
|
||||||
|
|
||||||
|
static BOOL PthreadCondApiTestSuiteSetUp(void)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static BOOL PthreadCondApiTestSuiteTearDown(void)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number SUB_KERNEL_PTHREAD_COND_INIT_0100
|
||||||
|
* @tc.name pthread_cond_init initializes condition variables
|
||||||
|
* @tc.desc [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(PthreadCondApiTestSuite, testPthreadCondInit, Function | MediumTest | Level2)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
pthread_condattr_t condAttr;
|
||||||
|
|
||||||
|
ret = pthread_condattr_init(&condAttr);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, POSIX_IPC_NO_ERROR, ret);
|
||||||
|
|
||||||
|
pthread_cond_t cond1;
|
||||||
|
ret = pthread_cond_init(&cond1, &condAttr);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, POSIX_IPC_NO_ERROR, ret);
|
||||||
|
|
||||||
|
pthread_cond_t cond2;
|
||||||
|
ret = pthread_cond_init(&cond2, NULL);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, POSIX_IPC_NO_ERROR, ret);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number SUB_KERNEL_PTHREAD_COND_DESTROY_0100
|
||||||
|
* @tc.name pthread_cond_destroy destroy condition variables
|
||||||
|
* @tc.desc [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(PthreadCondApiTestSuite, testPthreadCondDestroy, Function | MediumTest | Level3)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
pthread_condattr_t condAttr;
|
||||||
|
ret = pthread_condattr_init(&condAttr);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, POSIX_IPC_NO_ERROR, ret);
|
||||||
|
|
||||||
|
pthread_cond_t cond1;
|
||||||
|
ret = pthread_cond_init(&cond1, &condAttr);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, POSIX_IPC_NO_ERROR, ret);
|
||||||
|
ret = pthread_cond_destroy(&cond1);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, POSIX_IPC_NO_ERROR, ret);
|
||||||
|
|
||||||
|
pthread_cond_t cond2;
|
||||||
|
ret = pthread_cond_init(&cond2, NULL);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, POSIX_IPC_NO_ERROR, ret);
|
||||||
|
ret = pthread_cond_destroy(&cond2);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, POSIX_IPC_NO_ERROR, ret);
|
||||||
|
|
||||||
|
pthread_cond_t cond3 = PTHREAD_COND_INITIALIZER;
|
||||||
|
ret = pthread_cond_destroy(&cond3);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, POSIX_IPC_NO_ERROR, ret);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number SUB_KERNEL_PTHREAD_CONDATTR_INIT_0100
|
||||||
|
* @tc.name Init and destroy operations
|
||||||
|
* @tc.desc [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(PthreadCondApiTestSuite, testPthreadCondattrInit, Function | MediumTest | Level2)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
pthread_condattr_t condAttr;
|
||||||
|
|
||||||
|
ret = pthread_condattr_init(&condAttr);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, POSIX_IPC_NO_ERROR, ret);
|
||||||
|
ret = pthread_condattr_destroy(&condAttr);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, POSIX_IPC_NO_ERROR, ret);
|
||||||
|
ret = pthread_condattr_init(&condAttr);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, POSIX_IPC_NO_ERROR, ret);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// pthread_cond_broadcast
|
||||||
|
void *ThreadPthreadCondBroadcast1(void *arg)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
int *testIntP = (int *)arg;
|
||||||
|
usleep(20); /* 20, common data for test, no special meaning */
|
||||||
|
ret = pthread_mutex_lock(&g_mtx3);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, POSIX_IPC_NO_ERROR, ret, EXIT);
|
||||||
|
*testIntP = TEST_INTP_SIZE;
|
||||||
|
ret = pthread_cond_broadcast(&g_cond3);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, POSIX_IPC_NO_ERROR, ret, EXIT);
|
||||||
|
ret = pthread_mutex_unlock(&g_mtx3);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, POSIX_IPC_NO_ERROR, ret, EXIT);
|
||||||
|
return arg;
|
||||||
|
EXIT:
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// pthread_cond_wait
|
||||||
|
void *ThreadPthreadCondBroadcast2(void *arg)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
int *testIntP = (int *)arg;
|
||||||
|
ret = pthread_mutex_lock(&g_mtx3);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, POSIX_IPC_NO_ERROR, ret, EXIT);
|
||||||
|
ret = pthread_cond_wait(&g_cond3, &g_mtx3);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, POSIX_IPC_NO_ERROR, ret, EXIT);
|
||||||
|
(*testIntP)++;
|
||||||
|
ret = pthread_mutex_unlock(&g_mtx3);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, POSIX_IPC_NO_ERROR, ret, EXIT);
|
||||||
|
return arg;
|
||||||
|
EXIT:
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number SUB_KERNEL_PTHREAD_COND_BROADCAST_0100
|
||||||
|
* @tc.name Use pthread_cond_broadcast to release conditional semaphore
|
||||||
|
* @tc.desc [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(PthreadCondApiTestSuite, testPthreadCondBroadcast, Function | MediumTest | Level3)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
pthread_t tid[3]; /* 3, common data for test, no special meaning */
|
||||||
|
int testInt = 0;
|
||||||
|
|
||||||
|
ret = pthread_create(&tid[0], NULL, ThreadPthreadCondBroadcast1, (void*)&testInt);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, POSIX_IPC_NO_ERROR, ret);
|
||||||
|
ret = pthread_create(&tid[1], NULL, ThreadPthreadCondBroadcast2, (void*)&testInt); /* 1, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, POSIX_IPC_NO_ERROR, ret);
|
||||||
|
ret = pthread_create(&tid[2], NULL, ThreadPthreadCondBroadcast2, (void*)&testInt); /* 2, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, POSIX_IPC_NO_ERROR, ret);
|
||||||
|
|
||||||
|
usleep(100); /* 100, common data for test, no special meaning */
|
||||||
|
int index = (int)(sizeof(tid) / sizeof(tid[0]));
|
||||||
|
for (int i = 0; i < index; i++) {
|
||||||
|
ret = pthread_join(tid[i], NULL);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||||
|
}
|
||||||
|
EXIT:
|
||||||
|
ret = pthread_cond_destroy(&g_cond3);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, POSIX_IPC_NO_ERROR, ret);
|
||||||
|
ret = pthread_mutex_destroy(&g_mtx3);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, POSIX_IPC_NO_ERROR, ret);
|
||||||
|
ICUNIT_ASSERT_EQUAL(testInt, TEST_SEEK_SIZE, testInt);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
RUN_TEST_SUITE(PthreadCondApiTestSuite);
|
||||||
|
|
||||||
|
void PosixFutexCondTest(void)
|
||||||
|
{
|
||||||
|
RUN_ONE_TESTCASE(testPthreadCondInit);
|
||||||
|
RUN_ONE_TESTCASE(testPthreadCondDestroy);
|
||||||
|
RUN_ONE_TESTCASE(testPthreadCondattrInit);
|
||||||
|
RUN_ONE_TESTCASE(testPthreadCondBroadcast);
|
||||||
|
}
|
||||||
@@ -0,0 +1,870 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2023-2023 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 "xts_ipc.h"
|
||||||
|
|
||||||
|
LITE_TEST_SUIT(IPC, IpcMqExceptionApi, IpcMqExceptionApiTestSuite);
|
||||||
|
|
||||||
|
static BOOL IpcMqExceptionApiTestSuiteSetUp(void)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static BOOL IpcMqExceptionApiTestSuiteTearDown(void)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @tc.number SUB_KERNEL_IPC_MQ_RECEIVE_0200
|
||||||
|
* @tc.name mq_receive function errno for EBADF and EMSGSIZE test
|
||||||
|
* @tc.desc [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(IpcMqExceptionApiTestSuite, testMqReceiveEBADFEMSGSIZE001, Function | MediumTest | Level2)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
mqd_t queue;
|
||||||
|
unsigned int prio;
|
||||||
|
struct mq_attr attr = { 0 };
|
||||||
|
struct mq_attr getAttr = { 0 };
|
||||||
|
char qName[MQ_NAME_LEN], rMsg[MQ_RX_LEN], rMsgErr[1];
|
||||||
|
|
||||||
|
ret = sprintf_s(qName, MQ_NAME_LEN, "testMqReceiveEAGAIN_%d", GetRandom(10000)); /* 10000, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, strlen(qName), ret);
|
||||||
|
attr.mq_msgsize = MQ_MSG_SIZE;
|
||||||
|
attr.mq_maxmsg = MQ_MAX_MSG;
|
||||||
|
queue = mq_open(qName, O_CREAT | O_RDWR | O_NONBLOCK, S_IRUSR | S_IWUSR, &attr);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(queue, (mqd_t)-1, queue); /* -1, common data for test, no special meaning */
|
||||||
|
ret = mq_send(queue, MQ_MSG, MQ_MSG_LEN, MQ_MSG_PRIO);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ret = mq_getattr(queue, &getAttr);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ret = mq_receive(queue, rMsg, getAttr.mq_msgsize, &prio);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */
|
||||||
|
ret = strncmp(MQ_MSG, rMsg, MQ_MSG_LEN);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ret = mq_receive(NULL, rMsg, getAttr.mq_msgsize, &prio);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(errno, EBADF, errno);
|
||||||
|
ret = mq_send(queue, MQ_MSG, MQ_MSG_LEN, MQ_MSG_PRIO);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ret = mq_receive(queue, rMsgErr, sizeof(rMsgErr), &prio);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(errno, EMSGSIZE, errno);
|
||||||
|
ret = mq_close(queue);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ret = mq_unlink(qName);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @tc.number SUB_KERNEL_IPC_MQ_RECEIVE_0200
|
||||||
|
* @tc.name mq_receive function errno for EBADF and EMSGSIZE test
|
||||||
|
* @tc.desc [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(IpcMqExceptionApiTestSuite, testMqReceiveEBADFEMSGSIZE002, Function | MediumTest | Level2)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
mqd_t queue;
|
||||||
|
unsigned int prio;
|
||||||
|
struct mq_attr attr = { 0 };
|
||||||
|
struct mq_attr getAttr = { 0 };
|
||||||
|
char qName[MQ_NAME_LEN], rMsg[MQ_RX_LEN];
|
||||||
|
|
||||||
|
ret = sprintf_s(qName, MQ_NAME_LEN, "testMqReceiveEAGAIN_%d", GetRandom(10000)); /* 10000, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, strlen(qName), ret);
|
||||||
|
attr.mq_msgsize = MQ_MSG_SIZE;
|
||||||
|
attr.mq_maxmsg = MQ_MAX_MSG;
|
||||||
|
queue = mq_open(qName, O_CREAT | O_WRONLY | O_NONBLOCK, S_IRUSR | S_IWUSR, &attr);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(queue, (mqd_t)-1, queue); /* -1, common data for test, no special meaning */
|
||||||
|
ret = mq_getattr(queue, &getAttr);
|
||||||
|
ret = mq_receive(queue, rMsg, getAttr.mq_msgsize, &prio);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(errno, EBADF, errno);
|
||||||
|
attr.mq_flags |= O_NONBLOCK;
|
||||||
|
ret = mq_setattr(queue, &attr, NULL);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ret = mq_receive(queue, rMsg, getAttr.mq_msgsize, &prio);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(errno, EBADF, errno);
|
||||||
|
ret = mq_close(queue);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ret = mq_unlink(qName);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @tc.number SUB_KERNEL_IPC_MQ_RECEIVE_0300
|
||||||
|
* @tc.name mq_receive function errno for EINVAL test
|
||||||
|
* @tc.desc [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(IpcMqExceptionApiTestSuite, testMqReceiveEINVAL, Function | MediumTest | Level3)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
mqd_t queue;
|
||||||
|
unsigned int prio;
|
||||||
|
struct mq_attr attr = { 0 };
|
||||||
|
char qName[MQ_NAME_LEN], rMsg[MQ_RX_LEN];
|
||||||
|
|
||||||
|
ret = sprintf_s(qName, MQ_NAME_LEN, "testMqReceiveEINVAL_%d", GetRandom(10000)); /* 10000, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, strlen(qName), ret);
|
||||||
|
attr.mq_msgsize = MQ_MSG_SIZE;
|
||||||
|
attr.mq_maxmsg = MQ_MAX_MSG;
|
||||||
|
queue = mq_open(qName, O_CREAT | O_RDWR | O_NONBLOCK, S_IRUSR | S_IWUSR, &attr);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(queue, (mqd_t)-1, queue); /* -1, common data for test, no special meaning */
|
||||||
|
|
||||||
|
ret = mq_receive(queue, rMsg, 0, &prio);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
|
||||||
|
|
||||||
|
ret = mq_close(queue);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ret = mq_unlink(qName);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @tc.number SUB_KERNEL_IPC_MQ_TIMEDSEND_0100
|
||||||
|
* @tc.name mq_timedsend function errno for EAGAIN and EBADF test
|
||||||
|
* @tc.desc [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(IpcMqExceptionApiTestSuite, testMqTimedSendEAGAINEBADF, Function | MediumTest | Level2)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
mqd_t queue;
|
||||||
|
struct timespec ts = { 0, 0 };
|
||||||
|
struct mq_attr attr = { 0 };
|
||||||
|
char qName[MQ_NAME_LEN];
|
||||||
|
|
||||||
|
ret = sprintf_s(qName, MQ_NAME_LEN, "testMqTimedSendEAGAIN_%d", GetRandom(10000)); /* 10000, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, strlen(qName), ret);
|
||||||
|
attr.mq_msgsize = MQ_MSG_SIZE;
|
||||||
|
attr.mq_maxmsg = 1; /* 1, common data for test, no special meaning */
|
||||||
|
queue = mq_open(qName, O_CREAT | O_RDWR | O_NONBLOCK, S_IRUSR | S_IWUSR, &attr);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(queue, (mqd_t)-1, queue); /* -1, common data for test, no special meaning */
|
||||||
|
|
||||||
|
ts.tv_sec = time(NULL) + 1; /* 1, common data for test, no special meaning */
|
||||||
|
ts.tv_nsec = 0;
|
||||||
|
ret = mq_timedsend(queue, MQ_MSG, MQ_MSG_LEN, MQ_MSG_PRIO, &ts);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
|
||||||
|
ts.tv_sec = 0;
|
||||||
|
ts.tv_nsec = 0;
|
||||||
|
ret = mq_timedsend(queue, MQ_MSG, MQ_MSG_LEN, MQ_MSG_PRIO, &ts);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(errno, EAGAIN, errno);
|
||||||
|
ret = mq_timedsend(NULL, MQ_MSG, MQ_MSG_LEN, MQ_MSG_PRIO, &ts);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(errno, EBADF, errno);
|
||||||
|
|
||||||
|
ret = mq_close(queue);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ret = mq_unlink(qName);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
|
||||||
|
attr.mq_msgsize = MQ_MSG_SIZE;
|
||||||
|
attr.mq_maxmsg = MQ_MAX_MSG;
|
||||||
|
queue = mq_open(qName, O_CREAT | O_RDONLY | O_NONBLOCK, S_IRUSR | S_IWUSR, &attr);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(queue, (mqd_t)-1, queue); /* -1, common data for test, no special meaning */
|
||||||
|
|
||||||
|
ret = mq_timedsend(queue, MQ_MSG, MQ_MSG_LEN, MQ_MSG_PRIO, &ts);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(errno, EBADF, errno);
|
||||||
|
|
||||||
|
attr.mq_flags |= O_NONBLOCK;
|
||||||
|
ret = mq_setattr(queue, &attr, NULL);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ret = mq_timedsend(queue, MQ_MSG, MQ_MSG_LEN, MQ_MSG_PRIO, &ts);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(errno, EBADF, errno);
|
||||||
|
|
||||||
|
ret = mq_close(queue);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ret = mq_unlink(qName);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @tc.number SUB_KERNEL_IPC_MQ_TIMEDSEND_0200
|
||||||
|
* @tc.name mq_timedsend function errno for EINVAL test
|
||||||
|
* @tc.desc [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(IpcMqExceptionApiTestSuite, testMqTimedSendEINVAL, Function | MediumTest | Level2)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
mqd_t queue;
|
||||||
|
struct timespec ts = { 0, 0 };
|
||||||
|
struct mq_attr attr = { 0 };
|
||||||
|
char qName[MQ_NAME_LEN];
|
||||||
|
|
||||||
|
ret = sprintf_s(qName, MQ_NAME_LEN, "testMqTimedSendEINVAL_%d", GetRandom(10000)); /* 10000, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, strlen(qName), ret);
|
||||||
|
attr.mq_msgsize = MQ_MSG_SIZE;
|
||||||
|
attr.mq_maxmsg = MQ_MAX_MSG;
|
||||||
|
queue = mq_open(qName, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &attr);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(queue, (mqd_t)-1, queue); /* -1, common data for test, no special meaning */
|
||||||
|
|
||||||
|
for (int i = 0; i < 3; i++) { /* 3, common data for test, no special meaning */
|
||||||
|
switch (i) {
|
||||||
|
case 0:
|
||||||
|
ts.tv_sec = -1; /* -1, common data for test, no special meaning */
|
||||||
|
ts.tv_nsec = 0;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
ts.tv_sec = time(NULL) + 1; /* 1, common data for test, no special meaning */
|
||||||
|
ts.tv_nsec = -1; /* -1, common data for test, no special meaning */
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
ts.tv_sec = time(NULL) + 1; /* 1, common data for test, no special meaning */
|
||||||
|
ts.tv_nsec = 1000000000UL + 1UL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = mq_timedsend(queue, MQ_MSG, MQ_MSG_LEN, MQ_MSG_PRIO, &ts);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
|
||||||
|
}
|
||||||
|
ret = mq_timedsend(queue, MQ_MSG, 0, MQ_MSG_PRIO, &ts);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
|
||||||
|
|
||||||
|
ret = mq_close(queue);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ret = mq_unlink(qName);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @tc.number SUB_KERNEL_IPC_MQ_TIMEDSEND_0300
|
||||||
|
* @tc.name mq_timedsend function errno for EMSGSIZE test
|
||||||
|
* @tc.desc [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(IpcMqExceptionApiTestSuite, testMqTimedSendEMSGSIZE, Function | MediumTest | Level3)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
mqd_t queue;
|
||||||
|
struct timespec ts = { 0, 0 };
|
||||||
|
struct mq_attr attr = { 0 };
|
||||||
|
char qName[MQ_NAME_LEN];
|
||||||
|
|
||||||
|
ret = sprintf_s(qName, MQ_NAME_LEN, "testMqTimedSendEMSGSIZE_%d", GetRandom(10000)); /* 10000, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, strlen(qName), ret);
|
||||||
|
attr.mq_msgsize = 1; /* 1, common data for test, no special meaning */
|
||||||
|
attr.mq_maxmsg = MQ_MAX_MSG;
|
||||||
|
queue = mq_open(qName, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &attr);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(queue, (mqd_t)-1, queue); /* -1, common data for test, no special meaning */
|
||||||
|
|
||||||
|
ts.tv_sec = time(NULL) + 1; /* 1, common data for test, no special meaning */
|
||||||
|
ts.tv_nsec = 0;
|
||||||
|
ret = mq_timedsend(queue, MQ_MSG, MQ_MSG_LEN, MQ_MSG_PRIO, &ts);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(errno, EMSGSIZE, errno);
|
||||||
|
|
||||||
|
ret = mq_close(queue);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ret = mq_unlink(qName);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @tc.number SUB_KERNEL_IPC_MQ_TIMEDSEND_0400
|
||||||
|
* @tc.name mq_timedsend function errno for ETIMEDOUT test
|
||||||
|
* @tc.desc [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(IpcMqExceptionApiTestSuite, testMqTimedSendETIMEDOUT, Function | MediumTest | Level3)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
mqd_t queue;
|
||||||
|
struct timespec ts = { 0, 0 };
|
||||||
|
struct mq_attr attr = { 0 };
|
||||||
|
char qName[MQ_NAME_LEN];
|
||||||
|
|
||||||
|
ret = sprintf_s(qName, MQ_NAME_LEN, "testMqTimedSendETIMEDOUT_%d", GetRandom(10000)); /* 10000, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, strlen(qName), ret);
|
||||||
|
attr.mq_msgsize = MQ_MSG_SIZE;
|
||||||
|
attr.mq_maxmsg = 1; /* 1, common data for test, no special meaning */
|
||||||
|
queue = mq_open(qName, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &attr);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(queue, (mqd_t)-1, queue); /* -1, common data for test, no special meaning */
|
||||||
|
|
||||||
|
ts.tv_sec = time(NULL) + 1; /* 1, common data for test, no special meaning */
|
||||||
|
ts.tv_nsec = 0;
|
||||||
|
ret = mq_timedsend(queue, MQ_MSG, MQ_MSG_LEN, MQ_MSG_PRIO, &ts);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
|
||||||
|
ts.tv_sec = 0;
|
||||||
|
ts.tv_nsec = 100; /* 100, common data for test, no special meaning */
|
||||||
|
ret = mq_timedsend(queue, MQ_MSG, MQ_MSG_LEN, MQ_MSG_PRIO, &ts);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(errno, ETIMEDOUT, errno);
|
||||||
|
|
||||||
|
ret = mq_close(queue);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ret = mq_unlink(qName);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @tc.number SUB_KERNEL_IPC_MQ_TIMEDRECEIVE_0100
|
||||||
|
* @tc.name mq_timedreceive function errno for EAGAIN and EBADF test
|
||||||
|
* @tc.desc [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(IpcMqExceptionApiTestSuite, testMqTimedReceiveEAGAINEBADF, Function | MediumTest | Level2)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
mqd_t queue;
|
||||||
|
unsigned int prio;
|
||||||
|
struct timespec ts = { 0, 0 };
|
||||||
|
struct mq_attr attr = { 0 };
|
||||||
|
struct mq_attr getAttr = { 0 };
|
||||||
|
char qName[MQ_NAME_LEN], rMsg[MQ_RX_LEN];
|
||||||
|
|
||||||
|
ret = sprintf_s(qName, MQ_NAME_LEN, "testMqTimedReceiveEAGAIN_%d", GetRandom(10000)); /* 10000, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, strlen(qName), ret);
|
||||||
|
attr.mq_msgsize = MQ_MSG_SIZE;
|
||||||
|
attr.mq_maxmsg = MQ_MAX_MSG;
|
||||||
|
queue = mq_open(qName, O_CREAT | O_RDWR | O_NONBLOCK, S_IRUSR | S_IWUSR, &attr);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(queue, (mqd_t)-1, queue); /* -1, common data for test, no special meaning */
|
||||||
|
|
||||||
|
ret = mq_getattr(queue, &getAttr);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ts.tv_sec = time(NULL) + 1; /* 1, common data for test, no special meaning */
|
||||||
|
ts.tv_nsec = 0;
|
||||||
|
ret = mq_timedreceive(queue, rMsg, getAttr.mq_msgsize, &prio, &ts);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(errno, EAGAIN, errno);
|
||||||
|
ret = mq_timedreceive(NULL, rMsg, getAttr.mq_msgsize, &prio, &ts);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(errno, EBADF, errno);
|
||||||
|
|
||||||
|
ret = mq_close(queue);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ret = mq_unlink(qName);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
|
||||||
|
attr.mq_msgsize = MQ_MSG_SIZE;
|
||||||
|
attr.mq_maxmsg = MQ_MAX_MSG;
|
||||||
|
queue = mq_open(qName, O_CREAT | O_WRONLY | O_NONBLOCK, S_IRUSR | S_IWUSR, &attr);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(queue, (mqd_t)-1, queue); /* -1, common data for test, no special meaning */
|
||||||
|
|
||||||
|
ret = mq_timedreceive(NULL, rMsg, getAttr.mq_msgsize, &prio, &ts);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(errno, EBADF, errno);
|
||||||
|
|
||||||
|
attr.mq_flags |= O_NONBLOCK;
|
||||||
|
ret = mq_setattr(queue, &attr, NULL);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ret = mq_timedreceive(NULL, rMsg, getAttr.mq_msgsize, &prio, &ts);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(errno, EBADF, errno);
|
||||||
|
|
||||||
|
ret = mq_close(queue);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ret = mq_unlink(qName);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @tc.number SUB_KERNEL_IPC_MQ_TIMEDRECEIVE_0200
|
||||||
|
* @tc.name mq_timedreceive function errno for EINVAL test
|
||||||
|
* @tc.desc [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(IpcMqExceptionApiTestSuite, testMqTimedReceiveEINVAL, Function | MediumTest | Level2)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
mqd_t queue;
|
||||||
|
unsigned int prio;
|
||||||
|
struct timespec ts = { 0, 0 };
|
||||||
|
struct mq_attr attr = { 0 };
|
||||||
|
struct mq_attr getAttr = { 0 };
|
||||||
|
char qName[MQ_NAME_LEN], rMsg[MQ_RX_LEN];
|
||||||
|
|
||||||
|
ret = sprintf_s(qName, MQ_NAME_LEN, "testMqTimedReceiveEINVAL_%d", GetRandom(10000)); /* 10000, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, strlen(qName), ret);
|
||||||
|
attr.mq_msgsize = MQ_MSG_SIZE;
|
||||||
|
attr.mq_maxmsg = MQ_MAX_MSG;
|
||||||
|
queue = mq_open(qName, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &attr);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(queue, (mqd_t)-1, queue); /* -1, common data for test, no special meaning */
|
||||||
|
|
||||||
|
for (int i = 0; i < 3; i++) { /* 3, common data for test, no special meaning */
|
||||||
|
switch (i) {
|
||||||
|
case 0:
|
||||||
|
ts.tv_sec = -1; /* -1, common data for test, no special meaning */
|
||||||
|
ts.tv_nsec = 0;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
ts.tv_sec = time(NULL) + 1; /* 1, common data for test, no special meaning */
|
||||||
|
ts.tv_nsec = -1; /* -1, common data for test, no special meaning */
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
ts.tv_sec = time(NULL) + 1; /* 1, common data for test, no special meaning */
|
||||||
|
ts.tv_nsec = 1000000000UL + 1UL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = mq_getattr(queue, &getAttr);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ret = mq_timedreceive(queue, rMsg, getAttr.mq_msgsize, &prio, &ts);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
|
||||||
|
}
|
||||||
|
ret = mq_timedreceive(queue, rMsg, 0, &prio, &ts);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
|
||||||
|
|
||||||
|
ret = mq_close(queue);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ret = mq_unlink(qName);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @tc.number SUB_KERNEL_IPC_MQ_TIMEDRECEIVE_0300
|
||||||
|
* @tc.name mq_timedreceive function errno for ETIMEDOUT test
|
||||||
|
* @tc.desc [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(IpcMqExceptionApiTestSuite, testMqTimedReceiveETIMEDOUT, Function | MediumTest | Level3)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
mqd_t queue;
|
||||||
|
unsigned int prio;
|
||||||
|
struct timespec ts = { 0, 0 };
|
||||||
|
struct mq_attr attr = { 0 };
|
||||||
|
struct mq_attr getAttr = { 0 };
|
||||||
|
char qName[MQ_NAME_LEN], rMsg[MQ_RX_LEN];
|
||||||
|
|
||||||
|
ret = sprintf_s(qName, MQ_NAME_LEN, "testMqTimedReceiveETIMEDOUT_%d", GetRandom(10000)); /* 10000, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, strlen(qName), ret);
|
||||||
|
attr.mq_msgsize = MQ_MSG_SIZE;
|
||||||
|
attr.mq_maxmsg = MQ_MAX_MSG;
|
||||||
|
queue = mq_open(qName, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &attr);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(queue, (mqd_t)-1, queue); /* -1, common data for test, no special meaning */
|
||||||
|
|
||||||
|
ret = mq_getattr(queue, &getAttr);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ts.tv_sec = 0;
|
||||||
|
ts.tv_nsec = 100; /* 100, common data for test, no special meaning */
|
||||||
|
ret = mq_timedreceive(queue, rMsg, getAttr.mq_msgsize, &prio, &ts);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(errno, ETIMEDOUT, errno);
|
||||||
|
|
||||||
|
ret = mq_close(queue);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ret = mq_unlink(qName);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @tc.number SUB_KERNEL_IPC_MQ_TIMEDRECEIVE_0400
|
||||||
|
* @tc.name mq_timedreceive function errno for EMSGSIZE test
|
||||||
|
* @tc.desc [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(IpcMqExceptionApiTestSuite, testMqTimedReceiveEMSGSIZE, Function | MediumTest | Level3)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
mqd_t queue;
|
||||||
|
unsigned int prio;
|
||||||
|
struct timespec ts = { 0, 0 };
|
||||||
|
struct mq_attr attr = { 0 };
|
||||||
|
char qName[MQ_NAME_LEN], rMsg[MQ_RX_LEN];
|
||||||
|
|
||||||
|
ret = sprintf_s(qName, MQ_NAME_LEN, "testMqTimedReceiveEMSGSIZE_%d", GetRandom(10000)); /* 10000, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, strlen(qName), ret);
|
||||||
|
attr.mq_msgsize = MQ_MSG_SIZE;
|
||||||
|
attr.mq_maxmsg = MQ_MAX_MSG;
|
||||||
|
queue = mq_open(qName, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &attr);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(queue, (mqd_t)-1, queue); /* -1, common data for test, no special meaning */
|
||||||
|
|
||||||
|
ret = mq_send(queue, MQ_MSG, MQ_MSG_LEN, MQ_MSG_PRIO);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ts.tv_sec = time(NULL) + 1; /* 1, common data for test, no special meaning */
|
||||||
|
ts.tv_nsec = 0;
|
||||||
|
ret = mq_timedreceive(queue, rMsg, 1, &prio, &ts); /* 1, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(errno, EMSGSIZE, errno);
|
||||||
|
|
||||||
|
ret = mq_close(queue);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ret = mq_unlink(qName);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @tc.number SUB_KERNEL_IPC_MQ_UNLINK_0100
|
||||||
|
* @tc.name mq_unlink function errno for ENAMETOOLONG test
|
||||||
|
* @tc.desc [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(IpcMqExceptionApiTestSuite, testMqUnlinkENAMETOOLONG, Function | MediumTest | Level2)
|
||||||
|
{
|
||||||
|
char qName[MAX_MQ_NAME_LEN + 10]; /* 10, common data for test, no special meaning */
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < MAX_MQ_NAME_LEN + 5; i++) { /* 5, common data for test, no special meaning */
|
||||||
|
qName[i] = '8';
|
||||||
|
}
|
||||||
|
qName[i] = '\0';
|
||||||
|
int ret = mq_unlink(qName);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(errno, ENAMETOOLONG, errno);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @tc.number SUB_KERNEL_IPC_MQ_UNLINK_0200
|
||||||
|
* @tc.name mq_unlink function errno for ENOENT test
|
||||||
|
* @tc.desc [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(IpcMqExceptionApiTestSuite, testMqUnlinkENOENT, Function | MediumTest | Level2)
|
||||||
|
{
|
||||||
|
char qName[64] = "/mq_file-does-not-exit"; /* 64, common data for test, no special meaning */
|
||||||
|
int ret = mq_unlink(qName);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(errno, ENOENT, errno);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @tc.number SUB_KERNEL_IPC_MQ_UNLINK_0300
|
||||||
|
* @tc.name mq_unlink function errno for EINVAL test
|
||||||
|
* @tc.desc [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(IpcMqExceptionApiTestSuite, testMqUnlinkEINVAL, Function | MediumTest | Level3)
|
||||||
|
{
|
||||||
|
int ret = mq_unlink("");
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, -1, ret);
|
||||||
|
ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @tc.number SUB_KERNEL_IPC_MQ_GETATTR_0100
|
||||||
|
* @tc.name mq_getattr function errno for EBAD and EINVALF test
|
||||||
|
* @tc.desc [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(IpcMqExceptionApiTestSuite, testMqGetAttrEBADFEINVAL, Function | MediumTest | Level2)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
mqd_t queue;
|
||||||
|
struct mq_attr mqstat = { 0 };
|
||||||
|
char qName[MQ_NAME_LEN];
|
||||||
|
|
||||||
|
memset_s(&mqstat, sizeof(mqstat), 0, sizeof(mqstat));
|
||||||
|
ret = sprintf_s(qName, MQ_NAME_LEN, "testMqSendEINVAL_%d", GetRandom(10000)); /* 10000, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, strlen(qName), ret);
|
||||||
|
queue = mq_open(qName, O_CREAT | O_RDWR | O_NONBLOCK, S_IRUSR | S_IWUSR, NULL);
|
||||||
|
|
||||||
|
ret = mq_getattr(NULL, &mqstat);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(errno, EBADF, errno);
|
||||||
|
|
||||||
|
ret = mq_getattr(queue, NULL);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
|
||||||
|
|
||||||
|
ret = mq_close(queue);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ret = mq_unlink(qName);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @tc.number SUB_KERNEL_IPC_MQ_SETATTR_0100
|
||||||
|
* @tc.name mq_receive function errno for EBADF and EINVAL test
|
||||||
|
* @tc.desc [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(IpcMqExceptionApiTestSuite, testMqSetAttrEBADFEINVAL, Function | MediumTest | Level2)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
char qName[MQ_NAME_LEN];
|
||||||
|
mqd_t queue;
|
||||||
|
struct mq_attr gMqstat = { 0 }, sMqstat = { 0 };
|
||||||
|
|
||||||
|
ret = sprintf_s(qName, MQ_NAME_LEN, "testMqSetAttrEBADFEINVAL_%d", GetRandom(10000)); /* 10000, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, strlen(qName), ret);
|
||||||
|
queue = mq_open(qName, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, NULL);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(queue, (mqd_t)-1, queue); /* -1, common data for test, no special meaning */
|
||||||
|
|
||||||
|
memset_s(&gMqstat, sizeof(gMqstat), 0, sizeof(gMqstat));
|
||||||
|
memset_s(&sMqstat, sizeof(sMqstat), 0, sizeof(sMqstat));
|
||||||
|
ret = mq_getattr(queue, &gMqstat);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
|
||||||
|
sMqstat.mq_flags |= O_NONBLOCK;
|
||||||
|
ret = mq_setattr(queue, &sMqstat, NULL);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ret = mq_getattr(queue, &gMqstat);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(gMqstat.mq_flags, sMqstat.mq_flags, gMqstat.mq_flags);
|
||||||
|
|
||||||
|
ret = mq_setattr(NULL, &sMqstat, NULL);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(errno, EBADF, errno);
|
||||||
|
ret = mq_setattr(queue, NULL, NULL);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
|
||||||
|
|
||||||
|
ret = mq_close(queue);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ret = mq_unlink(qName);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @tc.number SUB_KERNEL_IPC_MQ_OPEN_0100
|
||||||
|
* @tc.name mq_open function errno for EEXIST test
|
||||||
|
* @tc.desc [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(IpcMqExceptionApiTestSuite, testMqOpenEEXIST, Function | MediumTest | Level2)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
char qName[MQ_NAME_LEN];
|
||||||
|
mqd_t queue, queueOther;
|
||||||
|
|
||||||
|
ret = sprintf_s(qName, sizeof(qName), "testMqOpenEEXIST_%d", GetRandom(10000)); /* 10000, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, strlen(qName), ret);
|
||||||
|
queue = mq_open(qName, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, NULL);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(queue, (mqd_t)-1, queue); /* 1, common data for test, no special meaning */
|
||||||
|
|
||||||
|
queueOther = mq_open(qName, O_CREAT | O_EXCL, S_IRUSR | S_IWUSR, NULL);
|
||||||
|
ICUNIT_ASSERT_EQUAL(queueOther, (mqd_t)-1, queueOther); /* 1, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(errno, EEXIST, errno);
|
||||||
|
ret = mq_close(queue);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ret = mq_unlink(qName);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @tc.number SUB_KERNEL_IPC_MQ_OPEN_0200
|
||||||
|
* @tc.name mq_open function errno for EINVAL test
|
||||||
|
* @tc.desc [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(IpcMqExceptionApiTestSuite, testMqOpenEINVAL, Function | MediumTest | Level2)
|
||||||
|
{
|
||||||
|
int i, ret;
|
||||||
|
mqd_t queue;
|
||||||
|
struct mq_attr attr = { 0 };
|
||||||
|
char qName[MQ_NAME_LEN];
|
||||||
|
const int max = 65535; /* 65535, common data for test, no special meaning */
|
||||||
|
|
||||||
|
ret = sprintf_s(qName, sizeof(qName), "testMqOpenEINVAL_%d", GetRandom(10000)); /* 10000, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, strlen(qName), ret);
|
||||||
|
|
||||||
|
for (i = 0; i < 6; i++) {
|
||||||
|
switch (i) {
|
||||||
|
case 0:
|
||||||
|
attr.mq_msgsize = -1; /* -1, common data for test, no special meaning */
|
||||||
|
attr.mq_maxmsg = max;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
attr.mq_msgsize = max;
|
||||||
|
attr.mq_maxmsg = max;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
attr.mq_msgsize = 10; /* 10, common data for test, no special meaning */
|
||||||
|
attr.mq_maxmsg = -1; /* -1, common data for test, no special meaning */
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
attr.mq_msgsize = 10; /* 10, common data for test, no special meaning */
|
||||||
|
attr.mq_maxmsg = max + 1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 4:
|
||||||
|
attr.mq_msgsize = 0; /* 0, common data for test, no special meaning */
|
||||||
|
attr.mq_maxmsg = 16; /* 16, common data for test, no special meaning */
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 5:
|
||||||
|
attr.mq_msgsize = 64; /* 64, common data for test, no special meaning */
|
||||||
|
attr.mq_maxmsg = 0; /* 0, common data for test, no special meaning */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
queue = mq_open(qName, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &attr);
|
||||||
|
ICUNIT_ASSERT_EQUAL(queue, (mqd_t)-1, queue); /* 1, common data for test, no special meaning */
|
||||||
|
|
||||||
|
if (queue != (mqd_t)-1) { /* 1, common data for test, no special meaning */
|
||||||
|
ret = mq_close(queue);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ret = mq_unlink(qName);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < MQ_NAME_LEN; i++) {
|
||||||
|
qName[i] = 0;
|
||||||
|
}
|
||||||
|
attr.mq_msgsize = MQ_MSG_SIZE;
|
||||||
|
attr.mq_maxmsg = MQ_MAX_MSG;
|
||||||
|
queue = mq_open(qName, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &attr);
|
||||||
|
ICUNIT_ASSERT_EQUAL(queue, (mqd_t)-1, queue); /* 1, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @tc.number SUB_KERNEL_IPC_MQ_OPEN_0300
|
||||||
|
* @tc.name mq_open function errno for ENAMETOOLONG test
|
||||||
|
* @tc.desc [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(IpcMqExceptionApiTestSuite, testMqOpenENAMETOOLONG, Function | MediumTest | Level2)
|
||||||
|
{
|
||||||
|
char qName[MAX_MQ_NAME_LEN + 10]; /* 10, common data for test, no special meaning */
|
||||||
|
mqd_t queue;
|
||||||
|
int i, ret;
|
||||||
|
|
||||||
|
for (i = 0; i < MAX_MQ_NAME_LEN + 5; i++) { /* 5, common data for test, no special meaning */
|
||||||
|
qName[i] = '8';
|
||||||
|
}
|
||||||
|
qName[i] = '\0';
|
||||||
|
|
||||||
|
queue = mq_open(qName, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, NULL);
|
||||||
|
ICUNIT_ASSERT_EQUAL(queue, (mqd_t)-1, queue); /* -1, common data for test, no special meaning */
|
||||||
|
|
||||||
|
if (queue != (mqd_t)-1) { /* -1, common data for test, no special meaning */
|
||||||
|
ret = mq_close(queue);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ret = mq_unlink(qName);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
ICUNIT_ASSERT_EQUAL(errno, ENAMETOOLONG, errno);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @tc.number SUB_KERNEL_IPC_MQ_OPEN_0400
|
||||||
|
* @tc.name mq_open function errno for ENOENT test
|
||||||
|
* @tc.desc [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(IpcMqExceptionApiTestSuite, testMqOpenENOENT, Function | MediumTest | Level3)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
mqd_t queue;
|
||||||
|
char qName[MQ_NAME_LEN];
|
||||||
|
|
||||||
|
ret = sprintf_s(qName, MQ_NAME_LEN, "testMqOpenENOENT_%d", GetRandom(10000)); /* 10000, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, strlen(qName), ret);
|
||||||
|
queue = mq_open(qName, O_RDWR, S_IRUSR | S_IWUSR, NULL);
|
||||||
|
ICUNIT_ASSERT_EQUAL(queue, (mqd_t)-1, queue); /* -1, common data for test, no special meaning */
|
||||||
|
|
||||||
|
if (queue != (mqd_t)-1) { /* -1, common data for test, no special meaning */
|
||||||
|
ret = mq_close(queue);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ret = mq_unlink(qName);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
}
|
||||||
|
ICUNIT_ASSERT_EQUAL(errno, ENOENT, errno);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @tc.number SUB_KERNEL_IPC_MQ_OPEN_0600
|
||||||
|
* @tc.name mq_open function errno for ENOSPC test
|
||||||
|
* @tc.desc [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(IpcMqExceptionApiTestSuite, testMqOpenENOSPC, Function | MediumTest | Level3)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
mqd_t queue;
|
||||||
|
struct mq_attr setAttr = { 0 };
|
||||||
|
char qName[MQ_NAME_LEN];
|
||||||
|
|
||||||
|
ret = sprintf_s(qName, MQ_NAME_LEN, "testMqOpenENOSPC_%d", GetRandom(10000)); /* 10000, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, strlen(qName), ret);
|
||||||
|
setAttr.mq_msgsize = MAX_MQ_MSG_SIZE + 1; /* 1, common data for test, no special meaning */
|
||||||
|
setAttr.mq_maxmsg = MAX_MQ_NAME_LEN;
|
||||||
|
queue = mq_open(qName, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &setAttr);
|
||||||
|
ICUNIT_ASSERT_EQUAL(queue, (mqd_t)-1, queue); /* -1, common data for test, no special meaning */
|
||||||
|
|
||||||
|
if (queue != (mqd_t)-1) { /* -1, common data for test, no special meaning */
|
||||||
|
ret = mq_close(queue);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ret = mq_unlink(qName);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
}
|
||||||
|
ICUNIT_ASSERT_EQUAL(errno, ENOSPC, errno);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @tc.number SUB_KERNEL_IPC_MQ_CLOSE_0100
|
||||||
|
* @tc.name mq_close function errno for EBADF test
|
||||||
|
* @tc.desc [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(IpcMqExceptionApiTestSuite, testMqCloseEBADF, Function | MediumTest | Level2)
|
||||||
|
{
|
||||||
|
int ret = mq_close(NULL);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(errno, EBADF, errno);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
RUN_TEST_SUITE(IpcMqExceptionApiTestSuite);
|
||||||
|
|
||||||
|
void IpcMqExceptionFuncTest(void)
|
||||||
|
{
|
||||||
|
RUN_ONE_TESTCASE(testMqReceiveEBADFEMSGSIZE001);
|
||||||
|
RUN_ONE_TESTCASE(testMqReceiveEBADFEMSGSIZE002);
|
||||||
|
RUN_ONE_TESTCASE(testMqReceiveEINVAL);
|
||||||
|
RUN_ONE_TESTCASE(testMqTimedSendEAGAINEBADF);
|
||||||
|
RUN_ONE_TESTCASE(testMqTimedSendEINVAL);
|
||||||
|
RUN_ONE_TESTCASE(testMqTimedSendEMSGSIZE);
|
||||||
|
RUN_ONE_TESTCASE(testMqTimedSendETIMEDOUT);
|
||||||
|
RUN_ONE_TESTCASE(testMqTimedReceiveEAGAINEBADF);
|
||||||
|
RUN_ONE_TESTCASE(testMqTimedReceiveEINVAL);
|
||||||
|
RUN_ONE_TESTCASE(testMqTimedReceiveETIMEDOUT);
|
||||||
|
RUN_ONE_TESTCASE(testMqTimedReceiveEMSGSIZE);
|
||||||
|
RUN_ONE_TESTCASE(testMqUnlinkENAMETOOLONG);
|
||||||
|
RUN_ONE_TESTCASE(testMqUnlinkENOENT);
|
||||||
|
RUN_ONE_TESTCASE(testMqUnlinkEINVAL);
|
||||||
|
RUN_ONE_TESTCASE(testMqGetAttrEBADFEINVAL);
|
||||||
|
RUN_ONE_TESTCASE(testMqSetAttrEBADFEINVAL);
|
||||||
|
RUN_ONE_TESTCASE(testMqOpenEEXIST);
|
||||||
|
RUN_ONE_TESTCASE(testMqOpenEINVAL);
|
||||||
|
RUN_ONE_TESTCASE(testMqOpenENAMETOOLONG);
|
||||||
|
RUN_ONE_TESTCASE(testMqOpenENOENT);
|
||||||
|
RUN_ONE_TESTCASE(testMqOpenENOSPC);
|
||||||
|
RUN_ONE_TESTCASE(testMqCloseEBADF);
|
||||||
|
}
|
||||||
@@ -0,0 +1,511 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2023-2023 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 "xts_ipc.h"
|
||||||
|
|
||||||
|
LITE_TEST_SUIT(IPC, IpcMqApi, IpcMqApiTestSuite);
|
||||||
|
|
||||||
|
static BOOL IpcMqApiTestSuiteSetUp(void)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static BOOL IpcMqApiTestSuiteTearDown(void)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @tc.number SUB_KERNEL_IPC_MQ_0100
|
||||||
|
* @tc.name mq_send and mq_receive function test
|
||||||
|
* @tc.desc [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(IpcMqApiTestSuite, testMqOneLevelCom, Function | MediumTest | Level0)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
mqd_t queue;
|
||||||
|
unsigned int prio;
|
||||||
|
struct mq_attr getAttr = { 0 };
|
||||||
|
struct mq_attr setAttr = { 0 };
|
||||||
|
char qName[MQ_NAME_LEN];
|
||||||
|
char rMsg[MQ_RX_LEN];
|
||||||
|
|
||||||
|
ret = sprintf_s(qName, sizeof(qName), "testMqOneLevelCom_%d", GetRandom(10000)); /* 10000, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, strlen(qName), ret);
|
||||||
|
setAttr.mq_msgsize = MQ_MSG_SIZE;
|
||||||
|
setAttr.mq_maxmsg = MQ_MAX_MSG;
|
||||||
|
queue = mq_open(qName, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &setAttr);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(queue, (mqd_t)-1, queue); /* -1, common data for test, no special meaning */
|
||||||
|
ret = mq_send(queue, MQ_MSG, MQ_MSG_LEN, MQ_MSG_PRIO);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
|
||||||
|
ret = mq_getattr(queue, &getAttr);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ICUNIT_ASSERT_EQUAL(getAttr.mq_msgsize, MQ_MSG_SIZE, getAttr.mq_msgsize);
|
||||||
|
ICUNIT_ASSERT_EQUAL(getAttr.mq_maxmsg, MQ_MAX_MSG, getAttr.mq_maxmsg);
|
||||||
|
|
||||||
|
ret = mq_receive(queue, rMsg, getAttr.mq_msgsize, &prio);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(prio, 0, prio);
|
||||||
|
|
||||||
|
ret = strncmp(MQ_MSG, rMsg, MQ_MSG_LEN);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ret = mq_close(queue);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ret = mq_unlink(qName);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @tc.number SUB_KERNEL_IPC_MQ_0200
|
||||||
|
* @tc.name mq_timedsend and mq_timedreceive function test
|
||||||
|
* @tc.desc [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(IpcMqApiTestSuite, testMqTimedOneLevelCom, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
mqd_t queue;
|
||||||
|
unsigned int prio;
|
||||||
|
struct timespec tts = { 0 };
|
||||||
|
struct timespec rts = { 0 };
|
||||||
|
struct mq_attr getAttr = { 0 };
|
||||||
|
struct mq_attr setAttr = { 0 };
|
||||||
|
char qName[MQ_NAME_LEN];
|
||||||
|
char rMsg[MQ_RX_LEN];
|
||||||
|
|
||||||
|
ret = sprintf_s(qName, sizeof(qName), "testMqTimedOneLevelCom_%d", GetRandom(10000)); /* 10000, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, strlen(qName), ret);
|
||||||
|
setAttr.mq_msgsize = MQ_MSG_SIZE;
|
||||||
|
setAttr.mq_maxmsg = MQ_MAX_MSG;
|
||||||
|
queue = mq_open(qName, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &setAttr);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(queue, (mqd_t)-1, queue); /* -1, common data for test, no special meaning */
|
||||||
|
|
||||||
|
tts.tv_sec = time(NULL) + 1; /* 1, common data for test, no special meaning */
|
||||||
|
tts.tv_nsec = 0;
|
||||||
|
ret = mq_timedsend(queue, MQ_MSG, MQ_MSG_LEN, MQ_MSG_PRIO, &tts);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
|
||||||
|
ret = mq_getattr(queue, &getAttr);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ICUNIT_ASSERT_EQUAL(getAttr.mq_msgsize, MQ_MSG_SIZE, getAttr.mq_msgsize);
|
||||||
|
ICUNIT_ASSERT_EQUAL(getAttr.mq_maxmsg, MQ_MAX_MSG, getAttr.mq_maxmsg);
|
||||||
|
|
||||||
|
rts.tv_sec = time(NULL) + 1; /* 1, common data for test, no special meaning */
|
||||||
|
rts.tv_nsec = 0;
|
||||||
|
ret = mq_timedreceive(queue, rMsg, getAttr.mq_msgsize, &prio, &rts);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(prio, 0, prio);
|
||||||
|
ret = strncmp(MQ_MSG, rMsg, MQ_MSG_LEN);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ret = mq_close(queue);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ret = mq_unlink(qName);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @tc.number SUB_KERNEL_IPC_MQ_0300
|
||||||
|
* @tc.name all send and all receive function test
|
||||||
|
* @tc.desc [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(IpcMqApiTestSuite, testMqAllOneLevelCom001, Function | MediumTest | Level2)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
mqd_t queue;
|
||||||
|
unsigned int prio;
|
||||||
|
struct mq_attr getAttr = { 0 };
|
||||||
|
struct mq_attr setAttr = { 0 };
|
||||||
|
char qName[MQ_NAME_LEN];
|
||||||
|
char rMsg[MQ_RX_LEN];
|
||||||
|
|
||||||
|
ret = sprintf_s(qName, sizeof(qName), "testMqAllOneLevelCom_%d", GetRandom(10000)); /* 10000, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, strlen(qName), ret);
|
||||||
|
memset_s(&getAttr, sizeof(getAttr), 0, sizeof(getAttr));
|
||||||
|
memset_s(&setAttr, sizeof(setAttr), 0, sizeof(setAttr));
|
||||||
|
setAttr.mq_msgsize = MQ_MSG_SIZE;
|
||||||
|
setAttr.mq_maxmsg = MQ_MAX_MSG;
|
||||||
|
queue = mq_open(qName, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &setAttr);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(queue, (mqd_t)-1, queue); /* -1, common data for test, no special meaning */
|
||||||
|
ret = mq_getattr(queue, &setAttr);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
setAttr.mq_msgsize = MQ_MSG_SIZE;
|
||||||
|
setAttr.mq_maxmsg = MQ_MAX_MSG;
|
||||||
|
ret = mq_setattr(queue, &setAttr, NULL);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ret = mq_send(queue, MQ_MSG, MQ_MSG_LEN, MQ_MSG_PRIO);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ret = mq_getattr(queue, &getAttr);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ICUNIT_ASSERT_EQUAL(getAttr.mq_msgsize, setAttr.mq_msgsize, getAttr.mq_msgsize);
|
||||||
|
ICUNIT_ASSERT_EQUAL(getAttr.mq_maxmsg, setAttr.mq_maxmsg, getAttr.mq_maxmsg);
|
||||||
|
ICUNIT_ASSERT_EQUAL(getAttr.mq_curmsgs, 1, getAttr.mq_curmsgs); /* 1, common data for test, no special meaning */
|
||||||
|
ret = mq_receive(queue, rMsg, getAttr.mq_msgsize, &prio);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */
|
||||||
|
ret = strncmp(MQ_MSG, rMsg, MQ_MSG_LEN);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
|
||||||
|
ret = mq_close(queue);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ret = mq_unlink(qName);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @tc.number SUB_KERNEL_IPC_MQ_0300
|
||||||
|
* @tc.name all send and all receive function test
|
||||||
|
* @tc.desc [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(IpcMqApiTestSuite, testMqAllOneLevelCom002, Function | MediumTest | Level2)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
mqd_t queue;
|
||||||
|
unsigned int prio;
|
||||||
|
struct timespec tts = { 0 };
|
||||||
|
struct timespec rts = { 0 };
|
||||||
|
struct mq_attr getAttr = { 0 };
|
||||||
|
struct mq_attr setAttr = { 0 };
|
||||||
|
char qName[MQ_NAME_LEN];
|
||||||
|
char rMsg[MQ_RX_LEN];
|
||||||
|
|
||||||
|
ret = sprintf_s(qName, sizeof(qName), "testMqAllOneLevelCom_%d", GetRandom(10000)); /* 10000, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, strlen(qName), ret);
|
||||||
|
memset_s(&getAttr, sizeof(getAttr), 0, sizeof(getAttr));
|
||||||
|
memset_s(&setAttr, sizeof(setAttr), 0, sizeof(setAttr));
|
||||||
|
setAttr.mq_msgsize = MQ_MSG_SIZE;
|
||||||
|
setAttr.mq_maxmsg = MQ_MAX_MSG;
|
||||||
|
queue = mq_open(qName, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &setAttr);
|
||||||
|
|
||||||
|
tts.tv_sec = time(NULL) + 1; /* 1, common data for test, no special meaning */
|
||||||
|
tts.tv_nsec = 0;
|
||||||
|
ret = mq_timedsend(queue, MQ_MSG, MQ_MSG_LEN, MQ_MSG_PRIO, &tts);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ret = mq_getattr(queue, &getAttr);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ICUNIT_ASSERT_EQUAL(getAttr.mq_msgsize, setAttr.mq_msgsize, getAttr.mq_msgsize);
|
||||||
|
ICUNIT_ASSERT_EQUAL(getAttr.mq_maxmsg, setAttr.mq_maxmsg, getAttr.mq_maxmsg);
|
||||||
|
ICUNIT_ASSERT_EQUAL(getAttr.mq_curmsgs, 1, getAttr.mq_curmsgs); /* 1, common data for test, no special meaning */
|
||||||
|
|
||||||
|
rts.tv_sec = time(NULL) + 1; /* 1, common data for test, no special meaning */
|
||||||
|
rts.tv_nsec = 0;
|
||||||
|
ret = mq_timedreceive(queue, rMsg, getAttr.mq_msgsize, &prio, &rts);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */
|
||||||
|
ret = strncmp(MQ_MSG, rMsg, MQ_MSG_LEN);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
|
||||||
|
ret = mq_close(queue);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ret = mq_unlink(qName);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void *PthreadCom(void *arg)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
mqd_t queue;
|
||||||
|
unsigned int prio;
|
||||||
|
struct mq_attr getAttr = { 0 };
|
||||||
|
char rMsg[MQ_RX_LEN];
|
||||||
|
|
||||||
|
queue = (mqd_t)arg;
|
||||||
|
ret = mq_getattr(queue, &getAttr);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ret = mq_receive(queue, rMsg, getAttr.mq_msgsize, &prio);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(prio, MQ_MSG_PRIO, prio);
|
||||||
|
ret = strncmp(MQ_MSG, rMsg, MQ_MSG_LEN);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ret = mq_send(queue, MQ_MSG, MQ_MSG_LEN, MQ_MSG_PRIO);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @tc.number SUB_KERNEL_IPC_MQ_0700
|
||||||
|
* @tc.name mq_send and mq_receive function test in thread and process
|
||||||
|
* @tc.desc [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(IpcMqApiTestSuite, testMqTwoThreadCom, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
mqd_t queue;
|
||||||
|
pthread_t tid;
|
||||||
|
unsigned int prio;
|
||||||
|
struct mq_attr getAttr = { 0 };
|
||||||
|
struct mq_attr setAttr = { 0 };
|
||||||
|
char qName[MQ_NAME_LEN];
|
||||||
|
char rMsg[MQ_RX_LEN];
|
||||||
|
|
||||||
|
ret = sprintf_s(qName, sizeof(qName), "testMqTwoLevelCom_%d", GetRandom(10000)); /* 10000, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, strlen(qName), ret);
|
||||||
|
setAttr.mq_msgsize = MQ_MSG_SIZE;
|
||||||
|
setAttr.mq_maxmsg = MQ_MAX_MSG;
|
||||||
|
queue = mq_open(qName, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &setAttr);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(queue, (mqd_t)-1, queue); /* -1, common data for test, no special meaning */
|
||||||
|
|
||||||
|
ret = pthread_create(&tid, NULL, PthreadCom, (void *)queue);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */
|
||||||
|
|
||||||
|
ret = mq_send(queue, MQ_MSG, MQ_MSG_LEN, MQ_MSG_PRIO);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ret = pthread_join(tid, NULL);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
|
||||||
|
ret = mq_getattr(queue, &getAttr);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ICUNIT_ASSERT_EQUAL(getAttr.mq_curmsgs, 1, getAttr.mq_curmsgs); /* 1, common data for test, no special meaning */
|
||||||
|
ret = mq_receive(queue, rMsg, getAttr.mq_msgsize, &prio);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(prio, MQ_MSG_PRIO, prio);
|
||||||
|
ret = strncmp(MQ_MSG, rMsg, MQ_MSG_LEN);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
|
||||||
|
ret = mq_close(queue);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ret = mq_unlink(qName);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void *PthreadTimedCom(void *arg)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
mqd_t queue;
|
||||||
|
unsigned int prio;
|
||||||
|
struct timespec tts = { 0 };
|
||||||
|
struct timespec rts = { 0 };
|
||||||
|
struct mq_attr getAttr = { 0 };
|
||||||
|
char rMsg[MQ_RX_LEN];
|
||||||
|
|
||||||
|
queue = (mqd_t)arg;
|
||||||
|
ret = mq_getattr(queue, &getAttr);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
rts.tv_sec = time(NULL) + 1; /* 1, common data for test, no special meaning */
|
||||||
|
rts.tv_nsec = 0;
|
||||||
|
ret = mq_timedreceive(queue, rMsg, getAttr.mq_msgsize, &prio, &rts);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(prio, MQ_MSG_PRIO, prio);
|
||||||
|
ret = strncmp(MQ_MSG, rMsg, MQ_MSG_LEN);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
|
||||||
|
tts.tv_sec = time(NULL) + 1; /* 1, common data for test, no special meaning */
|
||||||
|
tts.tv_nsec = 0;
|
||||||
|
ret = mq_timedsend(queue, MQ_MSG, MQ_MSG_LEN, MQ_MSG_PRIO, &tts);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @tc.number SUB_KERNEL_IPC_MQ_0800
|
||||||
|
* @tc.name mq_timedsend and mq_timedreceive function test in thread and process
|
||||||
|
* @tc.desc [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(IpcMqApiTestSuite, testMqTimedTwoThreadCom, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
mqd_t queue;
|
||||||
|
pthread_t tid;
|
||||||
|
unsigned int prio;
|
||||||
|
struct timespec tts = { 0 };
|
||||||
|
struct timespec rts = { 0 };
|
||||||
|
struct mq_attr getAttr = { 0 };
|
||||||
|
struct mq_attr setAttr = { 0 };
|
||||||
|
char qName[MQ_NAME_LEN];
|
||||||
|
char rMsg[MQ_RX_LEN];
|
||||||
|
ret = sprintf_s(qName, sizeof(qName), "testMqTimedTwoThreadCom_%d", GetRandom(10000)); /* 10000, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, strlen(qName), ret);
|
||||||
|
setAttr.mq_msgsize = MQ_MSG_SIZE;
|
||||||
|
setAttr.mq_maxmsg = MQ_MAX_MSG;
|
||||||
|
queue = mq_open(qName, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &setAttr);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(queue, (mqd_t)-1, queue); /* -1, common data for test, no special meaning */
|
||||||
|
|
||||||
|
ret = pthread_create(&tid, NULL, PthreadTimedCom, (void *)queue);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */
|
||||||
|
|
||||||
|
tts.tv_sec = time(NULL) + 1; /* 1, common data for test, no special meaning */
|
||||||
|
tts.tv_nsec = 0;
|
||||||
|
ret = mq_timedsend(queue, MQ_MSG, MQ_MSG_LEN, MQ_MSG_PRIO, &tts);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ret = pthread_join(tid, NULL);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
|
||||||
|
ret = mq_getattr(queue, &getAttr);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ICUNIT_ASSERT_EQUAL(getAttr.mq_curmsgs, 1, getAttr.mq_curmsgs); /* 1, common data for test, no special meaning */
|
||||||
|
rts.tv_sec = time(NULL) + 1; /* 1, common data for test, no special meaning */
|
||||||
|
rts.tv_nsec = 0;
|
||||||
|
ret = mq_timedreceive(queue, rMsg, getAttr.mq_msgsize, &prio, &rts);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(prio, MQ_MSG_PRIO, prio);
|
||||||
|
ret = strncmp(MQ_MSG, rMsg, MQ_MSG_LEN);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
|
||||||
|
ret = mq_close(queue);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ret = mq_unlink(qName);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void *PthreadAllCom(void *arg)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
mqd_t queue;
|
||||||
|
unsigned int prio;
|
||||||
|
struct timespec tts = { 0 };
|
||||||
|
struct timespec rts = { 0 };
|
||||||
|
struct mq_attr getAttr = { 0 };
|
||||||
|
char rMsg[MQ_RX_LEN];
|
||||||
|
|
||||||
|
queue = (mqd_t)arg;
|
||||||
|
ret = mq_getattr(queue, &getAttr);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
rts.tv_sec = time(NULL) + 1; /* 1, common data for test, no special meaning */
|
||||||
|
rts.tv_nsec = 0;
|
||||||
|
ret = mq_timedreceive(queue, rMsg, getAttr.mq_msgsize, &prio, &rts);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(prio, MQ_MSG_PRIO, prio);
|
||||||
|
ret = strncmp(MQ_MSG, rMsg, MQ_MSG_LEN);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
tts.tv_sec = time(NULL) + 1; /* 1, common data for test, no special meaning */
|
||||||
|
tts.tv_nsec = 0;
|
||||||
|
ret = mq_timedsend(queue, MQ_MSG, MQ_MSG_LEN, MQ_MSG_PRIO, &tts);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @tc.number SUB_KERNEL_IPC_MQ_0900
|
||||||
|
* @tc.name all send and all receive function test in thread and process
|
||||||
|
* @tc.desc [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(IpcMqApiTestSuite, testMqAllTwoThreadCom, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
mqd_t queue;
|
||||||
|
pthread_t tid;
|
||||||
|
unsigned int prio;
|
||||||
|
struct mq_attr getAttr = { 0 };
|
||||||
|
struct mq_attr setAttr = { 0 };
|
||||||
|
char qName[MQ_NAME_LEN];
|
||||||
|
char rMsg[MQ_RX_LEN];
|
||||||
|
|
||||||
|
ret = sprintf_s(qName, sizeof(qName), "testMqAllTwoThreadCom_%d", GetRandom(10000)); /* 10000, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, strlen(qName), ret);
|
||||||
|
setAttr.mq_msgsize = MQ_MSG_SIZE;
|
||||||
|
setAttr.mq_maxmsg = MQ_MAX_MSG;
|
||||||
|
queue = mq_open(qName, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &setAttr);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(queue, (mqd_t)-1, queue); /* -1, common data for test, no special meaning */
|
||||||
|
|
||||||
|
ret = pthread_create(&tid, NULL, PthreadAllCom, (void *)queue);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */
|
||||||
|
|
||||||
|
ret = mq_send(queue, MQ_MSG, MQ_MSG_LEN, MQ_MSG_PRIO);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ret = pthread_join(tid, NULL);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
|
||||||
|
ret = mq_getattr(queue, &getAttr);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ICUNIT_ASSERT_EQUAL(getAttr.mq_curmsgs, 1, getAttr.mq_curmsgs); /* 1, common data for test, no special meaning */
|
||||||
|
ret = mq_receive(queue, rMsg, getAttr.mq_msgsize, &prio);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(prio, MQ_MSG_PRIO, prio);
|
||||||
|
ret = strncmp(MQ_MSG, rMsg, MQ_MSG_LEN);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
|
||||||
|
ret = mq_close(queue);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ret = mq_unlink(qName);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* *
|
||||||
|
* @tc.number SUB_KERNEL_IPC_MQ_1200
|
||||||
|
* @tc.name mq_setattr set and clean mq_flags for O_NONBLOCK function test
|
||||||
|
* @tc.desc [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(IpcMqApiTestSuite, testMqSetGetAttr, Function | MediumTest | Level1)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
mqd_t queue;
|
||||||
|
struct mq_attr getAttr = { 0 };
|
||||||
|
struct mq_attr setAttr = { 0 };
|
||||||
|
char qName[MQ_NAME_LEN];
|
||||||
|
|
||||||
|
ret = sprintf_s(qName, sizeof(qName), "testMqFunction_%d", GetRandom(10000)); /* 10000, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, strlen(qName), ret);
|
||||||
|
memset_s(&setAttr, sizeof(setAttr), 0, sizeof(setAttr));
|
||||||
|
setAttr.mq_msgsize = MQ_MSG_SIZE;
|
||||||
|
setAttr.mq_maxmsg = MQ_MAX_MSG;
|
||||||
|
setAttr.mq_flags = O_NONBLOCK;
|
||||||
|
queue = mq_open(qName, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &setAttr);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(queue, (mqd_t)-1, queue); /* -1, common data for test, no special meaning */
|
||||||
|
|
||||||
|
memset_s(&getAttr, sizeof(getAttr), 0, sizeof(getAttr));
|
||||||
|
ret = mq_getattr(queue, &getAttr);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ret = (getAttr.mq_flags & O_NONBLOCK);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, O_NONBLOCK, ret);
|
||||||
|
|
||||||
|
setAttr.mq_flags &= ~O_NONBLOCK;
|
||||||
|
ret = mq_setattr(queue, &setAttr, NULL);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
|
||||||
|
ret = mq_getattr(queue, &getAttr);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ret = (getAttr.mq_flags & O_NONBLOCK);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ret = mq_close(queue);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
ret = mq_unlink(qName);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
RUN_TEST_SUITE(IpcMqApiTestSuite);
|
||||||
|
|
||||||
|
void IpcMqFuncTest(void)
|
||||||
|
{
|
||||||
|
RUN_ONE_TESTCASE(testMqOneLevelCom);
|
||||||
|
RUN_ONE_TESTCASE(testMqTimedOneLevelCom);
|
||||||
|
RUN_ONE_TESTCASE(testMqAllOneLevelCom001);
|
||||||
|
RUN_ONE_TESTCASE(testMqAllOneLevelCom002);
|
||||||
|
RUN_ONE_TESTCASE(testMqTwoThreadCom);
|
||||||
|
RUN_ONE_TESTCASE(testMqTimedTwoThreadCom);
|
||||||
|
RUN_ONE_TESTCASE(testMqAllTwoThreadCom);
|
||||||
|
RUN_ONE_TESTCASE(testMqSetGetAttr);
|
||||||
|
}
|
||||||
@@ -0,0 +1,139 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2023-2023 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 "xts_ipc.h"
|
||||||
|
|
||||||
|
LITE_TEST_SUIT(FUTEX, PthreadMutexApiTest, PthreadMutexApiTestSuite);
|
||||||
|
|
||||||
|
static BOOL PthreadMutexApiTestSuiteSetUp(void)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static BOOL PthreadMutexApiTestSuiteTearDown(void)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/********************************************* Test case dividing line ***********************************************/
|
||||||
|
|
||||||
|
struct PthreadMutexCond {
|
||||||
|
int loopNum;
|
||||||
|
int countMax;
|
||||||
|
int count;
|
||||||
|
int top;
|
||||||
|
int bottom;
|
||||||
|
pthread_cond_t notfull;
|
||||||
|
pthread_cond_t notempty;
|
||||||
|
pthread_mutex_t mutex;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct PthreadMutexCond g_st1;
|
||||||
|
|
||||||
|
void *PthreadProduce(void *arg)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
for (int i = 0; i < g_st1.loopNum; i++) {
|
||||||
|
ret = pthread_mutex_lock(&g_st1.mutex);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, POSIX_IPC_NO_ERROR, ret);
|
||||||
|
// check full
|
||||||
|
if ((g_st1.top + 1) % g_st1.countMax == g_st1.bottom) { /* 1, common data for test, no special meaning */
|
||||||
|
ret = pthread_cond_wait(&g_st1.notempty, &g_st1.mutex);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, POSIX_IPC_NO_ERROR, ret);
|
||||||
|
}
|
||||||
|
// Produce
|
||||||
|
g_st1.top = (g_st1.top + 1) % g_st1.countMax; /* 1, common data for test, no special meaning */
|
||||||
|
g_st1.count++;
|
||||||
|
|
||||||
|
ret = pthread_cond_signal(&g_st1.notempty);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, POSIX_IPC_NO_ERROR, ret);
|
||||||
|
ret = pthread_mutex_unlock(&g_st1.mutex);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, POSIX_IPC_NO_ERROR, ret);
|
||||||
|
usleep(10); /* 10, common data for test, no special meaning */
|
||||||
|
}
|
||||||
|
return arg;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *PthreadConsume(void *arg)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
for (int i = 0; i < g_st1.loopNum; i++) {
|
||||||
|
ret = pthread_mutex_lock(&g_st1.mutex);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, POSIX_IPC_NO_ERROR, ret);
|
||||||
|
// check empty
|
||||||
|
if (g_st1.top == g_st1.bottom) {
|
||||||
|
ret = pthread_cond_wait(&g_st1.notempty, &g_st1.mutex);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, POSIX_IPC_NO_ERROR, ret);
|
||||||
|
}
|
||||||
|
// Consume
|
||||||
|
g_st1.bottom = (g_st1.bottom + 1) % g_st1.countMax;
|
||||||
|
g_st1.count--;
|
||||||
|
|
||||||
|
ret = pthread_cond_signal(&g_st1.notempty);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, POSIX_IPC_NO_ERROR, ret);
|
||||||
|
ret = pthread_mutex_unlock(&g_st1.mutex);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, POSIX_IPC_NO_ERROR, ret);
|
||||||
|
|
||||||
|
usleep(10); /* 10, common data for test, no special meaning */
|
||||||
|
}
|
||||||
|
return arg;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number SUB_KERNEL_FUTEX_MUTEX_ALL_0300
|
||||||
|
* @tc.name test pthread_mutex with condition variable, produce and consume
|
||||||
|
* @tc.desc [C- SOFTWARE -0200]
|
||||||
|
*/
|
||||||
|
LITE_TEST_CASE(PthreadMutexApiTestSuite, testPthreadMutexCond, Function | MediumTest | Level3)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
pthread_t tid[2]; /* 2, common data for test, no special meaning */
|
||||||
|
|
||||||
|
g_st1.count = 0;
|
||||||
|
memset_s(tid, sizeof(tid), POSIX_IPC_NO_ERROR, sizeof(tid));
|
||||||
|
|
||||||
|
ret = pthread_create(&tid[0], NULL, PthreadProduce, NULL);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, POSIX_IPC_NO_ERROR, ret);
|
||||||
|
ret = pthread_create(&tid[1], NULL, PthreadConsume, NULL); /* 1, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, POSIX_IPC_NO_ERROR, ret);
|
||||||
|
ret = pthread_join(tid[0], NULL);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, POSIX_IPC_NO_ERROR, ret);
|
||||||
|
ret = pthread_join(tid[1], NULL); /* 1, common data for test, no special meaning */
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, POSIX_IPC_NO_ERROR, ret);
|
||||||
|
ICUNIT_ASSERT_EQUAL(g_st1.count, POSIX_IPC_NO_ERROR, g_st1.count);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
RUN_TEST_SUITE(PthreadMutexApiTestSuite);
|
||||||
|
|
||||||
|
void PosixFutexMutexTest(void)
|
||||||
|
{
|
||||||
|
RUN_ONE_TESTCASE(testPthreadMutexCond);
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user