summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Georgi <pgeorgi@google.com>2017-10-29 07:42:37 -0400
committerCommit Bot <commit-bot@chromium.org>2021-10-19 22:24:03 +0000
commitd9a7a641f1ba2763d46b996056a24574942be01d (patch)
treefb6cea8290f14b2af2b63661f797061895708d0f
parenta42e372c414e09d79e974bebd47e553b16ec0bff (diff)
downloadchrome-ec-d9a7a641f1ba2763d46b996056a24574942be01d.tar.gz
Mark reset and panic functions as noreturn
gcc 6.3 (as provided by coreboot-sdk) needs that to know which code paths end early. Also add a loop after the command that is "supposed" to reset the machine so that the compiler believes it (and in case that assumption fails). BRANCH=none BUG=b:65441143 TEST=none Change-Id: Idb87253ec7880d66ffec30d75f4d007f02f63aab Signed-off-by: Patrick Georgi <pgeorgi@google.com> Reviewed-on: https://chromium-review.googlesource.com/742916 Commit-Ready: Patrick Georgi <pgeorgi@chromium.org> Tested-by: Patrick Georgi <pgeorgi@chromium.org> Reviewed-by: Stefan Reinauer <reinauer@chromium.org> (cherry picked from commit 887e3962ca19cc7e8c3c474f8c82b4240eb63416) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3229786 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-by: Andrey Pronin <apronin@chromium.org> Tested-by: Mary Ruthven <mruthven@chromium.org> Commit-Queue: Mary Ruthven <mruthven@chromium.org>
-rw-r--r--chip/g/system.c3
-rw-r--r--chip/host/reboot.c3
-rw-r--r--chip/host/reboot.h1
-rw-r--r--chip/mec1322/system.c1
-rw-r--r--include/panic.h4
-rw-r--r--include/system.h2
6 files changed, 10 insertions, 4 deletions
diff --git a/chip/g/system.c b/chip/g/system.c
index da14c3fbed..8e7b0d03cb 100644
--- a/chip/g/system.c
+++ b/chip/g/system.c
@@ -170,7 +170,8 @@ void system_reset(int flags)
#endif /* ^^^^^^^ CHIP_FAMILY_CR50 Not defined */
/* Wait for reboot; should never return */
- asm("wfi");
+ while (1)
+ asm("wfi");
}
const char *system_get_chip_vendor(void)
diff --git a/chip/host/reboot.c b/chip/host/reboot.c
index 526276aede..7fdb6f7f8e 100644
--- a/chip/host/reboot.c
+++ b/chip/host/reboot.c
@@ -12,9 +12,12 @@
#include "reboot.h"
#include "test_util.h"
+__attribute__((noreturn))
void emulator_reboot(void)
{
char *argv[] = {strdup(__get_prog_name()), NULL};
emulator_flush();
execv(__get_prog_name(), argv);
+ while (1)
+ ;
}
diff --git a/chip/host/reboot.h b/chip/host/reboot.h
index e391866497..113569bb9b 100644
--- a/chip/host/reboot.h
+++ b/chip/host/reboot.h
@@ -8,6 +8,7 @@
#ifndef __CROS_EC_REBOOT_H
#define __CROS_EC_REBOOT_H
+__attribute__((noreturn))
void emulator_reboot(void);
#endif
diff --git a/chip/mec1322/system.c b/chip/mec1322/system.c
index a3262944ac..50f2ed973a 100644
--- a/chip/mec1322/system.c
+++ b/chip/mec1322/system.c
@@ -96,6 +96,7 @@ void chip_save_reset_flags(int flags)
MEC1322_VBAT_RAM(HIBDATA_INDEX_SAVED_RESET_FLAGS) = flags;
}
+__attribute__((noreturn))
void _system_reset(int flags, int wake_from_hibernate)
{
uint32_t save_flags = 0;
diff --git a/include/panic.h b/include/panic.h
index 3a3bb7db9b..f5e179acf5 100644
--- a/include/panic.h
+++ b/include/panic.h
@@ -135,12 +135,12 @@ void panic_assert_fail(const char *msg, const char *func, const char *fname,
*
* @param msg Panic message
*/
-void panic(const char *msg);
+void panic(const char *msg) __attribute__((noreturn));
/**
* Display a default message and reset
*/
-void panic_reboot(void);
+void panic_reboot(void) __attribute__((noreturn));
#ifdef CONFIG_SOFTWARE_PANIC
/**
diff --git a/include/system.h b/include/system.h
index 7c04387a09..aed803e54d 100644
--- a/include/system.h
+++ b/include/system.h
@@ -231,7 +231,7 @@ const char *system_get_build_info(void);
*
* @param flags Reset flags; see SYSTEM_RESET_* above.
*/
-void system_reset(int flags);
+void system_reset(int flags) __attribute__((noreturn));
/**
* Set a scratchpad register to the specified value.