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 <andrew.p.boie@intel.com>
This commit is contained in:
Andrew Boie 2020-05-29 13:22:20 -07:00 committed by Carles Cufí
commit 455e178b3b

View file

@ -77,25 +77,28 @@ from collections import OrderedDict
# #
# - The second item is a boolean indicating whether it is permissible for # - The second item is a boolean indicating whether it is permissible for
# the object to be located in user-accessible memory. # the object to be located in user-accessible memory.
#
# - The third items is a boolean indicating whether this item can be
# dynamically allocated with k_object_alloc()
# Regular dictionaries are ordered only with Python 3.6 and # Regular dictionaries are ordered only with Python 3.6 and
# above. Good summary and pointers to official documents at: # above. Good summary and pointers to official documents at:
# https://stackoverflow.com/questions/39980323/are-dictionaries-ordered-in-python-3-6 # https://stackoverflow.com/questions/39980323/are-dictionaries-ordered-in-python-3-6
kobjects = OrderedDict([ kobjects = OrderedDict([
("k_mem_slab", (None, False)), ("k_mem_slab", (None, False, True)),
("k_msgq", (None, False)), ("k_msgq", (None, False, True)),
("k_mutex", (None, False)), ("k_mutex", (None, False, True)),
("k_pipe", (None, False)), ("k_pipe", (None, False, True)),
("k_queue", (None, False)), ("k_queue", (None, False, True)),
("k_poll_signal", (None, False)), ("k_poll_signal", (None, False, True)),
("k_sem", (None, False)), ("k_sem", (None, False, True)),
("k_stack", (None, False)), ("k_stack", (None, False, True)),
("k_thread", (None, False)), ("k_thread", (None, False, True)), # But see #
("k_timer", (None, False)), ("k_timer", (None, False, True)),
("z_thread_stack_element", (None, False)), ("z_thread_stack_element", (None, False, False)),
("device", (None, False)), ("device", (None, False, False)),
("sys_mutex", (None, True)), ("sys_mutex", (None, True, False)),
("k_futex", (None, True)) ("k_futex", (None, True, False))
]) ])
def kobject_to_enum(kobj): def kobject_to_enum(kobj):
@ -609,7 +612,7 @@ def find_kobjects(elf, syms):
if ko.type_obj.api: if ko.type_obj.api:
continue continue
_, user_ram_allowed = kobjects[ko.type_obj.name] _, user_ram_allowed, _ = kobjects[ko.type_obj.name]
if not user_ram_allowed and app_smem_start <= addr < app_smem_end: if not user_ram_allowed and app_smem_start <= addr < app_smem_end:
debug("object '%s' found in invalid location %s" debug("object '%s' found in invalid location %s"
% (ko.type_obj.name, hex(addr))) % (ko.type_obj.name, hex(addr)))
@ -853,7 +856,7 @@ def write_validation_output(fp):
def write_kobj_types_output(fp): def write_kobj_types_output(fp):
fp.write("/* Core kernel objects */\n") fp.write("/* Core kernel objects */\n")
for kobj, obj_info in kobjects.items(): for kobj, obj_info in kobjects.items():
dep, _ = obj_info dep, _, _ = obj_info
if kobj == "device": if kobj == "device":
continue continue
@ -874,7 +877,7 @@ def write_kobj_types_output(fp):
def write_kobj_otype_output(fp): def write_kobj_otype_output(fp):
fp.write("/* Core kernel objects */\n") fp.write("/* Core kernel objects */\n")
for kobj, obj_info in kobjects.items(): for kobj, obj_info in kobjects.items():
dep, _ = obj_info dep, _, _ = obj_info
if kobj == "device": if kobj == "device":
continue continue
@ -898,10 +901,9 @@ def write_kobj_otype_output(fp):
def write_kobj_size_output(fp): def write_kobj_size_output(fp):
fp.write("/* Non device/stack objects */\n") fp.write("/* Non device/stack objects */\n")
for kobj, obj_info in kobjects.items(): for kobj, obj_info in kobjects.items():
dep, _ = obj_info dep, _, alloc = obj_info
# device handled by default case. Stacks are not currently handled,
# if they eventually are it will be a special case. if not alloc:
if kobj in {"device", STACK_TYPE}:
continue continue
if dep: if dep: