summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiao Yan <yanmiaobest@gmail.com>2016-05-22 19:37:13 -0700
committerBin Meng <bmeng.cn@gmail.com>2016-05-23 15:18:00 +0800
commitd3ad06239291d89c1c598248d577cde5470ac1ee (patch)
tree2bfa2cac772a70f420ca68b0cf7ddf42ff183c56
parent05dd6f183c8c20f0176a67ac885f8143c0052203 (diff)
cmd: qfw: make fwcfg_present and fwcfg_dma_present public
This patch is part of the qfw refactor work. This patch makes qemu_fwcfg_present() and qemu_fwcfg_dma_present() public functions. Signed-off-by: Miao Yan <yanmiaobest@gmail.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
-rw-r--r--cmd/qemu_fw_cfg.c37
-rw-r--r--include/qemu_fw_cfg.h3
2 files changed, 23 insertions, 17 deletions
diff --git a/cmd/qemu_fw_cfg.c b/cmd/qemu_fw_cfg.c
index 9f03ab60ab..aab6b1a452 100644
--- a/cmd/qemu_fw_cfg.c
+++ b/cmd/qemu_fw_cfg.c
@@ -62,23 +62,14 @@ static void qemu_fwcfg_read_entry_dma(uint16_t entry,
__asm__ __volatile__ ("pause");
}
-static bool qemu_fwcfg_present(void)
+bool qemu_fwcfg_present(void)
{
- uint32_t qemu;
-
- qemu_fwcfg_read_entry_pio(FW_CFG_SIGNATURE, 4, &qemu);
- return be32_to_cpu(qemu) == QEMU_FW_CFG_SIGNATURE;
+ return fwcfg_present;
}
-static bool qemu_fwcfg_dma_present(void)
+bool qemu_fwcfg_dma_present(void)
{
- uint8_t dma_enabled;
-
- qemu_fwcfg_read_entry_pio(FW_CFG_ID, 1, &dma_enabled);
- if (dma_enabled & FW_CFG_DMA_ENABLED)
- return true;
-
- return false;
+ return fwcfg_dma_present;
}
void qemu_fwcfg_read_entry(uint16_t entry, uint32_t length, void *address)
@@ -257,9 +248,21 @@ static int qemu_fwcfg_list_firmware(void)
void qemu_fwcfg_init(void)
{
- fwcfg_present = qemu_fwcfg_present();
- if (fwcfg_present)
- fwcfg_dma_present = qemu_fwcfg_dma_present();
+ uint32_t qemu;
+ uint32_t dma_enabled;
+
+ fwcfg_present = false;
+ fwcfg_dma_present = false;
+
+ qemu_fwcfg_read_entry_pio(FW_CFG_SIGNATURE, 4, &qemu);
+ if (be32_to_cpu(qemu) == QEMU_FW_CFG_SIGNATURE)
+ fwcfg_present = true;
+
+ if (fwcfg_present) {
+ qemu_fwcfg_read_entry_pio(FW_CFG_ID, 1, &dma_enabled);
+ if (dma_enabled & FW_CFG_DMA_ENABLED)
+ fwcfg_dma_present = true;
+ }
}
static int qemu_fwcfg_do_list(cmd_tbl_t *cmdtp, int flag,
@@ -323,7 +326,7 @@ static int do_qemu_fw(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
int ret;
cmd_tbl_t *fwcfg_cmd;
- if (!fwcfg_present) {
+ if (!qemu_fwcfg_present()) {
printf("QEMU fw_cfg interface not found\n");
return CMD_RET_USAGE;
}
diff --git a/include/qemu_fw_cfg.h b/include/qemu_fw_cfg.h
index 986f4b2e5a..f718e09e31 100644
--- a/include/qemu_fw_cfg.h
+++ b/include/qemu_fw_cfg.h
@@ -167,4 +167,7 @@ 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);
+bool qemu_fwcfg_present(void);
+bool qemu_fwcfg_dma_present(void);
+
#endif