From e113fa5f1d498f86705bfb53c6ae8b8a8e225173 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Wed, 20 Jul 2016 09:47:10 +0200 Subject: blspec: separate bootentries from blspec entries This completes the separation of the blspec code from the boot code. With this the boot code only handles generic boot entries of type struct bootentry which are embedded into the type (blspec/bootscript) specific structs. Signed-off-by: Sascha Hauer --- include/blspec.h | 60 ++++---------------------------------------------------- 1 file changed, 4 insertions(+), 56 deletions(-) (limited to 'include/blspec.h') diff --git a/include/blspec.h b/include/blspec.h index c956f0d940..7a16ae73c6 100644 --- a/include/blspec.h +++ b/include/blspec.h @@ -14,6 +14,8 @@ struct bootentry { struct menu_entry me; char *title; char *description; + int (*boot)(struct bootentry *entry, int verbose, int dryrun); + void (*release)(struct bootentry *entry); }; struct blspec_entry { @@ -23,8 +25,6 @@ struct blspec_entry { struct cdev *cdev; char *rootpath; char *configpath; - - char *scriptpath; }; int blspec_entry_var_set(struct blspec_entry *entry, const char *name, @@ -39,61 +39,9 @@ int blspec_scan_device(struct bootentries *bootentries, struct device_d *dev); int blspec_scan_devicename(struct bootentries *bootentries, const char *devname); int blspec_scan_directory(struct bootentries *bootentries, const char *root); +int bootentries_add_entry(struct bootentries *entries, struct bootentry *entry); + #define bootentries_for_each_entry(bootentries, entry) \ list_for_each_entry(entry, &bootentries->entries, list) -static inline struct blspec_entry *blspec_entry_alloc(struct bootentries *bootentries) -{ - struct blspec_entry *entry; - - entry = xzalloc(sizeof(*entry)); - - entry->node = of_new_node(NULL, NULL); - - list_add_tail(&entry->entry.list, &bootentries->entries); - - return entry; -} - -static inline void blspec_entry_free(struct blspec_entry *entry) -{ - list_del(&entry->entry.list); - of_delete_node(entry->node); - free(entry->entry.me.display); - free(entry->entry.title); - free(entry->entry.description); - free(entry->scriptpath); - free(entry->configpath); - free(entry->rootpath); - free(entry); -} - -static inline struct bootentries *blspec_alloc(void) -{ - struct bootentries *bootentries; - - bootentries = xzalloc(sizeof(*bootentries)); - INIT_LIST_HEAD(&bootentries->entries); - - if (IS_ENABLED(CONFIG_MENU)) - bootentries->menu = menu_alloc(); - - return bootentries; -} - -static inline void blspec_free(struct bootentries *bootentries) -{ - struct bootentry *be, *tmp; - struct blspec_entry *entry; - - list_for_each_entry_safe(be, tmp, &bootentries->entries, list) { - entry = container_of(be, struct blspec_entry, entry); - blspec_entry_free(entry); - } - if (bootentries->menu) - free(bootentries->menu->display); - free(bootentries->menu); - free(bootentries); -} - #endif /* __LOADER_H__ */ -- cgit v1.2.3