Commit d3ad06239291d89c1c598248d577cde5470ac1ee
Committed by
Bin Meng
1 parent
05dd6f183c
Exists in
v2017.01-smarct4x
and in
25 other branches
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>
Showing 2 changed files with 23 additions and 17 deletions Side-by-side Diff
cmd/qemu_fw_cfg.c
... | ... | @@ -62,23 +62,14 @@ |
62 | 62 | __asm__ __volatile__ ("pause"); |
63 | 63 | } |
64 | 64 | |
65 | -static bool qemu_fwcfg_present(void) | |
65 | +bool qemu_fwcfg_present(void) | |
66 | 66 | { |
67 | - uint32_t qemu; | |
68 | - | |
69 | - qemu_fwcfg_read_entry_pio(FW_CFG_SIGNATURE, 4, &qemu); | |
70 | - return be32_to_cpu(qemu) == QEMU_FW_CFG_SIGNATURE; | |
67 | + return fwcfg_present; | |
71 | 68 | } |
72 | 69 | |
73 | -static bool qemu_fwcfg_dma_present(void) | |
70 | +bool qemu_fwcfg_dma_present(void) | |
74 | 71 | { |
75 | - uint8_t dma_enabled; | |
76 | - | |
77 | - qemu_fwcfg_read_entry_pio(FW_CFG_ID, 1, &dma_enabled); | |
78 | - if (dma_enabled & FW_CFG_DMA_ENABLED) | |
79 | - return true; | |
80 | - | |
81 | - return false; | |
72 | + return fwcfg_dma_present; | |
82 | 73 | } |
83 | 74 | |
84 | 75 | void qemu_fwcfg_read_entry(uint16_t entry, uint32_t length, void *address) |
... | ... | @@ -257,9 +248,21 @@ |
257 | 248 | |
258 | 249 | void qemu_fwcfg_init(void) |
259 | 250 | { |
260 | - fwcfg_present = qemu_fwcfg_present(); | |
261 | - if (fwcfg_present) | |
262 | - fwcfg_dma_present = qemu_fwcfg_dma_present(); | |
251 | + uint32_t qemu; | |
252 | + uint32_t dma_enabled; | |
253 | + | |
254 | + fwcfg_present = false; | |
255 | + fwcfg_dma_present = false; | |
256 | + | |
257 | + qemu_fwcfg_read_entry_pio(FW_CFG_SIGNATURE, 4, &qemu); | |
258 | + if (be32_to_cpu(qemu) == QEMU_FW_CFG_SIGNATURE) | |
259 | + fwcfg_present = true; | |
260 | + | |
261 | + if (fwcfg_present) { | |
262 | + qemu_fwcfg_read_entry_pio(FW_CFG_ID, 1, &dma_enabled); | |
263 | + if (dma_enabled & FW_CFG_DMA_ENABLED) | |
264 | + fwcfg_dma_present = true; | |
265 | + } | |
263 | 266 | } |
264 | 267 | |
265 | 268 | static int qemu_fwcfg_do_list(cmd_tbl_t *cmdtp, int flag, |
... | ... | @@ -323,7 +326,7 @@ |
323 | 326 | int ret; |
324 | 327 | cmd_tbl_t *fwcfg_cmd; |
325 | 328 | |
326 | - if (!fwcfg_present) { | |
329 | + if (!qemu_fwcfg_present()) { | |
327 | 330 | printf("QEMU fw_cfg interface not found\n"); |
328 | 331 | return CMD_RET_USAGE; |
329 | 332 | } |
include/qemu_fw_cfg.h