summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiao Yan <yanmiaobest@gmail.com>2016-05-22 19:37:11 -0700
committerBin Meng <bmeng.cn@gmail.com>2016-05-23 15:18:00 +0800
commit099b2196e4a693968fd6205ac6d61f6eaab79fb1 (patch)
treee255d10eb85b684816f07a330b6f4c2622cbd775
parent34865a65c44d9c0dffb9b5346e66ea9b7757b880 (diff)
downloadu-boot-imx-099b2196e4a693968fd6205ac6d61f6eaab79fb1.zip
u-boot-imx-099b2196e4a693968fd6205ac6d61f6eaab79fb1.tar.gz
u-boot-imx-099b2196e4a693968fd6205ac6d61f6eaab79fb1.tar.bz2
cmd: qfw: add API to iterate firmware list
This patch is part of the refactor work of qfw. It adds 3 APIs to qfw core to iterate firmware list. Signed-off-by: Miao Yan <yanmiaobest@gmail.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
-rw-r--r--cmd/qemu_fw_cfg.c25
-rw-r--r--include/qemu_fw_cfg.h9
2 files changed, 31 insertions, 3 deletions
diff --git a/cmd/qemu_fw_cfg.c b/cmd/qemu_fw_cfg.c
index 48ae476..192b7d1 100644
--- a/cmd/qemu_fw_cfg.c
+++ b/cmd/qemu_fw_cfg.c
@@ -229,10 +229,27 @@ void qemu_fwcfg_free_files(void)
}
}
+struct fw_file *qemu_fwcfg_file_iter_init(struct fw_cfg_file_iter *iter)
+{
+ iter->entry = fw_list.next;
+ return list_entry(iter->entry, struct fw_file, list);
+}
+
+struct fw_file *qemu_fwcfg_file_iter_next(struct fw_cfg_file_iter *iter)
+{
+ iter->entry = iter->entry->next;
+ return list_entry(iter->entry, struct fw_file, list);
+}
+
+bool qemu_fwcfg_file_iter_end(struct fw_cfg_file_iter *iter)
+{
+ return iter->entry == &fw_list;
+}
+
static int qemu_fwcfg_list_firmware(void)
{
int ret;
- struct list_head *entry;
+ struct fw_cfg_file_iter iter;
struct fw_file *file;
/* make sure fw_list is loaded */
@@ -240,8 +257,10 @@ static int qemu_fwcfg_list_firmware(void)
if (ret)
return ret;
- list_for_each(entry, &fw_list) {
- file = list_entry(entry, struct fw_file, list);
+
+ for (file = qemu_fwcfg_file_iter_init(&iter);
+ !qemu_fwcfg_file_iter_end(&iter);
+ file = qemu_fwcfg_file_iter_next(&iter)) {
printf("%-56s\n", file->cfg.name);
}
diff --git a/include/qemu_fw_cfg.h b/include/qemu_fw_cfg.h
index e21f150..19d0ba0 100644
--- a/include/qemu_fw_cfg.h
+++ b/include/qemu_fw_cfg.h
@@ -87,6 +87,10 @@ struct fw_file {
struct list_head list; /* list node to link to fw_list */
};
+struct fw_cfg_file_iter {
+ struct list_head *entry; /* structure to iterate file list */
+};
+
struct fw_cfg_dma_access {
__be32 control;
__be32 length;
@@ -159,4 +163,9 @@ void qemu_fwcfg_free_files(void);
*/
int qemu_fwcfg_online_cpus(void);
+/* helper functions to iterate firmware file list */
+struct fw_file *qemu_fwcfg_file_iter_init(struct fw_cfg_file_iter *iter);
+struct fw_file *qemu_fwcfg_file_iter_next(struct fw_cfg_file_iter *iter);
+bool qemu_fwcfg_file_iter_end(struct fw_cfg_file_iter *iter);
+
#endif