diff options
author | Benjamin Walsh <benjamin.walsh@windriver.com> | 2015-09-28 15:53:04 -0400 |
---|---|---|
committer | Anas Nashif <anas.nashif@intel.com> | 2016-02-05 20:24:43 -0500 |
commit | 826edfc16b2615e8ee5f8fd0b06af39ded365a8e (patch) | |
tree | bd019266957c07d076dbc72afa9c7cb6bc5851df /misc | |
parent | 55afb68e83a3ae21ba1b0b4069c0da491db4b1f4 (diff) |
reboot: add reboot infrastructure
Add the REBOOT kconfig option, along with the sys_reboot() API.
This infrastructure is not enough to actually perform a reboot.
Architecture/platform code must be provided as well, in the form of a
sys_arch_reboot() function.
Change-Id: I5b2b15855ff06453f2764f3e3b3b7d6a4a078723
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
Diffstat (limited to 'misc')
-rw-r--r-- | misc/Kconfig | 8 | ||||
-rw-r--r-- | misc/Makefile | 1 | ||||
-rw-r--r-- | misc/reboot.c | 42 |
3 files changed, 51 insertions, 0 deletions
diff --git a/misc/Kconfig b/misc/Kconfig index 00cd1d146..8fa1a8cd1 100644 --- a/misc/Kconfig +++ b/misc/Kconfig @@ -260,3 +260,11 @@ config CPU_CLOCK_FREQ_MHZ endmenu +config REBOOT + bool "Reboot functionality" + default n + select SYSTEM_CLOCK_DISABLE + help + Enable the sys_reboot() API. Enabling this can drag in other subsystems + needed to perform a "safe" reboot (e.g. SYSTEM_CLOCK_DISABLE, to stop the + system clock before issuing a reset). diff --git a/misc/Makefile b/misc/Makefile index 635389621..cca7f4dee 100644 --- a/misc/Makefile +++ b/misc/Makefile @@ -1,4 +1,5 @@ obj-y = obj-$(CONFIG_PRINTK) += printk.o +obj-$(CONFIG_REBOOT) += reboot.o obj-y += generated/ obj-y += debug/ diff --git a/misc/reboot.c b/misc/reboot.c new file mode 100644 index 000000000..49576bbc2 --- /dev/null +++ b/misc/reboot.c @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2015 Wind River Systems, Inc. + * + * 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. + */ + +/** + * @file common target reboot functionality + * + * @details See misc/Kconfig and the reboot help for details. + */ + +#include <nanokernel.h> +#include <drivers/system_timer.h> +#include <misc/printk.h> +#include <misc/reboot.h> + +extern void sys_arch_reboot(int type); + +void sys_reboot(int type) +{ + (void)irq_lock(); + sys_clock_disable(); + + sys_arch_reboot(type); + + /* should never get here */ + printk("Failed to reboot: spinning endlessly...\n"); + for (;;) { + nano_cpu_idle(); + } +} |