aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2017-05-26 09:14:26 -0400
committerKevin O'Connor <kevin@koconnor.net>2017-05-26 12:39:34 -0400
commita82e949c00aceaedd9d9a76ddcc3c88c9cad3d80 (patch)
tree685af9ff540b0407cfb0f96664fc3dccbc160152 /scripts
parentca9756413f2793279b5ba1c1ecf274ce734b2087 (diff)
downloadkutter-a82e949c00aceaedd9d9a76ddcc3c88c9cad3d80.tar.gz
kutter-a82e949c00aceaedd9d9a76ddcc3c88c9cad3d80.tar.xz
kutter-a82e949c00aceaedd9d9a76ddcc3c88c9cad3d80.zip
build: Use compile_time_request system for init, tasks, and shutdown
Avoid using linker magic to define the init, task, and shutdown functions. Instead, use the compile_time_request system. This simplifies the build and produces more efficient code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/buildcommands.py28
-rwxr-xr-xscripts/checkstack.py9
2 files changed, 27 insertions, 10 deletions
diff --git a/scripts/buildcommands.py b/scripts/buildcommands.py
index 54a01caa..3935fa63 100644
--- a/scripts/buildcommands.py
+++ b/scripts/buildcommands.py
@@ -13,6 +13,7 @@ import msgproto
FILEHEADER = """
/* DO NOT EDIT! This is an autogenerated file. See scripts/buildcommands.py. */
+#include "board/irq.h"
#include "board/pgm.h"
#include "command.h"
#include "compiler.h"
@@ -119,6 +120,23 @@ ctr_lookup_static_string(const char *str)
"""
return fmt % ("".join(code).strip(),)
+def build_call_lists(call_lists):
+ code = []
+ for funcname, funcs in call_lists.items():
+ func_code = [' extern void %s(void);\n %s();' % (f, f)
+ for f in funcs]
+ if funcname == 'ctr_run_taskfuncs':
+ func_code = [' irq_poll();\n' + fc for fc in func_code]
+ fmt = """
+void
+%s(void)
+{
+ %s
+}
+"""
+ code.append(fmt % (funcname, "\n".join(func_code).strip()))
+ return "".join(code)
+
def build_param_types(all_param_types):
sorted_param_types = sorted([(i, a) for a, i in all_param_types.items()])
params = ['']
@@ -271,6 +289,7 @@ def main():
encoders = []
static_strings = []
constants = {}
+ call_lists = {'ctr_run_initfuncs': []}
# Parse request file
f = open(incmdfile, 'rb')
data = f.read()
@@ -314,6 +333,10 @@ def main():
if name in constants and constants[name] != value:
error("Conflicting definition for constant '%s'" % name)
constants[name] = value
+ elif cmd == '_DECL_CALLLIST':
+ funcname, callname = parts[1:]
+ cl = call_lists.setdefault(funcname, [])
+ cl.append(callname)
else:
error("Unknown build time command '%s'" % cmd)
# Create unique ids for each message type
@@ -328,6 +351,7 @@ def main():
all_param_types = {}
parsercode = build_encoders(encoders, msg_to_id, all_param_types)
static_strings_code = build_static_strings(static_strings)
+ call_lists_code = build_call_lists(call_lists)
# Create command definitions
cmd_by_id = dict((msg_to_id[messages_by_name.get(msgname, msgname)], cmd)
for msgname, cmd in commands.items())
@@ -342,8 +366,8 @@ def main():
, static_strings, constants, version)
# Write output
f = open(outcfile, 'wb')
- f.write(FILEHEADER + paramcode + parsercode + static_strings_code
- + cmdcode + icode)
+ f.write(FILEHEADER + call_lists_code + static_strings_code
+ + paramcode + parsercode + cmdcode + icode)
f.close()
# Write data dictionary
diff --git a/scripts/checkstack.py b/scripts/checkstack.py
index 07d88176..34314218 100755
--- a/scripts/checkstack.py
+++ b/scripts/checkstack.py
@@ -191,16 +191,9 @@ def main():
for info in funcs.values():
funcnameroot = info.funcname.split('.')[0]
funcsbyname[funcnameroot] = info
- mainfunc = funcsbyname.get('sched_main')
- cmdfunc = funcsbyname.get('command_task')
+ cmdfunc = funcsbyname.get('sched_main')
eventfunc = funcsbyname.get('__vector_13', funcsbyname.get('__vector_17'))
for funcnameroot, info in funcsbyname.items():
- if (funcnameroot.startswith('_DECL_taskfuncs_')
- or funcnameroot.startswith('_DECL_initfuncs_')
- or funcnameroot.startswith('_DECL_shutdownfuncs_')):
- funcname = funcnameroot[funcnameroot.index('_', 7)+1:]
- f = funcsbyname[funcname]
- mainfunc.noteCall(0, f.funcaddr, mainfunc.basic_stack_usage + 2)
if funcnameroot.startswith('parser_'):
f = funcsbyname.get(funcnameroot[7:])
if f is not None: