[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 1/6] Use IO port for qemu<->guest BIOS communication
From: |
Gleb Natapov |
Subject: |
[Qemu-devel] [PATCH 1/6] Use IO port for qemu<->guest BIOS communication. |
Date: |
Sun, 24 Aug 2008 14:33:04 +0300 |
User-agent: |
StGIT/0.14.2 |
Use PIO to get configuration info between qemu process and guest BIOS.
Signed-off-by: Gleb Natapov <address@hidden>
---
hw/pc.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 51 insertions(+), 0 deletions(-)
diff --git a/hw/pc.c b/hw/pc.c
index 213ead8..ccbe4b3 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -44,6 +44,7 @@
/* Leave a chunk of memory at the top of RAM for the BIOS ACPI tables. */
#define ACPI_DATA_SIZE 0x10000
+#define BIOS_CFG_IOPORT 0x1234
#define MAX_IDE_BUS 2
@@ -53,6 +54,24 @@ static PITState *pit;
static IOAPICState *ioapic;
static PCIDevice *i440fx_state;
+typedef struct _BIOSCfgEntry {
+ uint16_t len;
+ uint8_t *data;
+} BIOSCfgEntry;
+
+typedef enum _BIOSCfgEntryNum{
+ BIOS_CFG_SIGNATURE,
+ BIOS_CFG_MAX_ENTRY
+} BIOSCfgEntryNum;
+
+typedef struct _BIOSCfgState {
+ BIOSCfgEntry entries[BIOS_CFG_MAX_ENTRY];
+ BIOSCfgEntryNum entry;
+ uint16_t cur_offset;
+} BIOSCfgState;
+
+static BIOSCfgState bios_params;
+
static void ioport80_write(void *opaque, uint32_t addr, uint32_t data)
{
}
@@ -716,6 +735,33 @@ static void pc_init_ne2k_isa(NICInfo *nd, qemu_irq *pic)
nb_ne2k++;
}
+static uint32_t bios_cfg_read(void *opaque, uint32_t addr)
+{
+ BIOSCfgEntry *e = &bios_params.entries[bios_params.entry];
+
+ if (!e->data)
+ return 0;
+
+ return e->data[bios_params.cur_offset++ % e->len];
+}
+
+static void bios_cfg_write(void *opaque, uint32_t addr, uint32_t value)
+{
+ bios_params.entry = value % BIOS_CFG_MAX_ENTRY;
+ bios_params.cur_offset = 0;
+}
+
+static int bios_cfg_add_data(BIOSCfgEntryNum entry, uint8_t *data, uint16_t
len)
+{
+ if(entry >= BIOS_CFG_MAX_ENTRY)
+ return 0;
+
+ bios_params.entries[entry].data = data;
+ bios_params.entries[entry].len = len;
+
+ return 1;
+}
+
/* PC hardware initialisation */
static void pc_init1(ram_addr_t ram_size, int vga_ram_size,
const char *boot_device, DisplayState *ds,
@@ -871,6 +917,11 @@ static void pc_init1(ram_addr_t ram_size, int vga_ram_size,
cpu_register_physical_memory((uint32_t)(-bios_size),
bios_size, bios_offset | IO_MEM_ROM);
+ register_ioport_read(BIOS_CFG_IOPORT, 1, 1, bios_cfg_read, NULL);
+ register_ioport_write(BIOS_CFG_IOPORT, 1, 1, bios_cfg_write, NULL);
+
+ bios_cfg_add_data(BIOS_CFG_SIGNATURE, "QEMU", 4);
+
bochs_bios_init();
if (linux_boot)