Skip to content

Commit 455e178

Browse files
Andrew Boiecarlescufi
authored andcommitted
scripts: gen_kobject_list: generalize obj alloc
Instead of handling this ad hoc, generalize which kobject types can be allocated. Signed-off-by: Andrew Boie <[email protected]>
1 parent 378024c commit 455e178

File tree

1 file changed

+23
-21
lines changed

1 file changed

+23
-21
lines changed

scripts/gen_kobject_list.py

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -77,25 +77,28 @@
7777
#
7878
# - The second item is a boolean indicating whether it is permissible for
7979
# the object to be located in user-accessible memory.
80+
#
81+
# - The third items is a boolean indicating whether this item can be
82+
# dynamically allocated with k_object_alloc()
8083

8184
# Regular dictionaries are ordered only with Python 3.6 and
8285
# above. Good summary and pointers to official documents at:
8386
# https://stackoverflow.com/questions/39980323/are-dictionaries-ordered-in-python-3-6
8487
kobjects = OrderedDict([
85-
("k_mem_slab", (None, False)),
86-
("k_msgq", (None, False)),
87-
("k_mutex", (None, False)),
88-
("k_pipe", (None, False)),
89-
("k_queue", (None, False)),
90-
("k_poll_signal", (None, False)),
91-
("k_sem", (None, False)),
92-
("k_stack", (None, False)),
93-
("k_thread", (None, False)),
94-
("k_timer", (None, False)),
95-
("z_thread_stack_element", (None, False)),
96-
("device", (None, False)),
97-
("sys_mutex", (None, True)),
98-
("k_futex", (None, True))
88+
("k_mem_slab", (None, False, True)),
89+
("k_msgq", (None, False, True)),
90+
("k_mutex", (None, False, True)),
91+
("k_pipe", (None, False, True)),
92+
("k_queue", (None, False, True)),
93+
("k_poll_signal", (None, False, True)),
94+
("k_sem", (None, False, True)),
95+
("k_stack", (None, False, True)),
96+
("k_thread", (None, False, True)), # But see #
97+
("k_timer", (None, False, True)),
98+
("z_thread_stack_element", (None, False, False)),
99+
("device", (None, False, False)),
100+
("sys_mutex", (None, True, False)),
101+
("k_futex", (None, True, False))
99102
])
100103

101104
def kobject_to_enum(kobj):
@@ -609,7 +612,7 @@ def find_kobjects(elf, syms):
609612
if ko.type_obj.api:
610613
continue
611614

612-
_, user_ram_allowed = kobjects[ko.type_obj.name]
615+
_, user_ram_allowed, _ = kobjects[ko.type_obj.name]
613616
if not user_ram_allowed and app_smem_start <= addr < app_smem_end:
614617
debug("object '%s' found in invalid location %s"
615618
% (ko.type_obj.name, hex(addr)))
@@ -853,7 +856,7 @@ def write_validation_output(fp):
853856
def write_kobj_types_output(fp):
854857
fp.write("/* Core kernel objects */\n")
855858
for kobj, obj_info in kobjects.items():
856-
dep, _ = obj_info
859+
dep, _, _ = obj_info
857860
if kobj == "device":
858861
continue
859862

@@ -874,7 +877,7 @@ def write_kobj_types_output(fp):
874877
def write_kobj_otype_output(fp):
875878
fp.write("/* Core kernel objects */\n")
876879
for kobj, obj_info in kobjects.items():
877-
dep, _ = obj_info
880+
dep, _, _ = obj_info
878881
if kobj == "device":
879882
continue
880883

@@ -898,10 +901,9 @@ def write_kobj_otype_output(fp):
898901
def write_kobj_size_output(fp):
899902
fp.write("/* Non device/stack objects */\n")
900903
for kobj, obj_info in kobjects.items():
901-
dep, _ = obj_info
902-
# device handled by default case. Stacks are not currently handled,
903-
# if they eventually are it will be a special case.
904-
if kobj in {"device", STACK_TYPE}:
904+
dep, _, alloc = obj_info
905+
906+
if not alloc:
905907
continue
906908

907909
if dep:

0 commit comments

Comments
 (0)