2015-04-04 22:08:32 +08:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
import sys
|
|
|
|
|
2015-04-27 20:43:45 +08:00
|
|
|
from elftools.elf.elffile import ELFFile
|
|
|
|
|
2015-04-04 22:08:32 +08:00
|
|
|
|
|
|
|
services = [
|
|
|
|
("syscalls", [
|
2015-05-02 23:41:49 +08:00
|
|
|
("now_init", "now_init"),
|
|
|
|
("now_save", "now_save"),
|
2015-05-08 16:20:12 +08:00
|
|
|
|
2015-04-29 12:58:37 +08:00
|
|
|
("watchdog_set", "watchdog_set"),
|
|
|
|
("watchdog_clear", "watchdog_clear"),
|
2015-05-08 16:20:12 +08:00
|
|
|
|
|
|
|
("rpc", "rpc"),
|
|
|
|
|
2015-04-04 22:08:32 +08:00
|
|
|
("rtio_get_counter", "rtio_get_counter"),
|
2015-05-08 16:20:12 +08:00
|
|
|
|
|
|
|
("ttl_set_o", "ttl_set_o"),
|
|
|
|
("ttl_set_oe", "ttl_set_oe"),
|
|
|
|
("ttl_set_sensitivity", "ttl_set_sensitivity"),
|
|
|
|
("ttl_get", "ttl_get"),
|
|
|
|
|
2015-05-08 14:44:39 +08:00
|
|
|
("dds_init", "dds_init"),
|
2015-05-08 16:51:54 +08:00
|
|
|
("dds_batch_enter", "dds_batch_enter"),
|
|
|
|
("dds_batch_exit", "dds_batch_exit"),
|
2015-05-08 14:44:39 +08:00
|
|
|
("dds_set", "dds_set"),
|
2015-04-04 22:08:32 +08:00
|
|
|
]),
|
2015-05-08 16:20:12 +08:00
|
|
|
|
2015-04-04 22:08:32 +08:00
|
|
|
("eh", [
|
|
|
|
("setjmp", "exception_setjmp"),
|
|
|
|
("push", "exception_push"),
|
|
|
|
("pop", "exception_pop"),
|
|
|
|
("getid", "exception_getid"),
|
|
|
|
("raise", "exception_raise"),
|
|
|
|
])
|
|
|
|
]
|
|
|
|
|
|
|
|
|
2015-04-27 20:43:45 +08:00
|
|
|
def print_service_table(ksupport_elf_filename):
|
2015-04-04 22:08:32 +08:00
|
|
|
with open(ksupport_elf_filename, "rb") as f:
|
|
|
|
elf = ELFFile(f)
|
|
|
|
symtab = elf.get_section_by_name(b".symtab")
|
|
|
|
symbols = {symbol.name: symbol.entry.st_value
|
|
|
|
for symbol in symtab.iter_symbols()}
|
|
|
|
for name, contents in services:
|
|
|
|
print("static const struct symbol {}[] = {{".format(name))
|
|
|
|
for name, value in contents:
|
|
|
|
print(" {{\"{}\", (void *)0x{:08x}}},"
|
|
|
|
.format(name, symbols[bytes(value, "ascii")]))
|
|
|
|
print(" {NULL, NULL}")
|
|
|
|
print("};")
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
2015-04-27 20:43:45 +08:00
|
|
|
if len(sys.argv) == 2:
|
|
|
|
print_service_table(sys.argv[1])
|
2015-04-04 22:08:32 +08:00
|
|
|
else:
|
|
|
|
print("Incorrect number of command line arguments")
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|