diff --git a/tests/kernel/test_arm_runtime_nmi/Makefile b/tests/kernel/test_arm_runtime_nmi/Makefile new file mode 100644 index 00000000000..a1b9f6e80e3 --- /dev/null +++ b/tests/kernel/test_arm_runtime_nmi/Makefile @@ -0,0 +1,4 @@ +BOARD ?= qemu_cortex_m3 +CONF_FILE = prj.conf + +include $(ZEPHYR_BASE)/Makefile.inc diff --git a/tests/kernel/test_arm_runtime_nmi/README.txt b/tests/kernel/test_arm_runtime_nmi/README.txt new file mode 100644 index 00000000000..613c84d61c9 --- /dev/null +++ b/tests/kernel/test_arm_runtime_nmi/README.txt @@ -0,0 +1,45 @@ +Title: Test to verify the behavior of CONFIG_RUNTIME_NMI at runtime (ARM Only) + +Description: + +This test verifies the behavior of CONFIG_RUNTIME_NMI at runtime. Only for +ARM Cortex-M targets. + +--------------------------------------------------------------------------- + +Building and Running Project: + +This project outputs to the console. It can be built and executed on QEMU as +follows: + + make qemu + +--------------------------------------------------------------------------- + +Troubleshooting: + +Problems caused by out-dated project information can be addressed by +issuing one of the following commands then rebuilding the project: + + make clean # discard results of previous builds + # but keep existing configuration info +or + make pristine # discard results of previous builds + # and restore pre-defined configuration info + +--------------------------------------------------------------------------- + +Sample Output: + +Trigger NMI in 10s: 0 s +Trigger NMI in 10s: 1 s +Trigger NMI in 10s: 2 s +Trigger NMI in 10s: 3 s +Trigger NMI in 10s: 4 s +Trigger NMI in 10s: 5 s +Trigger NMI in 10s: 6 s +Trigger NMI in 10s: 7 s +Trigger NMI in 10s: 8 s +Trigger NMI in 10s: 9 s +NMI received (test_handler_isr)! Rebooting... +... diff --git a/tests/kernel/test_arm_runtime_nmi/prj.conf b/tests/kernel/test_arm_runtime_nmi/prj.conf new file mode 100644 index 00000000000..2a908641035 --- /dev/null +++ b/tests/kernel/test_arm_runtime_nmi/prj.conf @@ -0,0 +1 @@ +CONFIG_RUNTIME_NMI=y diff --git a/tests/kernel/test_arm_runtime_nmi/src/Makefile b/tests/kernel/test_arm_runtime_nmi/src/Makefile new file mode 100644 index 00000000000..2b356966312 --- /dev/null +++ b/tests/kernel/test_arm_runtime_nmi/src/Makefile @@ -0,0 +1,3 @@ +ccflags-y += -I${ZEPHYR_BASE}/tests/include + +obj-y = main.o diff --git a/tests/kernel/test_arm_runtime_nmi/src/main.c b/tests/kernel/test_arm_runtime_nmi/src/main.c new file mode 100644 index 00000000000..e09c87cb525 --- /dev/null +++ b/tests/kernel/test_arm_runtime_nmi/src/main.c @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2016 Linaro Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + /** + * @brief Test to verify the behavior of CONFIG_RUNTIME_NMI at runtime. + */ + +#include +#include +#include + +#include + +extern void _NmiHandlerSet(void (*pHandler)(void)); + +static void nmi_test_isr(void) +{ + printk("NMI received (test_handler_isr)! Rebooting...\n"); + /* ISR triggered correctly: test passed! */ + TC_END_RESULT(TC_PASS); + TC_END_REPORT(TC_PASS); +} + +void main(void) +{ + uint32_t i = 0; + + /* Configure the NMI isr */ + _NmiHandlerSet(nmi_test_isr); + + for (i = 0; i < 10; i++) { + printk("Trigger NMI in 10s: %d s\n", i); + k_sleep(1000); + } + + /* Trigger NMI: Should fire immediately */ + _ScbNmiPend(); +} diff --git a/tests/kernel/test_arm_runtime_nmi/testcase.ini b/tests/kernel/test_arm_runtime_nmi/testcase.ini new file mode 100644 index 00000000000..f3ce4f88bb1 --- /dev/null +++ b/tests/kernel/test_arm_runtime_nmi/testcase.ini @@ -0,0 +1,3 @@ +[test] +tags = core bat_commit +arch_whitelist = arm