summaryrefslogtreecommitdiffstats
path: root/arch/x86
diff options
context:
space:
mode:
authorMiao Yan <yanmiaobest@gmail.com>2016-05-22 19:37:15 -0700
committerBin Meng <bmeng.cn@gmail.com>2016-05-23 15:18:00 +0800
commit2e82e745a4cf6bad10d9fe5a53db6592f40ff903 (patch)
treef998e79cd2a89b2417f4a8497ee2059d1e89ff93 /arch/x86
parentfcf5c04193b48c3f5e2d337a85d28c4026f90ac3 (diff)
downloadblackbird-obmc-uboot-2e82e745a4cf6bad10d9fe5a53db6592f40ff903.tar.gz
blackbird-obmc-uboot-2e82e745a4cf6bad10d9fe5a53db6592f40ff903.zip
x86: qemu: move x86 specific operations out of qfw core
The original implementation of qfw includes several x86 specific operations, like directly calling outb/inb and using some inline assembly code which prevents it being ported to other architectures. This patch adds callback functions and moves those to arch/x86/ Signed-off-by: Miao Yan <yanmiaobest@gmail.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Diffstat (limited to 'arch/x86')
-rw-r--r--arch/x86/cpu/qemu/qemu.c39
1 files changed, 38 insertions, 1 deletions
diff --git a/arch/x86/cpu/qemu/qemu.c b/arch/x86/cpu/qemu/qemu.c
index 32a4351874..6ff99474bf 100644
--- a/arch/x86/cpu/qemu/qemu.c
+++ b/arch/x86/cpu/qemu/qemu.c
@@ -15,6 +15,43 @@
static bool i440fx;
+#ifdef CONFIG_QFW
+
+#define FW_CONTROL_PORT 0x510
+#define FW_DATA_PORT 0x511
+#define FW_DMA_PORT_LOW 0x514
+#define FW_DMA_PORT_HIGH 0x518
+
+static void qemu_x86_fwcfg_read_entry_pio(uint16_t entry,
+ uint32_t size, void *address)
+{
+ uint32_t i = 0;
+ uint8_t *data = address;
+
+ /*
+ * writting FW_CFG_INVALID will cause read operation to resume at
+ * last offset, otherwise read will start at offset 0
+ */
+ if (entry != FW_CFG_INVALID)
+ outw(entry, FW_CONTROL_PORT);
+ while (size--)
+ data[i++] = inb(FW_DATA_PORT);
+}
+
+static void qemu_x86_fwcfg_read_entry_dma(struct fw_cfg_dma_access *dma)
+{
+ outl(cpu_to_be32((uint32_t)dma), FW_DMA_PORT_HIGH);
+
+ while (be32_to_cpu(dma->control) & ~FW_CFG_DMA_ERROR)
+ __asm__ __volatile__ ("pause");
+}
+
+static struct fw_cfg_arch_ops fwcfg_x86_ops = {
+ .arch_read_pio = qemu_x86_fwcfg_read_entry_pio,
+ .arch_read_dma = qemu_x86_fwcfg_read_entry_dma
+};
+#endif
+
static void enable_pm_piix(void)
{
u8 en;
@@ -89,7 +126,7 @@ static void qemu_chipset_init(void)
}
#ifdef CONFIG_QFW
- qemu_fwcfg_init();
+ qemu_fwcfg_init(&fwcfg_x86_ops);
#endif
}
OpenPOWER on IntegriCloud