Skip to contentSkip to conversation

remove target ifdefs from vl.c

PATCH In review Glauber Costa 2 participants 2 messages Apr 29, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 remove target ifdefs from vl.c

This patch goes towards the direction of increasing general modularity of the code. Code in vl.c that used to live inside target ifdefs, are moved to inside the target directories, in a new file called machine.c. They are the cpu save/load and machine registration

---
 Makefile.target        |    5 +-
 hw/boards.h            |    1 +
 target-arm/machine.c   |  211 +++++++++++++++++
 target-cris/machine.c  |    7 +
 target-i386/machine.c  |  264 +++++++++++++++++++++
 target-m68k/machine.c  |    9 +
 target-mips/machine.c  |   21 ++
 target-ppc/machine.c   |   20 ++
 target-sh4/machine.c   |    8 +
 target-sparc/machine.c |  102 ++++++++
 vl.c                   |  616 ------------------------------------------------
 11 files changed, 647 insertions(+), 617 deletions(-)
 create mode 100644 target-arm/machine.c
 create mode 100644 target-cris/machine.c
 create mode 100644 target-i386/machine.c
 create mode 100644 target-m68k/machine.c
 create mode 100644 target-mips/machine.c
 create mode 100644 target-ppc/machine.c
 create mode 100644 target-sh4/machine.c
 create mode 100644 target-sparc/machine.c
Makefile.target +4 -1
index 5ac29a7..a530ee5 100644
@@ -303,6 +303,9 @@ gen-op.h: op.o $(DYNGEN)
 op.o: op.c
 	$(CC) $(OP_CFLAGS) $(CPPFLAGS) -c -o $@ $<
 
+machine.o: machine.c
+	$(CC) $(OP_CFLAGS) $(CPPFLAGS) -c -o $@ $<
+
 # HELPER_CFLAGS is used for all the code compiled with static register
 # variables
 ifeq ($(TARGET_BASE_ARCH), i386)
@@ -481,7 +484,7 @@ endif #CONFIG_DARWIN_USER
 # System emulator target
 ifndef CONFIG_USER_ONLY
 
-OBJS=vl.o osdep.o monitor.o pci.o loader.o isa_mmio.o
+OBJS=vl.o osdep.o monitor.o pci.o loader.o isa_mmio.o machine.o
 ifdef CONFIG_WIN32
 OBJS+=block-raw-win32.o
 else
hw/boards.h +1 -0
index affcaa6..ada4664 100644
@@ -18,6 +18,7 @@ typedef struct QEMUMachine {
 } QEMUMachine;
 
 int qemu_register_machine(QEMUMachine *m);
+void register_machines(void);
 
 /* Axis ETRAX.  */
 extern QEMUMachine bareetraxfs_machine;
target-arm/machine.c new file +211 -0

211 lines not on this page · raw message

target-cris/machine.c new file +7 -0
new file mode 100644
index 0000000..cbfa645
@@ -0,0 +1,7 @@
+#include "hw/hw.h"
+#include "hw/boards.h"
+
+void register_machines(void)
+{
+    qemu_register_machine(&bareetraxfs_machine);
+}
target-i386/machine.c new file +264 -0

264 lines not on this page · raw message

target-m68k/machine.c new file +9 -0
new file mode 100644
index 0000000..fbdcac9
@@ -0,0 +1,9 @@
+#include "hw/hw.h"
+#include "hw/boards.h"
+
+void register_machines(void)
+{
+    qemu_register_machine(&mcf5208evb_machine);
+    qemu_register_machine(&an5206_machine);
+    qemu_register_machine(&dummy_m68k_machine);
+}
target-mips/machine.c new file +21 -0
new file mode 100644
index 0000000..ba01070
@@ -0,0 +1,21 @@
+#include "hw/hw.h"
+#include "hw/boards.h"
+
+void register_machines(void)
+{
+    qemu_register_machine(&mips_machine);
+    qemu_register_machine(&mips_malta_machine);
+    qemu_register_machine(&mips_pica61_machine);
+    qemu_register_machine(&mips_mipssim_machine);
+}
+
+void cpu_save(QEMUFile *f, void *opaque)
+{
+}
+
+int cpu_load(QEMUFile *f, void *opaque, int version_id)
+{
+    return 0;
+}
+
+
target-ppc/machine.c new file +20 -0
new file mode 100644
index 0000000..be0cbe1
@@ -0,0 +1,20 @@
+#include "hw/hw.h"
+#include "hw/boards.h"
+
+void register_machines(void)
+{
+    qemu_register_machine(&heathrow_machine);
+    qemu_register_machine(&core99_machine);
+    qemu_register_machine(&prep_machine);
+    qemu_register_machine(&ref405ep_machine);
+    qemu_register_machine(&taihu_machine);
+}
+
+void cpu_save(QEMUFile *f, void *opaque)
+{
+}
+
+int cpu_load(QEMUFile *f, void *opaque, int version_id)
+{
+    return 0;
+}
target-sh4/machine.c new file +8 -0
new file mode 100644
index 0000000..2d78aae
@@ -0,0 +1,8 @@
+#include "hw/hw.h"
+#include "hw/boards.h"
+
+void register_machines(void)
+{
+    qemu_register_machine(&shix_machine);
+    qemu_register_machine(&r2d_machine);
+}
target-sparc/machine.c new file +102 -0

102 lines not on this page · raw message

vl.c +0 -616

628 lines not on this page · raw message

Signature · 8 lines
1.5.0.6


-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
#1 lore raw
Quoted 4 lines · Glauber Costa

This patch goes towards the direction of increasing general modularity of the
code. Code in vl.c that used to live inside target ifdefs, are moved to inside the target directories, in a new file called machine.c. They are the cpu save/load and machine registration

Good idea, I had a similar patch to move cpu save/load to target-*/helper.c but I postponed it because it would make the libqemu.a depend on vl.c.

Quoted 82 lines

---

  Makefile.target        |    5 +-
  hw/boards.h            |    1 +
  target-arm/machine.c   |  211 +++++++++++++++++
  target-cris/machine.c  |    7 +
  target-i386/machine.c  |  264 +++++++++++++++++++++
  target-m68k/machine.c  |    9 +
  target-mips/machine.c  |   21 ++
  target-ppc/machine.c   |   20 ++
  target-sh4/machine.c   |    8 +
  target-sparc/machine.c |  102 ++++++++
  vl.c                   |  616 ------------------------------------------------
  11 files changed, 647 insertions(+), 617 deletions(-)

create mode 100644 target-arm/machine.c
create mode 100644 target-cris/machine.c
create mode 100644 target-i386/machine.c
create mode 100644 target-m68k/machine.c
create mode 100644 target-mips/machine.c
create mode 100644 target-ppc/machine.c
create mode 100644 target-sh4/machine.c
create mode 100644 target-sparc/machine.c

diff --git a/Makefile.target b/Makefile.target
index 5ac29a7..a530ee5 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -303,6 +303,9 @@ gen-op.h: op.o $(DYNGEN)
op.o: op.c

        $(CC) $(OP_CFLAGS) $(CPPFLAGS) -c -o $@ $<

+machine.o: machine.c
+ $(CC) $(OP_CFLAGS) $(CPPFLAGS) -c -o $@ $<
+
# HELPER_CFLAGS is used for all the code compiled with static register

  # variables
  ifeq ($(TARGET_BASE_ARCH), i386)
 @@ -481,7 +484,7 @@ endif #CONFIG_DARWIN_USER
  # System emulator target
  ifndef CONFIG_USER_ONLY

-OBJS=vl.o osdep.o monitor.o pci.o loader.o isa_mmio.o +OBJS=vl.o osdep.o monitor.o pci.o loader.o isa_mmio.o machine.o
ifdef CONFIG_WIN32
OBJS+=block-raw-win32.o
else
diff --git a/hw/boards.h b/hw/boards.h
index affcaa6..ada4664 100644
--- a/hw/boards.h
+++ b/hw/boards.h
@@ -18,6 +18,7 @@ typedef struct QEMUMachine {
} QEMUMachine;

int qemu_register_machine(QEMUMachine *m);
+void register_machines(void);

/* Axis ETRAX. */
extern QEMUMachine bareetraxfs_machine;
diff --git a/target-arm/machine.c b/target-arm/machine.c new file mode 100644
index 0000000..d8de189
--- /dev/null
+++ b/target-arm/machine.c
@@ -0,0 +1,211 @@
+#include "hw/hw.h"
+#include "hw/boards.h"
+
+void register_machines(void)
+{

 +    qemu_register_machine(&integratorcp_machine);
 +    qemu_register_machine(&versatilepb_machine);
 +    qemu_register_machine(&versatileab_machine);
 +    qemu_register_machine(&realview_machine);
 +    qemu_register_machine(&akitapda_machine);
 +    qemu_register_machine(&spitzpda_machine);
 +    qemu_register_machine(&borzoipda_machine);
 +    qemu_register_machine(&terrierpda_machine);
 +    qemu_register_machine(&palmte_machine);
 +    qemu_register_machine(&lm3s811evb_machine);
 +    qemu_register_machine(&lm3s6965evb_machine);
 +    qemu_register_machine(&connex_machine);
 +    qemu_register_machine(&verdex_machine);
 +    qemu_register_machine(&mainstone2_machine);
Quoted 1 line

+}

This list is a bit outdated and the new files lack licenses.

Regards

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone