#!/usr/bin/env python3 template = """.global {name} {name}: li a7, SYS_{name} ecall ret""" def genstub(syscall: str): return template.format(name=syscall) syscalls = [ "fork", "exit", "wait", "pipe", "read", "write", "close", "kill", "exec", "open", "mknod", "unlink", "fstat", "link", "mkdir", "chdir", "dup", "getpid", "sbrk", "sleep", "uptime", "trace", "halt", ] assembly = "\n\n".join(map(genstub, syscalls)) # TODO: Perhaps do some more specific assertions on the code here assert len(assembly) > 0, "No assembly code generated. Something is fishy" print("# generated by usys.py - do not edit\n") print('#include "kernel/syscall.h"\n') print(assembly)