userspace: generate list of kernel object sizes
This used to be done by hand but can easily be generated like we do other switch statements based on object type. Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
parent
f3bee951b1
commit
47fa8eb98c
3 changed files with 21 additions and 17 deletions
|
@ -7,6 +7,7 @@ function(gen_kobj gen_dir_out)
|
|||
|
||||
set(KOBJ_TYPES ${gen_dir}/kobj-types-enum.h)
|
||||
set(KOBJ_OTYPE ${gen_dir}/otype-to-str.h)
|
||||
set(KOBJ_SIZE ${gen_dir}/otype-to-size.h)
|
||||
|
||||
file(MAKE_DIRECTORY ${gen_dir})
|
||||
|
||||
|
@ -17,6 +18,7 @@ function(gen_kobj gen_dir_out)
|
|||
$ENV{ZEPHYR_BASE}/scripts/gen_kobject_list.py
|
||||
--kobj-types-output ${KOBJ_TYPES}
|
||||
--kobj-otype-output ${KOBJ_OTYPE}
|
||||
--kobj-size-output ${KOBJ_SIZE}
|
||||
$<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:--verbose>
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
|
|
|
@ -80,26 +80,10 @@ static sys_dlist_t obj_list = SYS_DLIST_STATIC_INIT(&obj_list);
|
|||
* and obj_list.
|
||||
*/
|
||||
|
||||
/* TODO: incorporate auto-gen with Leandro's patch */
|
||||
static size_t obj_size_get(enum k_objects otype)
|
||||
{
|
||||
switch (otype) {
|
||||
case K_OBJ_ALERT:
|
||||
return sizeof(struct k_alert);
|
||||
case K_OBJ_MSGQ:
|
||||
return sizeof(struct k_msgq);
|
||||
case K_OBJ_MUTEX:
|
||||
return sizeof(struct k_mutex);
|
||||
case K_OBJ_PIPE:
|
||||
return sizeof(struct k_pipe);
|
||||
case K_OBJ_SEM:
|
||||
return sizeof(struct k_sem);
|
||||
case K_OBJ_STACK:
|
||||
return sizeof(struct k_stack);
|
||||
case K_OBJ_THREAD:
|
||||
return sizeof(struct k_thread);
|
||||
case K_OBJ_TIMER:
|
||||
return sizeof(struct k_timer);
|
||||
#include <otype-to-size.h>
|
||||
default:
|
||||
return sizeof(struct device);
|
||||
}
|
||||
|
|
|
@ -186,6 +186,17 @@ def write_kobj_otype_output(fp):
|
|||
subsystem
|
||||
))
|
||||
|
||||
def write_kobj_size_output(fp):
|
||||
fp.write("/* Non device/stack objects */\n")
|
||||
for kobj in kobjects:
|
||||
# device handled by default case. Stacks are not currently handled,
|
||||
# if they eventually are it will be a special case.
|
||||
if kobj == "device" or kobj == "_k_thread_stack_element":
|
||||
continue
|
||||
|
||||
kobj_enum = "K_OBJ_%s" % kobj[2:].upper();
|
||||
|
||||
fp.write('case %s: return sizeof(struct %s);\n' % (kobj_enum, kobj))
|
||||
|
||||
def parse_args():
|
||||
global args
|
||||
|
@ -208,6 +219,9 @@ def parse_args():
|
|||
parser.add_argument(
|
||||
"-S", "--kobj-otype-output", required=False,
|
||||
help="Output case statements for otype_to_str()")
|
||||
parser.add_argument(
|
||||
"-Z", "--kobj-size-output", required=False,
|
||||
help="Output case statements for obj_size_get()")
|
||||
parser.add_argument("-v", "--verbose", action="store_true",
|
||||
help="Print extra debugging information")
|
||||
args = parser.parse_args()
|
||||
|
@ -247,5 +261,9 @@ def main():
|
|||
with open(args.kobj_otype_output, "w") as fp:
|
||||
write_kobj_otype_output(fp)
|
||||
|
||||
if args.kobj_size_output:
|
||||
with open(args.kobj_size_output, "w") as fp:
|
||||
write_kobj_size_output(fp)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue