qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH v2 1/6] Use IO port for qemu<->guest BIOS communicat


From: Gleb Natapov
Subject: [Qemu-devel] [PATCH v2 1/6] Use IO port for qemu<->guest BIOS communication.
Date: Mon, 25 Aug 2008 12:58:05 +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 |   59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 59 insertions(+), 0 deletions(-)

diff --git a/hw/pc.c b/hw/pc.c
index 213ead8..8caa48f 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,26 @@ 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_ID,
+    BIOS_CFG_MAX_ENTRY
+} BIOSCfgEntryNum;
+
+typedef struct _BIOSCfgState {
+    BIOSCfgEntry entries[BIOS_CFG_MAX_ENTRY];
+    BIOSCfgEntryNum entry;
+    uint16_t cur_offset;
+} BIOSCfgState;
+
+static uint32_t bios_cfg_id = 1;
+static BIOSCfgState *bios_params;
+
 static void ioport80_write(void *opaque, uint32_t addr, uint32_t data)
 {
 }
@@ -716,6 +737,36 @@ static void pc_init_ne2k_isa(NICInfo *nd, qemu_irq *pic)
     nb_ne2k++;
 }
 
+static uint32_t bios_cfg_read(void *opaque, uint32_t addr)
+{
+    BIOSCfgState *s = opaque;
+    BIOSCfgEntry *e = &s->entries[s->entry];
+
+    if (s->entry == BIOS_CFG_MAX_ENTRY || !e->data || s->cur_offset >= e->len)
+        return 0;
+
+    return e->data[s->cur_offset++];
+}
+
+static void bios_cfg_write(void *opaque, uint32_t addr, uint32_t value)
+{
+    BIOSCfgState *s = opaque;
+    s->entry = (value > BIOS_CFG_MAX_ENTRY) ? BIOS_CFG_MAX_ENTRY : value;
+    s->cur_offset = 0;
+}
+
+static int bios_cfg_add_data(BIOSCfgState *s, BIOSCfgEntryNum entry,
+        uint8_t *data, uint16_t len)
+{
+    if(entry >=  BIOS_CFG_MAX_ENTRY)
+        return 0;
+
+    s->entries[entry].data = data;
+    s->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 +922,14 @@ 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);
 
+    bios_params = qemu_mallocz(sizeof(BIOSCfgState));
+
+    register_ioport_read(BIOS_CFG_IOPORT, 1, 1, bios_cfg_read, bios_params);
+    register_ioport_write(BIOS_CFG_IOPORT, 1, 1, bios_cfg_write, bios_params);
+
+    bios_cfg_add_data(bios_params, BIOS_CFG_SIGNATURE, "QEMU", 4);
+    bios_cfg_add_data(bios_params, BIOS_CFG_ID, (uint8_t*)&bios_cfg_id, 4);
+
     bochs_bios_init();
 
     if (linux_boot)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]