2013-09-27 14:35:46 +00:00
|
|
|
#ifndef __LOADER_H__
|
|
|
|
#define __LOADER_H__
|
|
|
|
|
|
|
|
#include <linux/list.h>
|
|
|
|
#include <menu.h>
|
|
|
|
|
|
|
|
struct blspec {
|
|
|
|
struct list_head entries;
|
|
|
|
struct menu *menu;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct blspec_entry {
|
|
|
|
struct list_head list;
|
|
|
|
struct device_node *node;
|
|
|
|
struct cdev *cdev;
|
|
|
|
char *rootpath;
|
|
|
|
char *configpath;
|
|
|
|
bool boot_default;
|
|
|
|
bool boot_once;
|
|
|
|
|
|
|
|
struct menu_entry me;
|
|
|
|
|
|
|
|
char *scriptpath;
|
|
|
|
};
|
|
|
|
|
|
|
|
int blspec_entry_var_set(struct blspec_entry *entry, const char *name,
|
|
|
|
const char *val);
|
|
|
|
const char *blspec_entry_var_get(struct blspec_entry *entry, const char *name);
|
|
|
|
|
|
|
|
int blspec_entry_save(struct blspec_entry *entry, const char *path);
|
|
|
|
|
|
|
|
int blspec_boot(struct blspec_entry *entry, int verbose, int dryrun);
|
|
|
|
|
2013-10-31 15:18:47 +00:00
|
|
|
int blspec_boot_devicename(const char *devname, int verbose, int dryrun);
|
2013-09-27 14:35:46 +00:00
|
|
|
|
2013-11-01 08:24:56 +00:00
|
|
|
int blspec_scan_devices(struct blspec *blspec);
|
2013-09-27 14:35:46 +00:00
|
|
|
|
2015-06-16 09:59:41 +00:00
|
|
|
int blspec_scan_device(struct blspec *blspec, struct device_d *dev);
|
2013-10-31 15:18:47 +00:00
|
|
|
int blspec_scan_devicename(struct blspec *blspec, const char *devname);
|
2013-11-01 09:52:43 +00:00
|
|
|
int blspec_scan_directory(struct blspec *blspec, const char *root);
|
2013-09-27 14:35:46 +00:00
|
|
|
|
|
|
|
#define blspec_for_each_entry(blspec, entry) \
|
|
|
|
list_for_each_entry(entry, &blspec->entries, list)
|
|
|
|
|
|
|
|
static inline struct blspec_entry *blspec_entry_alloc(struct blspec *blspec)
|
|
|
|
{
|
|
|
|
struct blspec_entry *entry;
|
|
|
|
|
|
|
|
entry = xzalloc(sizeof(*entry));
|
|
|
|
|
|
|
|
entry->node = of_new_node(NULL, NULL);
|
|
|
|
|
|
|
|
list_add_tail(&entry->list, &blspec->entries);
|
|
|
|
|
|
|
|
return entry;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void blspec_entry_free(struct blspec_entry *entry)
|
|
|
|
{
|
|
|
|
list_del(&entry->list);
|
|
|
|
of_delete_node(entry->node);
|
|
|
|
free(entry->me.display);
|
|
|
|
free(entry->scriptpath);
|
|
|
|
free(entry->configpath);
|
|
|
|
free(entry->rootpath);
|
|
|
|
free(entry);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline struct blspec *blspec_alloc(void)
|
|
|
|
{
|
|
|
|
struct blspec *blspec;
|
|
|
|
|
|
|
|
blspec = xzalloc(sizeof(*blspec));
|
|
|
|
INIT_LIST_HEAD(&blspec->entries);
|
|
|
|
|
|
|
|
if (IS_ENABLED(CONFIG_MENU))
|
|
|
|
blspec->menu = menu_alloc();
|
|
|
|
|
|
|
|
return blspec;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void blspec_free(struct blspec *blspec)
|
|
|
|
{
|
|
|
|
struct blspec_entry *entry, *tmp;
|
|
|
|
|
|
|
|
list_for_each_entry_safe(entry, tmp, &blspec->entries, list)
|
|
|
|
blspec_entry_free(entry);
|
2013-10-30 10:36:58 +00:00
|
|
|
if (blspec->menu)
|
|
|
|
free(blspec->menu->display);
|
2013-09-27 14:35:46 +00:00
|
|
|
free(blspec->menu);
|
|
|
|
free(blspec);
|
|
|
|
}
|
|
|
|
|
2014-03-20 11:26:19 +00:00
|
|
|
#ifdef CONFIG_BLSPEC
|
|
|
|
struct blspec_entry *blspec_entry_default(struct blspec *l);
|
|
|
|
#else
|
|
|
|
static inline struct blspec_entry *blspec_entry_default(struct blspec *l)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-09-27 14:35:46 +00:00
|
|
|
#endif /* __LOADER_H__ */
|