diff --git a/include/toolchain/common.h b/include/toolchain/common.h index 0df20ee2de9..4ec2f908857 100644 --- a/include/toolchain/common.h +++ b/include/toolchain/common.h @@ -132,11 +132,17 @@ #define __syscall #endif /* #ifndef ZTEST_UNITTEST */ -/* Used as a sentinel by parse_syscalls.py to identify what API structs - * define driver subsystems. +/* Definitions for struct declaration tags. These are sentinel values used by + * parse_syscalls.py to gather a list of names of struct declarations that + * have these tags applied for them. */ + +/* Indicates this is a driver subsystem */ #define __subsystem +/* Indicates this is a network socket object */ +#define __net_socket + #ifndef BUILD_ASSERT /* Compile-time assertion that makes the build to fail. * Common implementation swallows the message. diff --git a/scripts/gen_kobject_list.py b/scripts/gen_kobject_list.py index 54a4f0da098..01574b074d9 100755 --- a/scripts/gen_kobject_list.py +++ b/scripts/gen_kobject_list.py @@ -80,6 +80,10 @@ from collections import OrderedDict # # - The third items is a boolean indicating whether this item can be # dynamically allocated with k_object_alloc() +# +# Key names in all caps do not correspond to a specific data type but instead +# indicate that objects of its type are of a family of compatible data +# structures # Regular dictionaries are ordered only with Python 3.6 and # above. Good summary and pointers to official documents at: @@ -97,6 +101,7 @@ kobjects = OrderedDict([ ("k_timer", (None, False, True)), ("z_thread_stack_element", (None, False, False)), ("device", (None, False, False)), + ("NET_SOCKET", (None, False, False)), ("sys_mutex", (None, True, False)), ("k_futex", (None, True, False)) ]) @@ -118,6 +123,9 @@ subsystems = [ #}; ] +# Names of all structs tagged with __net_socket, found by parse_syscalls.py +net_sockets = [ ] + def subsystem_to_enum(subsys): return "K_OBJ_DRIVER_" + subsys[:-11].upper() @@ -402,6 +410,8 @@ def analyze_die_struct(die): type_env[offset] = KobjectType(offset, name, size) elif name in subsystems: type_env[offset] = KobjectType(offset, name, size, api=True) + elif name in net_sockets: + type_env[offset] = KobjectType(offset, "NET_SOCKET", size) else: at = AggregateType(offset, name, size) type_env[offset] = at @@ -919,6 +929,7 @@ def parse_subsystems_list_file(path): with open(path, "r") as fp: subsys_list = json.load(fp) subsystems.extend(subsys_list["__subsystem"]) + net_sockets.extend(subsys_list["__net_socket"]) def parse_args(): global args diff --git a/scripts/parse_syscalls.py b/scripts/parse_syscalls.py index f3bddefc349..e00474fe71b 100644 --- a/scripts/parse_syscalls.py +++ b/scripts/parse_syscalls.py @@ -40,7 +40,7 @@ __syscall\s+ # __syscall attribute, must be first [)] # Closing parenthesis ''', regex_flags) -struct_tags = ["__subsystem"] +struct_tags = ["__subsystem", "__net_socket"] tagged_struct_decl_template = r''' %s\s+ # tag, must be first