aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2017-07-02 14:29:16 -0400
committerKevin O'Connor <kevin@koconnor.net>2017-07-04 12:49:58 -0400
commit09140a51d560372bb7e77297f7a2807e717167a0 (patch)
tree7f3650141ced47961d3e93e4ff6fab4019b71195
parentcf662b842b10c92ab525633c35af659756006306 (diff)
downloadkutter-09140a51d560372bb7e77297f7a2807e717167a0.tar.gz
kutter-09140a51d560372bb7e77297f7a2807e717167a0.tar.xz
kutter-09140a51d560372bb7e77297f7a2807e717167a0.zip
sched: Pass shutdown reason code via longjmp() parameter
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
-rw-r--r--scripts/buildcommands.py6
-rw-r--r--src/sched.c10
2 files changed, 9 insertions, 7 deletions
diff --git a/scripts/buildcommands.py b/scripts/buildcommands.py
index 93c0eb37..0abc0e33 100644
--- a/scripts/buildcommands.py
+++ b/scripts/buildcommands.py
@@ -102,11 +102,13 @@ ctr_lookup_output(const char *str)
return fmt % ("".join(encoder_defs).strip(), "".join(encoder_code).strip(),
"".join(output_code).strip())
+STATIC_STRING_MIN = 2
+
def build_static_strings(static_strings):
code = []
for i, s in enumerate(static_strings):
code.append(' if (__builtin_strcmp(str, "%s") == 0)\n'
- ' return %d;\n' % (s, i))
+ ' return %d;\n' % (s, i + STATIC_STRING_MIN))
fmt = """
uint8_t __always_inline
ctr_lookup_static_string(const char *str)
@@ -187,7 +189,7 @@ def build_identify(cmd_by_id, msg_to_id, responses, static_strings
data['messages'] = messages
data['commands'] = sorted(cmd_by_id.keys())
data['responses'] = sorted(responses)
- data['static_strings'] = { i: static_strings[i]
+ data['static_strings'] = { i + STATIC_STRING_MIN: static_strings[i]
for i in range(len(static_strings)) }
data['config'] = constants
data['version'] = version
diff --git a/src/sched.c b/src/sched.c
index 542e3747..8fee61f2 100644
--- a/src/sched.c
+++ b/src/sched.c
@@ -205,9 +205,11 @@ sched_clear_shutdown(void)
// Invoke all shutdown functions (as declared by DECL_SHUTDOWN)
static void
-run_shutdown(void)
+run_shutdown(int reason)
{
uint32_t cur = timer_read_time();
+ if (!shutdown_status)
+ shutdown_reason = reason;
shutdown_status = 2;
extern void ctr_run_shutdownfuncs(void);
ctr_run_shutdownfuncs();
@@ -239,9 +241,7 @@ void
sched_shutdown(uint_fast8_t reason)
{
irq_disable();
- if (!shutdown_status)
- shutdown_reason = reason;
- longjmp(shutdown_jmp, 1);
+ longjmp(shutdown_jmp, reason);
}
@@ -261,7 +261,7 @@ sched_main(void)
int ret = setjmp(shutdown_jmp);
if (ret)
- run_shutdown();
+ run_shutdown(ret);
for (;;)
ctr_run_taskfuncs();