From: Anthony Liguori <aliguori@us.ibm.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
Anthony Liguori <aliguori@us.ibm.com>,
Jan Kiszka <jan.kiszka@siemens.com>,
Markus Armbruster <armbru@redhat.com>,
Avi Kivity <avi@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>
Subject: [Qemu-devel] [PATCH 14/15] i440fx: move bios loading to i440fx
Date: Thu, 26 Jan 2012 13:00:59 -0600 [thread overview]
Message-ID: <1327604460-31142-15-git-send-email-aliguori@us.ibm.com> (raw)
In-Reply-To: <1327604460-31142-1-git-send-email-aliguori@us.ibm.com>
---
hw/pc.c | 70 ++++--------------------------------------------------
hw/pc.h | 3 +-
hw/piix_pci.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
sysemu.h | 2 -
4 files changed, 79 insertions(+), 70 deletions(-)
diff --git a/hw/pc.c b/hw/pc.c
index b7542b4..4964a64 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -64,8 +64,6 @@
#define DPRINTF(fmt, ...)
#endif
-#define BIOS_FILENAME "bios.bin"
-
#define PC_MAX_BIOS_SIZE (4 * 1024 * 1024)
/* Leave a chunk of memory at the top of RAM for the BIOS ACPI tables. */
@@ -996,14 +994,10 @@ static void pc_memory_init(MemoryRegion *system_memory,
const char *initrd_filename,
ram_addr_t below_4g_mem_size,
ram_addr_t above_4g_mem_size,
- MemoryRegion *rom_memory,
MemoryRegion **ram_memory)
{
- char *filename;
- int ret, linux_boot, i;
- MemoryRegion *ram, *bios, *isa_bios, *option_rom_mr;
- MemoryRegion *ram_below_4g, *ram_above_4g;
- int bios_size, isa_bios_size;
+ int linux_boot, i;
+ MemoryRegion *ram, *ram_below_4g, *ram_above_4g;
void *fw_cfg;
linux_boot = (kernel_filename != NULL);
@@ -1029,58 +1023,6 @@ static void pc_memory_init(MemoryRegion *system_memory,
ram_above_4g);
}
- /* BIOS load */
- if (bios_name == NULL)
- bios_name = BIOS_FILENAME;
- filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
- if (filename) {
- bios_size = get_image_size(filename);
- } else {
- bios_size = -1;
- }
- if (bios_size <= 0 ||
- (bios_size % 65536) != 0) {
- goto bios_error;
- }
- bios = g_malloc(sizeof(*bios));
- memory_region_init_ram(bios, "pc.bios", bios_size);
- vmstate_register_ram_global(bios);
- memory_region_set_readonly(bios, true);
- ret = rom_add_file_fixed(bios_name, (uint32_t)(-bios_size), -1);
- if (ret != 0) {
- bios_error:
- fprintf(stderr, "qemu: could not load PC BIOS '%s'\n", bios_name);
- exit(1);
- }
- if (filename) {
- g_free(filename);
- }
- /* map the last 128KB of the BIOS in ISA space */
- isa_bios_size = bios_size;
- if (isa_bios_size > (128 * 1024))
- isa_bios_size = 128 * 1024;
- isa_bios = g_malloc(sizeof(*isa_bios));
- memory_region_init_alias(isa_bios, "isa-bios", bios,
- bios_size - isa_bios_size, isa_bios_size);
- memory_region_add_subregion_overlap(rom_memory,
- 0x100000 - isa_bios_size,
- isa_bios,
- 1);
- memory_region_set_readonly(isa_bios, true);
-
- option_rom_mr = g_malloc(sizeof(*option_rom_mr));
- memory_region_init_ram(option_rom_mr, "pc.rom", PC_ROM_SIZE);
- vmstate_register_ram_global(option_rom_mr);
- memory_region_add_subregion_overlap(rom_memory,
- PC_ROM_MIN_VGA,
- option_rom_mr,
- 1);
-
- /* map all the bios at the top of memory */
- memory_region_add_subregion(rom_memory,
- (uint32_t)(-bios_size),
- bios);
-
fw_cfg = bochs_bios_init();
rom_set_fw(fw_cfg);
@@ -1299,7 +1241,6 @@ static void pc_init1(MemoryRegion *system_memory,
ISADevice *floppy;
MemoryRegion *ram_memory = NULL;
MemoryRegion *pci_memory;
- MemoryRegion *rom_memory;
DeviceState *dev;
pc_cpus_init(cpu_model);
@@ -1319,10 +1260,8 @@ static void pc_init1(MemoryRegion *system_memory,
if (pci_enabled) {
pci_memory = g_new(MemoryRegion, 1);
memory_region_init(pci_memory, "pci", INT64_MAX);
- rom_memory = pci_memory;
} else {
pci_memory = NULL;
- rom_memory = system_memory;
}
/* allocate ram and load rom/bios */
@@ -1330,7 +1269,7 @@ static void pc_init1(MemoryRegion *system_memory,
pc_memory_init(system_memory,
kernel_filename, kernel_cmdline, initrd_filename,
below_4g_mem_size, above_4g_mem_size,
- pci_enabled ? rom_memory : system_memory, &ram_memory);
+ &ram_memory);
}
gsi_state = g_malloc0(sizeof(*gsi_state));
@@ -1351,7 +1290,8 @@ static void pc_init1(MemoryRegion *system_memory,
(sizeof(target_phys_addr_t) == 4
? 0
: ((uint64_t)1 << 62)),
- pci_memory, ram_memory);
+ pci_memory, ram_memory,
+ bios_name);
} else {
pci_bus = NULL;
i440fx_state = NULL;
diff --git a/hw/pc.h b/hw/pc.h
index 0764f55..530f417 100644
--- a/hw/pc.h
+++ b/hw/pc.h
@@ -166,7 +166,8 @@ PCIBus *i440fx_init(I440FXPMCState **pi440fx_state, int *piix_devfn,
target_phys_addr_t pci_hole64_start,
target_phys_addr_t pci_hole64_size,
MemoryRegion *pci_memory,
- MemoryRegion *ram_memory);
+ MemoryRegion *ram_memory,
+ const char *bios_name);
/* piix4.c */
extern PCIDevice *piix4_dev;
diff --git a/hw/piix_pci.c b/hw/piix_pci.c
index 855f402..6dda019 100644
--- a/hw/piix_pci.c
+++ b/hw/piix_pci.c
@@ -33,6 +33,10 @@
#include "hpet_emul.h"
#include "mc146818rtc.h"
#include "i8254.h"
+#include "loader.h"
+#include "sysemu.h"
+
+#define BIOS_FILENAME "bios.bin"
/*
* I440FX chipset data sheet.
@@ -122,6 +126,13 @@ typedef struct I440FXState
I440FXPMCState pmc;
PIIX3State piix3;
+
+ /* Is this more appropriate for the PMC? */
+ MemoryRegion bios;
+ MemoryRegion isa_bios;
+ MemoryRegion option_roms;
+
+ char *bios_name;
} I440FXState;
#define I440FX_PAM 0x59
@@ -266,6 +277,9 @@ static int i440fx_realize(SysBusDevice *dev)
{
I440FXState *s = I440FX(dev);
PCIHostState *h = PCI_HOST(s);
+ int bios_size, isa_bios_size;
+ char *filename;
+ int ret;
g_assert(h->address_space != NULL);
g_assert(s->address_space_io != NULL);
@@ -300,6 +314,55 @@ static int i440fx_realize(SysBusDevice *dev)
PIIX_NUM_PIRQS);
}
+ /* BIOS load */
+ filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, s->bios_name);
+ if (filename) {
+ bios_size = get_image_size(filename);
+ } else {
+ bios_size = -1;
+ }
+ if (bios_size <= 0 ||
+ (bios_size % 65536) != 0) {
+ goto bios_error;
+ }
+ memory_region_init_ram(&s->bios, "pc.bios", bios_size);
+ vmstate_register_ram_global(&s->bios);
+ memory_region_set_readonly(&s->bios, true);
+ ret = rom_add_file_fixed(s->bios_name, (uint32_t)(-bios_size), -1);
+ if (ret != 0) {
+ bios_error:
+ fprintf(stderr, "qemu: could not load PC BIOS '%s'\n", s->bios_name);
+ exit(1);
+ }
+ if (filename) {
+ g_free(filename);
+ }
+
+ /* map the last 128KB of the BIOS in ISA space */
+ isa_bios_size = bios_size;
+ if (isa_bios_size > (128 * 1024)) {
+ isa_bios_size = 128 * 1024;
+ }
+ memory_region_init_alias(&s->isa_bios, "isa-bios", &s->bios,
+ bios_size - isa_bios_size, isa_bios_size);
+ memory_region_add_subregion_overlap(&s->pci_address_space,
+ 0x100000 - isa_bios_size,
+ &s->isa_bios,
+ 1);
+ memory_region_set_readonly(&s->isa_bios, true);
+
+ memory_region_init_ram(&s->option_roms, "pc.rom", PC_ROM_SIZE);
+ vmstate_register_ram_global(&s->option_roms);
+ memory_region_add_subregion_overlap(&s->pci_address_space,
+ PC_ROM_MIN_VGA,
+ &s->option_roms,
+ 1);
+
+ /* map all the bios at the top of memory */
+ memory_region_add_subregion(&s->pci_address_space,
+ (uint32_t)(-bios_size),
+ &s->bios);
+
return 0;
}
@@ -322,6 +385,8 @@ static void i440fx_initfn(Object *obj)
}
object_property_add_child(OBJECT(s), "piix3", OBJECT(&s->piix3), NULL);
+ s->bios_name = g_strdup(BIOS_FILENAME);
+
memory_region_init(&s->pci_address_space, "pci", INT64_MAX);
}
@@ -390,8 +455,8 @@ PCIBus *i440fx_init(I440FXPMCState **pi440fx_state, int *piix3_devfn,
target_phys_addr_t pci_hole_size,
target_phys_addr_t pci_hole64_start,
target_phys_addr_t pci_hole64_size,
- MemoryRegion *pci_address_space, MemoryRegion *ram_memory)
-
+ MemoryRegion *pci_address_space, MemoryRegion *ram_memory,
+ const char *bios_name)
{
I440FXState *s;
PCIHostState *h;
@@ -403,6 +468,11 @@ PCIBus *i440fx_init(I440FXPMCState **pi440fx_state, int *piix3_devfn,
h->address_space = address_space_mem;
s->address_space_io = address_space_io;
s->piix3.pic = pic;
+ if (bios_name) {
+ g_free(s->bios_name);
+ s->bios_name = g_strdup(bios_name);
+ }
+
/* FIXME pmc should create ram_memory */
s->pmc.ram_memory = ram_memory;
s->pmc.ram_size = ram_size;
diff --git a/sysemu.h b/sysemu.h
index caff268..5978e90 100644
--- a/sysemu.h
+++ b/sysemu.h
@@ -172,8 +172,6 @@ void usb_info(Monitor *mon);
void rtc_change_mon_event(struct tm *tm);
-void register_devices(void);
-
void add_boot_device_path(int32_t bootindex, DeviceState *dev,
const char *suffix);
char *get_boot_devices_list(uint32_t *size);
--
1.7.4.1
next prev parent reply other threads:[~2012-01-26 19:02 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-26 19:00 [Qemu-devel] [RFC 00/15] Refactor PC machine to take advantage of QOM Anthony Liguori
2012-01-26 19:00 ` [Qemu-devel] [PATCH 01/15] pc: merge pc_piix.c into pc.c Anthony Liguori
2012-01-26 19:40 ` Anthony Liguori
2012-01-27 8:50 ` Jan Kiszka
2012-01-27 13:07 ` Anthony Liguori
2012-01-27 13:32 ` Jan Kiszka
2012-01-27 14:06 ` Anthony Liguori
2012-01-27 14:15 ` Jan Kiszka
2012-01-27 14:23 ` Anthony Liguori
2012-01-27 14:03 ` Andreas Färber
2012-01-27 14:14 ` Anthony Liguori
2012-01-26 19:00 ` [Qemu-devel] [PATCH 02/15] pc: make some functions static Anthony Liguori
2012-01-26 19:00 ` [Qemu-devel] [PATCH 03/15] piix3: make PIIX3-xen a subclass of PIIX3 Anthony Liguori
2012-01-26 19:00 ` [Qemu-devel] [PATCH 04/15] piix: prepare for composition Anthony Liguori
2012-01-26 19:00 ` [Qemu-devel] [PATCH 05/15] piix: create the HPET and RTC through composition Anthony Liguori
2012-01-31 14:26 ` Jan Kiszka
2012-01-31 14:43 ` Anthony Liguori
2012-01-31 14:49 ` Jan Kiszka
2012-01-31 14:54 ` Anthony Liguori
2012-01-31 14:56 ` Jan Kiszka
2012-01-31 15:04 ` Anthony Liguori
2012-01-31 16:02 ` Jan Kiszka
2012-01-26 19:00 ` [Qemu-devel] [PATCH 06/15] piix: create i8254 " Anthony Liguori
2012-01-31 14:34 ` Jan Kiszka
2012-01-31 14:47 ` Anthony Liguori
2012-01-31 14:51 ` Jan Kiszka
2012-01-31 14:56 ` Anthony Liguori
2012-01-31 16:42 ` Jan Kiszka
2012-01-31 16:49 ` Anthony Liguori
2012-01-31 16:56 ` Jan Kiszka
2012-01-31 14:58 ` Paolo Bonzini
2012-01-31 16:04 ` Jan Kiszka
2012-01-31 16:12 ` Anthony Liguori
2012-01-31 16:19 ` Jan Kiszka
2012-01-31 16:47 ` Anthony Liguori
2012-01-31 16:59 ` Paolo Bonzini
2012-01-26 19:00 ` [Qemu-devel] [PATCH 07/15] i440fx: eliminate i440fx_common_init Anthony Liguori
2012-01-26 19:00 ` [Qemu-devel] [PATCH 08/15] i440fx: introduce some saner naming conventions Anthony Liguori
2012-01-26 19:00 ` [Qemu-devel] [PATCH 09/15] i440fx: create the PMC through composition Anthony Liguori
2012-01-26 19:00 ` [Qemu-devel] [PATCH 10/15] i440fx: move some logic to realize and make inheritance from PCIHost explicit Anthony Liguori
2012-01-26 19:00 ` [Qemu-devel] [PATCH 11/15] i440fx-pmc: refactor to take properties for memory geometry Anthony Liguori
2012-01-26 19:00 ` [Qemu-devel] [PATCH 12/15] i440fx-pmc: calculate PCI memory hole directly Anthony Liguori
2012-01-26 19:00 ` [Qemu-devel] [PATCH 13/15] i440fx: allocate MemoryRegion for pci memory space Anthony Liguori
2012-01-26 19:00 ` Anthony Liguori [this message]
2012-01-31 14:38 ` [Qemu-devel] [PATCH 14/15] i440fx: move bios loading to i440fx Jan Kiszka
2012-01-31 14:50 ` Anthony Liguori
2012-01-31 14:53 ` Jan Kiszka
2012-01-31 14:57 ` Anthony Liguori
2012-01-31 15:01 ` Jan Kiszka
2012-01-26 19:01 ` [Qemu-devel] [PATCH 15/15] i440fx: move ram initialization into i440fx-pmc Anthony Liguori
2012-01-26 19:12 ` [Qemu-devel] [RFC 00/15] Refactor PC machine to take advantage of QOM Peter Maydell
2012-01-26 19:36 ` Anthony Liguori
2012-01-29 10:42 ` Avi Kivity
2012-01-26 19:57 ` Markus Armbruster
2012-01-26 20:00 ` Anthony Liguori
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1327604460-31142-15-git-send-email-aliguori@us.ibm.com \
--to=aliguori@us.ibm.com \
--cc=armbru@redhat.com \
--cc=avi@redhat.com \
--cc=jan.kiszka@siemens.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).