Commit fc1071d9 authored by Vincenzo Frascino's avatar Vincenzo Frascino Committed by Anas Nashif
Browse files

tests/kernel: verify RUNTIME_NMI at runtime



This patch introduces a test that verifies the behavior of
CONFIG_RUNTIME_NMI at runtime.

The test is meant to be only for ARM Cortex-M targets.

Change-Id: I805a88e67fe47d396ac9e29e1275e5452a4b8a36
Signed-off-by: default avatarVincenzo Frascino <vincenzo.frascino@linaro.org>
parent aae7ac07
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
BOARD ?= qemu_cortex_m3
CONF_FILE = prj.conf

include $(ZEPHYR_BASE)/Makefile.inc
+45 −0
Original line number Diff line number Diff line
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...
...
+1 −0
Original line number Diff line number Diff line
CONFIG_RUNTIME_NMI=y
+3 −0
Original line number Diff line number Diff line
ccflags-y += -I${ZEPHYR_BASE}/tests/include

obj-y = main.o
+51 −0
Original line number Diff line number Diff line
/*
 * 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 <zephyr.h>
#include <misc/printk.h>
#include <misc/reboot.h>

#include <tc_util.h>

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();
}
Loading