Sanity checking when generating usys.S

This commit is contained in:
Imbus 2025-01-15 13:14:02 +01:00
parent 5a3fa8f6af
commit c9665ce5bd
2 changed files with 23 additions and 0 deletions

View file

@ -6,6 +6,9 @@ struct stat;
/** /**
* System calls * System calls
*
* Note that none of these calls are implemented in C. They are implemented in assembly in [usys.S](./usys.S). This file
* is in turn generated by the [usys.py](./usys.py) script during the build.
*/ */
/** Create a child process */ /** Create a child process */

View file

@ -42,6 +42,26 @@ assembly = "\n\n".join(map(genstub, syscalls))
# TODO: Perhaps do some more specific assertions on the code here # TODO: Perhaps do some more specific assertions on the code here
assert len(assembly) > 0, "No assembly code generated. Something is fishy" assert len(assembly) > 0, "No assembly code generated. Something is fishy"
with open("kernel/syscall.h", "r") as sfile:
lines = list(filter(lambda x: x.startswith("#define"), sfile.readlines()))
header_calls = set([line.split()[1] for line in lines])
calls = set(["SYS_" + call for call in syscalls])
if header_calls == calls:
print("All items match in both sets.")
else:
missing_in_calls = header_calls - calls
missing_in_header_calls = calls - header_calls
if missing_in_calls:
print("These items are in header_calls but not in calls:", missing_in_calls)
if missing_in_header_calls:
print(
"These items are in calls but not in header_calls:",
missing_in_header_calls,
)
print("# generated by usys.py - do not edit\n") print("# generated by usys.py - do not edit\n")
print('#include "kernel/syscall.h"\n') print('#include "kernel/syscall.h"\n')
print(assembly) print(assembly)