Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/syscall_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ static inline int z_obj_validation_check(struct z_object *ko,
#define Z_SYSCALL_SPECIFIC_DRIVER(_device, _dtype, _init_fn) \
({ \
struct device *_dev = (struct device *)_device; \
Z_SYSCALL_OBJ(_dev, _dtype) || \
Z_SYSCALL_OBJ(_dev, _dtype) && \
Z_SYSCALL_VERIFY_MSG(_dev->config->init == _init_fn, \
"init function mismatch"); \
})
Expand Down
14 changes: 8 additions & 6 deletions scripts/gen_kobject_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,18 @@ def kobject_to_enum(kobj):

return "K_OBJ_%s" % name.upper()

subsystems = [
subsystems = {
# Editing the list is deprecated, add the __subsystem sentinal to your driver
# api declaration instead. e.x.
#
# __subsystem struct my_driver_api {
# ....
#};
]
}

def subsystem_to_enum(subsys):
# Map from extended subsystem to base subsystem if different
subsys = subsystems[subsys]
return "K_OBJ_DRIVER_" + subsys[:-11].upper()

# --- debug stuff ---
Expand Down Expand Up @@ -839,7 +841,7 @@ def write_validation_output(fp):
Z_SYSCALL_DRIVER_OP(ptr, driver_lower_case##_driver_api, op))
""")

for subsystem in subsystems:
for subsystem in set(subsystems.values()):
subsystem = subsystem.replace("_driver_api", "")

fp.write(driver_macro_tpl % {
Expand All @@ -866,7 +868,7 @@ def write_kobj_types_output(fp):
fp.write("#endif\n")

fp.write("/* Driver subsystems */\n")
for subsystem in subsystems:
for subsystem in set(subsystems.values()):
subsystem = subsystem.replace("_driver_api", "").upper()
fp.write("K_OBJ_DRIVER_%s,\n" % subsystem)

Expand All @@ -887,7 +889,7 @@ def write_kobj_otype_output(fp):
fp.write("#endif\n")

fp.write("/* Driver subsystems */\n")
for subsystem in subsystems:
for subsystem in set(subsystems.values()):
subsystem = subsystem.replace("_driver_api", "")
fp.write('case K_OBJ_DRIVER_%s: ret = "%s driver"; break;\n' % (
subsystem.upper(),
Expand Down Expand Up @@ -916,7 +918,7 @@ def write_kobj_size_output(fp):
def parse_subsystems_list_file(path):
with open(path, "r") as fp:
subsys_list = json.load(fp)
subsystems.extend(subsys_list)
subsystems.update(subsys_list)

def parse_args():
global args
Expand Down
17 changes: 10 additions & 7 deletions scripts/parse_syscalls.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,16 @@
''', re.MULTILINE | re.VERBOSE)

subsys_regex = re.compile(r'''
__subsystem\s+ # __subsystem attribute, must be first
struct\s+ # struct keyword is next
([^{]+) # name of subsystem
__subsystem # __subsystem attribute, must be first
(/\*(?P<base>\w+)\*/)? # optional base subsystem for extensions
\s+struct\s+ # struct keyword is next
(?P<name>[^{]+) # name of subsystem
[{] # Open curly bracket
''', re.MULTILINE | re.VERBOSE)

def analyze_headers(multiple_directories):
syscall_ret = []
subsys_ret = []
subsys_ret = {}

for base_path in multiple_directories:
for root, dirs, files in os.walk(base_path, topdown=True):
Expand All @@ -63,14 +64,16 @@ def analyze_headers(multiple_directories):
try:
syscall_result = [(mo.groups(), fn)
for mo in syscall_regex.finditer(contents)]
subsys_result = [mo.groups()[0].strip()
for mo in subsys_regex.finditer(contents)]
subsys_result = {}
for mo in subsys_regex.finditer(contents):
subsys_name = mo.group('name').strip()
subsys_result[subsys_name] = mo.group('base') or subsys_name
except Exception:
sys.stderr.write("While parsing %s\n" % fn)
raise

syscall_ret.extend(syscall_result)
subsys_ret.extend(subsys_result)
subsys_ret.update(subsys_result)

return syscall_ret, subsys_ret

Expand Down