From: "Hervé Poussineau" <hpoussin@reactos.org>
To: qemu-devel@nongnu.org
Cc: "Hervé Poussineau" <hpoussin@reactos.org>
Subject: [Qemu-devel] [PATCH 19/20] [MIPS] qdev: add a mips board device, which initializes the ram and the rom
Date: Sun, 1 Aug 2010 19:37:21 +0200 [thread overview]
Message-ID: <1280684242-19611-19-git-send-email-hpoussin@reactos.org> (raw)
In-Reply-To: <4C5579DA.8050508@reactos.org>
Also add an empty machine (to be used with the mips board device)
Finally, add a workaround to be able to create the initial system bus
Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
---
hw/mips_jazz.c | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
hw/qdev.c | 6 ++++
2 files changed, 84 insertions(+), 0 deletions(-)
diff --git a/hw/mips_jazz.c b/hw/mips_jazz.c
index 6daf76e..b4c95c9 100644
--- a/hw/mips_jazz.c
+++ b/hw/mips_jazz.c
@@ -37,6 +37,7 @@
#include "loader.h"
#include "mc146818rtc.h"
#include "rc4030.h"
+#include "sysbus.h"
enum jazz_model_e
{
@@ -274,6 +275,14 @@ void mips_pica61_init (ram_addr_t ram_size,
mips_jazz_init(ram_size, cpu_model, JAZZ_PICA61);
}
+static
+void empty_init (ram_addr_t ram_size,
+ const char *boot_device,
+ const char *kernel_filename, const char *kernel_cmdline,
+ const char *initrd_filename, const char *cpu_model)
+{
+}
+
static QEMUMachine mips_magnum_machine = {
.name = "magnum",
.desc = "MIPS Magnum",
@@ -288,10 +297,79 @@ static QEMUMachine mips_pica61_machine = {
.use_scsi = 1,
};
+static QEMUMachine empty_machine = {
+ .name = "empty",
+ .desc = "Empty machine",
+ .init = empty_init,
+};
+
static void mips_jazz_machine_init(void)
{
qemu_register_machine(&mips_magnum_machine);
qemu_register_machine(&mips_pica61_machine);
+ qemu_register_machine(&empty_machine);
}
machine_init(mips_jazz_machine_init);
+
+typedef struct MipsBoardState {
+ SysBusDevice busdev;
+
+ char *romfile;
+ uint32_t romsize;
+ uint32_t ramsize;
+} MipsBoardState;
+
+static int mips_board_device_init(SysBusDevice *dev)
+{
+ MipsBoardState *s = FROM_SYSBUS(MipsBoardState, dev);
+ int bios_size;
+ ram_addr_t ram_size;
+ ram_addr_t ram_offset;
+ ram_addr_t bios_offset;
+
+ /* allocate RAM */
+ ram_size = s->ramsize * 1024 * 1024;
+ ram_offset = qemu_ram_alloc(NULL, "mips_jazz.ram", ram_size);
+ cpu_register_physical_memory(0, ram_size, ram_offset | IO_MEM_RAM);
+
+ /* load the BIOS image */
+ if (s->romfile) {
+ bios_offset = qemu_ram_alloc(NULL, "mips_jazz.bios", s->romsize);
+ cpu_register_physical_memory(0x1fc00000LL,
+ s->romsize, bios_offset | IO_MEM_ROM);
+ cpu_register_physical_memory(0xfff00000LL,
+ s->romsize, bios_offset | IO_MEM_ROM);
+
+ bios_size = load_image_targphys(s->romfile,
+ 0x1fc00000LL,
+ s->romsize);
+
+ bios_size = load_image_targphys(s->romfile,
+ 0xfff00000LL,
+ s->romsize);
+ if (bios_size != s->romsize) {
+ return -1;
+ }
+ }
+ return 0;
+}
+
+static SysBusDeviceInfo board_device_info = {
+ .qdev.name = "mips-board",
+ .qdev.size = sizeof(MipsBoardState),
+ .init = mips_board_device_init,
+ .qdev.props = (Property[]) {
+ DEFINE_PROP_STRING("romfile", MipsBoardState, romfile),
+ DEFINE_PROP_HEX32("romsize", MipsBoardState, romsize, 0x40000),
+ DEFINE_PROP_UINT32("ramsize", MipsBoardState, ramsize, 64),
+ DEFINE_PROP_END_OF_LIST(),
+ },
+};
+
+static void mips_register_devices(void)
+{
+ sysbus_register_withprop(&board_device_info);
+}
+
+device_init(mips_register_devices)
diff --git a/hw/qdev.c b/hw/qdev.c
index e99c73f..f907385 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -455,6 +455,12 @@ static BusState *qbus_find_recursive(BusState *bus, const char *name,
BusState *child, *ret;
int match = 1;
+ if (!bus) {
+ if (!main_system_bus) {
+ main_system_bus = qbus_create(&system_bus_info, NULL, "main-system-bus");
+ }
+ return main_system_bus;
+ }
if (name && (strcmp(bus->name, name) != 0)) {
match = 0;
}
--
1.7.1.GIT
next prev parent reply other threads:[~2010-08-01 18:11 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-01 13:42 [Qemu-devel] [PATCH 00/20] MIPS Magnum conversion to qdev Hervé Poussineau
2010-08-01 17:37 ` [Qemu-devel] [PATCH 01/20] [MIPS] cpu: add a init inplace method Hervé Poussineau
2010-08-01 17:37 ` [Qemu-devel] [PATCH 02/20] [MIPS] cpu: convert to qdev Hervé Poussineau
2010-08-01 17:37 ` [Qemu-devel] [PATCH 03/20] [MIPS] Jazz emulation: create a qdev cpu Hervé Poussineau
2010-08-01 17:37 ` [Qemu-devel] [PATCH 04/20] [MIPS] rc4030: convert to qdev Hervé Poussineau
2010-08-01 17:37 ` [Qemu-devel] [PATCH 05/20] Add a stub for some rc4030 functions, if rc4030 support is not compiled in Hervé Poussineau
2010-08-01 17:37 ` [Qemu-devel] [PATCH 06/20] [MIPS] qdev: convert i8042 to rc4030 device Hervé Poussineau
2010-08-01 17:37 ` [Qemu-devel] [PATCH 07/20] [MIPS] qdev: convert parallel port " Hervé Poussineau
2010-08-01 17:37 ` [Qemu-devel] [PATCH 08/20] [MIPS] qdev: convert serial " Hervé Poussineau
2010-08-01 17:37 ` [Qemu-devel] [PATCH 09/20] [MIPS] qdev: convert jazz-led to sysbus device Hervé Poussineau
2010-08-01 17:37 ` [Qemu-devel] [PATCH 10/20] [MIPS] Jazz emulation: make video card optional Hervé Poussineau
2010-08-01 17:37 ` [Qemu-devel] [PATCH 11/20] [MIPS] qdev: convert vga-isa-mm to ISA device Hervé Poussineau
2010-08-01 17:37 ` [Qemu-devel] [PATCH 12/20] [MIPS] qdev: convert g364fb to rc4030 device Hervé Poussineau
2010-08-01 17:37 ` [Qemu-devel] [PATCH 13/20] [MIPS] qdev: add a rtc forwarder device Hervé Poussineau
2010-08-01 17:37 ` [Qemu-devel] [PATCH 14/20] [MIPS] qdev: add an isa bus device Hervé Poussineau
2010-08-01 17:37 ` [Qemu-devel] [PATCH 15/20] [MIPS] qdev: convert dp83932 network card to rc4030 device Hervé Poussineau
2010-08-01 17:37 ` [Qemu-devel] [PATCH 16/20] [MIPS] qdev: convert floppy disk controller " Hervé Poussineau
2010-08-01 17:37 ` [Qemu-devel] [PATCH 17/20] [MIPS] qdev: convert esp scsi adapter " Hervé Poussineau
2010-08-02 14:51 ` Artyom Tarasenko
2010-08-01 17:37 ` [Qemu-devel] [PATCH 18/20] [MIPS] qdev: convert ds1225y nvram to sysbus device Hervé Poussineau
2010-08-01 17:37 ` Hervé Poussineau [this message]
2010-08-01 17:37 ` [Qemu-devel] [PATCH 20/20] [MIPS] qdev: Complete rc4030 conversion, by removing legacy stuff Hervé Poussineau
2010-08-02 16:06 ` [Qemu-devel] [PATCH 00/20] MIPS Magnum conversion to qdev Blue Swirl
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=1280684242-19611-19-git-send-email-hpoussin@reactos.org \
--to=hpoussin@reactos.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.