Skip to contentSkip to conversation

target-ppc: MacIO QOM'ification

RFC In review Andreas Färber 4 participants 24 messages Jan 13, 2013 – Jan 19, 2013

lore
Share & tools
lore
#0 lore raw

v3 cover target-ppc: MacIO QOM'ification

Hello,

As requested by Markus, here's a conversion of MacIO IDE to QOM. There's more work to be done, but in light of the approaching Soft Freeze here's my current state of affairs, lightly tested.

Patch 1 is a generic QOM API fix and could be applied independent of the ppc device conversion.

Patch 2 goes on to move PowerMac machines to hw/ppc/ as discussed with Alex. The intent would be to do the same for PReP once applied.

The remainder revives an old patch from the time of QOM introduction to split MacIO in two, allowing to move more logic into the device from the machine. This time it adopts new QOM concepts for embedding the sub-devices converted in the following patches. TODO: finalization support / object_unref().

ADB is still being worked on. DBDMA still TODO (but then again so is x86 DMA). ESCC would affect sparc as well.
The PICs pose cyclic dependency issues (mapped inside MacIO but MacIO as a PCIDevice needing a PCIBus, the Grackle/UniNorth PHBs needing a PIC IRQ).

Regards,
Andreas

v2 -> v3:
* Redone using QOM, split up into three patches for better reviewability.
* Added QOM'ification patches for NVRAM, IDE and CUDA.

v1 -> v2:
* qdev'ification patch was ignored for QOM 2nd series: Rebased onto Anthony's.

Cc Alexander Graf <[email protected]>
Cc qemu-ppc <[email protected]>
Cc Markus Armbruster <[email protected]>
Cc Kevin Wolf <[email protected]>
Cc Blue Swirl <[email protected]>
Cc Hervé Poussineau <[email protected]>

Andreas Färber (10):
qom: Make object_resolve_path_component() path argument const
ppc: Move Mac machines to hw/ppc/
macio: QOM'ify some more
macio: Delay qdev init until all fields are initialized
macio: Split MacIO in two
mac_nvram: Clean up public API
mac_nvram: Mark as Big Endian
mac_nvram: QOM'ify MacIO NVRAM
ide/macio: QOM'ify MacIO IDE
cuda: QOM'ify CUDA

 hw/cuda.c                                 |  100 +++++-----
 hw/grackle_pci.c                          |    2 +-
 hw/heathrow_pic.c                         |    2 +-
 hw/ide.h                                  |    4 -
 hw/ide/macio.c                            |   87 ++++++---
 hw/mac_nvram.c                            |   82 ++++----
 hw/macio.c                                |  289 ++++++++++++++++++++++-------
 hw/openpic.c                              |    2 +-
 hw/ppc/Makefile.objs                      |    9 +-
 hw/ppc/mac.h                              |  179 ++++++++++++++++++
 hw/{ppc_newworld.c => ppc/mac_newworld.c} |   65 ++++---
 hw/{ppc_oldworld.c => ppc/mac_oldworld.c} |   56 +++---
 hw/ppc_mac.h                              |   81 --------
 hw/unin_pci.c                             |    2 +-
 include/qom/object.h                      |    2 +-
 qom/object.c                              |    2 +-
 16 Dateien geändert, 636 Zeilen hinzugefügt(+), 328 Zeilen entfernt(-)
 create mode 100644 hw/ppc/mac.h
 rename hw/{ppc_newworld.c => ppc/mac_newworld.c} (91%)
 rename hw/{ppc_oldworld.c => ppc/mac_oldworld.c} (92%)
 delete mode 100644 hw/ppc_mac.h
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH v3 1/10 qom: Make object_resolve_path_component() path argument const

This allows to navigate partial well-known paths from an object.

---
 include/qom/object.h |    2 +-
 qom/object.c         |    2 +-

2 Dateien geändert, 2 Zeilen hinzugefügt(+), 2 Zeilen entfernt(-)

include/qom/object.h +1 -1
index d43b289..1ef2f0e 100644
@@ -900,7 +900,7 @@ Object *object_resolve_path_type(const char *path, const char *typename,
  *
  * Returns: The resolved object or NULL on path lookup failure.
  */
-Object *object_resolve_path_component(Object *parent, gchar *part);
+Object *object_resolve_path_component(Object *parent, const gchar *part);
 
 /**
  * object_property_add_child:
qom/object.c +1 -1
index 351b88c..03e6f24 100644
@@ -1017,7 +1017,7 @@ gchar *object_get_canonical_path(Object *obj)
     return newpath;
 }
 
-Object *object_resolve_path_component(Object *parent, gchar *part)
+Object *object_resolve_path_component(Object *parent, const gchar *part)
 {
     ObjectProperty *prop = object_property_find(parent, part, NULL);
     if (prop == NULL) {
Signature · 1 line
1.7.10.4
#2 lore raw

Re: [Qemu-devel] [PATCH 01/10] qom: Make object_resolve_path_component() path argument const

Quoted 1 line · Andreas Färber

This allows to navigate partial well-known paths from an object.

Why does making the argument const allow such navigation?

Quoted 24 lines
---
 include/qom/object.h |    2 +-
 qom/object.c         |    2 +-

2 Dateien geändert, 2 Zeilen hinzugefügt(+), 2 Zeilen entfernt(-)

include/qom/object.h +1 -1
index d43b289..1ef2f0e 100644
@@ -900,7 +900,7 @@ Object *object_resolve_path_type(const char *path, const char *typename,
  *
  * Returns: The resolved object or NULL on path lookup failure.
  */
-Object *object_resolve_path_component(Object *parent, gchar *part);
+Object *object_resolve_path_component(Object *parent, const gchar *part);
 /**
  * object_property_add_child:
qom/object.c +0 -0
index 351b88c..03e6f24 100644

qom/object.c gchar *object_get_canonical_path(Object *obj) · line 1023

Quoted 8 lines
qom/object.c +1 -1
@@ -1017,7 +1017,7 @@ gchar *object_get_canonical_path(Object *obj)
     return newpath;
 }
 
-Object *object_resolve_path_component(Object *parent, gchar *part)
+Object *object_resolve_path_component(Object *parent, const gchar *part)
 {
     ObjectProperty *prop = object_property_find(parent, part, NULL);
     if (prop == NULL) {

Unrelated: do we really want to go along with glib's basic type typedef silliness?

#3 lore raw

Re: [Qemu-devel] [PATCH 01/10] qom: Make object_resolve_path_component() path argument const

Am 14.01.2013 13:19, schrieb Markus Armbruster:

Quoted 5 lines
Quoted 1 line · Andreas Färber

This allows to navigate partial well-known paths from an object.

Why does making the argument const allow such navigation?

Without const, object_resolve_path_component(foo, "bar") results in a compile error (09/10 accesses "ide[1]" etc. to avoid exposing the full MacIOState).

Apparently this function was so far only used on dynamically generated (non-const) arrays:

qom/container.c: child = object_resolve_path_component(obj,
parts[i]);
qom/object.c: child = object_resolve_path_component(parent,
parts[index]);

Quoted 27 lines
Quoted 27 lines
---
 include/qom/object.h |    2 +-
 qom/object.c         |    2 +-

2 Dateien geändert, 2 Zeilen hinzugefügt(+), 2 Zeilen entfernt(-)

include/qom/object.h +1 -1
index d43b289..1ef2f0e 100644
@@ -900,7 +900,7 @@ Object *object_resolve_path_type(const char *path, const char *typename,
  *
  * Returns: The resolved object or NULL on path lookup failure.
  */
-Object *object_resolve_path_component(Object *parent, gchar *part);
+Object *object_resolve_path_component(Object *parent, const gchar *part);
 /**
  * object_property_add_child:
qom/object.c +0 -0
index 351b88c..03e6f24 100644
@@ -1017,7 +1017,7 @@ gchar *object_get_canonical_path(Object *obj)
     return newpath;
 }
 
Quoted 8 lines

qom/object.c gchar *object_get_canonical_path(Object *obj) · line 1023

Quoted 5 lines
qom/object.c +1 -1
-Object *object_resolve_path_component(Object *parent, gchar *part)
+Object *object_resolve_path_component(Object *parent, const gchar *part)
 {
     ObjectProperty *prop = object_property_find(parent, part, NULL);
     if (prop == NULL) {

Unrelated: do we really want to go along with glib's basic type typedef silliness?

Elsewhere I have adopted the exact GLib signature since typedefs can be changed at any time. In particular the GCompareFunc using gconstpointer, gint, etc. Not saying I find their GLib usage useful.

I admit I didn't review object_property_find(), which uses const char*. So I wouldn't mind sending a v2 if non-g is preferred. Or Anthony or Stefan could just edit the patch in my name before applying. :)

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#4 lore raw

Re: [Qemu-devel] [PATCH 01/10] qom: Make object_resolve_path_component() path argument const

Quoted 11 lines · Andreas Färber

Am 14.01.2013 13:19, schrieb Markus Armbruster:

Quoted 5 lines
Quoted 1 line · Andreas Färber

This allows to navigate partial well-known paths from an object.

Why does making the argument const allow such navigation?

Without const, object_resolve_path_component(foo, "bar") results in a compile error (09/10 accesses "ide[1]" etc. to avoid exposing the full MacIOState).

Quoted 7 lines

Apparently this function was so far only used on dynamically generated (non-const) arrays:

qom/container.c: child = object_resolve_path_component(obj,
parts[i]);
qom/object.c: child = object_resolve_path_component(parent,
parts[index]);

Makes sense, but isn't immediately obvious from your commit message. What about:

qom: Make object_resolve_path_component() path argument const

Navigating well-known paths from an object like

object_resolve_path_component(foo, "bar")

is perfectly legitimate, but doesn't compile, because the second parameter lacks const. Fix that.

#5 lore raw

[Qemu-devel] Go along with glib's basic type typedef silliness? (was: [PATCH 01/10] qom: Make object_resolve_path_component() path argument const)

In reply to Andreas Färber

[Thread hijack, dropping cc: qemu-trivial, qemu-ppc]

Quoted 2 lines · Andreas Färber

Am 14.01.2013 13:19, schrieb Markus Armbruster:

Quoted 1 line

Andreas Färber <[email protected]> writes:

[...]

Quoted 17 lines
Quoted 8 lines
Quoted 8 lines
qom/object.c +0 -0
index 351b88c..03e6f24 100644
@@ -1017,7 +1017,7 @@ gchar *object_get_canonical_path(Object *obj)
     return newpath;
 }
 
Quoted 8 lines

qom/object.c gchar *object_get_canonical_path(Object *obj) · line 1023

Quoted 5 lines
qom/object.c +1 -1
-Object *object_resolve_path_component(Object *parent, gchar *part)
+Object *object_resolve_path_component(Object *parent, const gchar *part)
 {
     ObjectProperty *prop = object_property_find(parent, part, NULL);
     if (prop == NULL) {

Unrelated: do we really want to go along with glib's basic type typedef silliness?

Quoted 3 lines

Elsewhere I have adopted the exact GLib signature since typedefs can be changed at any time. In particular the GCompareFunc using gconstpointer, gint, etc. Not saying I find their GLib usage useful.

No, these typedefs cannot be changed.

Firstly, their exact definitions are documented[*], therefore can be relied on.

Secondly, mountains of code rely on the exact definitions, and would break left and right if they were changed.

They're a textbook example of a perfectly useless pseudo-abstraction.

[...]

[*] http://developer.gnome.org/glib/stable/glib-Basic-Types.html

#6 lore raw

Re: [Qemu-devel] Go along with glib's basic type typedef silliness? (was: [PATCH 01/10] qom: Make object_resolve_path_component() path argument const)

Quoted 30 lines · Markus Armbruster

[Thread hijack, dropping cc: qemu-trivial, qemu-ppc]

Quoted 2 lines · Andreas Färber

Am 14.01.2013 13:19, schrieb Markus Armbruster:

Quoted 1 line

Andreas Färber <[email protected]> writes:

[...]

Quoted 17 lines
Quoted 8 lines
Quoted 8 lines
qom/object.c +0 -0
index 351b88c..03e6f24 100644
@@ -1017,7 +1017,7 @@ gchar *object_get_canonical_path(Object *obj)
     return newpath;
 }
 
Quoted 8 lines

qom/object.c gchar *object_get_canonical_path(Object *obj) · line 1023

Quoted 5 lines
qom/object.c +1 -1
-Object *object_resolve_path_component(Object *parent, gchar *part)
+Object *object_resolve_path_component(Object *parent, const gchar *part)
 {
     ObjectProperty *prop = object_property_find(parent, part, NULL);
     if (prop == NULL) {

Unrelated: do we really want to go along with glib's basic type typedef silliness?

Quoted 3 lines

Elsewhere I have adopted the exact GLib signature since typedefs can be changed at any time. In particular the GCompareFunc using gconstpointer, gint, etc. Not saying I find their GLib usage useful.

No, these typedefs cannot be changed.

Quoted 7 lines

Firstly, their exact definitions are documented[*], therefore can be relied on.

Secondly, mountains of code rely on the exact definitions, and would break left and right if they were changed.

They're a textbook example of a perfectly useless pseudo-abstraction.

CONST, WORD, PWORD, DWORD, FLOAT etc. in a certain platform...

Quoted 6 lines

[...]

[*] http://developer.gnome.org/glib/stable/glib-Basic-Types.html

#7 lore raw

Re: [Qemu-devel] Go along with glib's basic type typedef silliness?

Quoted 34 lines · Blue Swirl
Quoted 33 lines · Markus Armbruster

[Thread hijack, dropping cc: qemu-trivial, qemu-ppc]

Quoted 2 lines · Andreas Färber

Am 14.01.2013 13:19, schrieb Markus Armbruster:

Quoted 1 line

Andreas Färber <[email protected]> writes:

[...]

Quoted 17 lines
Quoted 8 lines
Quoted 8 lines
qom/object.c +0 -0
index 351b88c..03e6f24 100644
@@ -1017,7 +1017,7 @@ gchar *object_get_canonical_path(Object *obj)
     return newpath;
 }
 
Quoted 8 lines

qom/object.c gchar *object_get_canonical_path(Object *obj) · line 1023

Quoted 5 lines
qom/object.c +1 -1
-Object *object_resolve_path_component(Object *parent, gchar *part)
+Object *object_resolve_path_component(Object *parent, const gchar *part)
 {
     ObjectProperty *prop = object_property_find(parent, part, NULL);
     if (prop == NULL) {

Unrelated: do we really want to go along with glib's basic type typedef silliness?

Quoted 3 lines

Elsewhere I have adopted the exact GLib signature since typedefs can be changed at any time. In particular the GCompareFunc using gconstpointer, gint, etc. Not saying I find their GLib usage useful.

No, these typedefs cannot be changed.

Firstly, their exact definitions are documented[*], therefore can be relied on.

Quoted 6 lines
Quoted 4 lines

Secondly, mountains of code rely on the exact definitions, and would break left and right if they were changed.

They're a textbook example of a perfectly useless pseudo-abstraction.

CONST, WORD, PWORD, DWORD, FLOAT etc. in a certain platform...

MY EYES, MY EYES, WHAT DID YOU DO TO MY EYES!!!

[...]

#8 lore raw

Re: [Qemu-devel] Go along with glib's basic type typedef silliness?

Quoted 36 lines · Markus Armbruster
Quoted 34 lines · Blue Swirl
Quoted 33 lines · Markus Armbruster

[Thread hijack, dropping cc: qemu-trivial, qemu-ppc]

Quoted 2 lines · Andreas Färber

Am 14.01.2013 13:19, schrieb Markus Armbruster:

Quoted 1 line

Andreas Färber <[email protected]> writes:

[...]

Quoted 17 lines
Quoted 8 lines
Quoted 8 lines
qom/object.c +0 -0
index 351b88c..03e6f24 100644
@@ -1017,7 +1017,7 @@ gchar *object_get_canonical_path(Object *obj)
     return newpath;
 }
 
Quoted 8 lines

qom/object.c gchar *object_get_canonical_path(Object *obj) · line 1023

Quoted 5 lines
qom/object.c +1 -1
-Object *object_resolve_path_component(Object *parent, gchar *part)
+Object *object_resolve_path_component(Object *parent, const gchar *part)
 {
     ObjectProperty *prop = object_property_find(parent, part, NULL);
     if (prop == NULL) {

Unrelated: do we really want to go along with glib's basic type typedef silliness?

Quoted 3 lines

Elsewhere I have adopted the exact GLib signature since typedefs can be changed at any time. In particular the GCompareFunc using gconstpointer, gint, etc. Not saying I find their GLib usage useful.

No, these typedefs cannot be changed.

Firstly, their exact definitions are documented[*], therefore can be relied on.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

Secondly, mountains of code rely on the exact definitions, and would break left and right if they were changed.

They're a textbook example of a perfectly useless pseudo-abstraction.

CONST, WORD, PWORD, DWORD, FLOAT etc. in a certain platform...

MY EYES, MY EYES, WHAT DID YOU DO TO MY EYES!!!

Leishmaniasis Capslockititis Fenestrae? :-D

Quoted 2 lines

[...]

#9 lore raw

RFC v3 2/10 ppc: Move Mac machines to hw/ppc/

In reply to Andreas Färber
---
 hw/cuda.c                                 |    2 +-
 hw/grackle_pci.c                          |    2 +-
 hw/heathrow_pic.c                         |    2 +-
 hw/ide/macio.c                            |    6 +++---
 hw/mac_nvram.c                            |    2 +-
 hw/macio.c                                |    2 +-
 hw/openpic.c                              |    2 +-
 hw/ppc/Makefile.objs                      |    9 +++++----
 hw/{ppc_mac.h => ppc/mac.h}               |    0
 hw/{ppc_newworld.c => ppc/mac_newworld.c} |   28 ++++++++++++++--------------
 hw/{ppc_oldworld.c => ppc/mac_oldworld.c} |   26 +++++++++++++-------------
 hw/unin_pci.c                             |    2 +-
 12 Dateien geändert, 42 Zeilen hinzugefügt(+), 41 Zeilen entfernt(-)
 rename hw/{ppc_mac.h => ppc/mac.h} (100%)
 rename hw/{ppc_newworld.c => ppc/mac_newworld.c} (98%)
 rename hw/{ppc_oldworld.c => ppc/mac_oldworld.c} (97%)
hw/cuda.c +1 -1
index d59e0ae..bbd1fda 100644
@@ -23,7 +23,7 @@
  * THE SOFTWARE.
  */
 #include "hw.h"
-#include "ppc_mac.h"
+#include "ppc/mac.h"
 #include "adb.h"
 #include "qemu/timer.h"
 #include "sysemu/sysemu.h"
hw/grackle_pci.c +1 -1
index 9484166..95639d5 100644
@@ -24,7 +24,7 @@
  */
 
 #include "pci/pci_host.h"
-#include "ppc_mac.h"
+#include "ppc/mac.h"
 #include "pci/pci.h"
 
 /* debug Grackle */
hw/heathrow_pic.c +1 -1
index b9ec8e7..c0a71c3 100644
@@ -23,7 +23,7 @@
  * THE SOFTWARE.
  */
 #include "hw.h"
-#include "ppc_mac.h"
+#include "ppc/mac.h"
 
 /* debug PIC */
 //#define DEBUG_PIC
hw/ide/macio.c +3 -3
index d8f9b4b..e0f04dc 100644
@@ -22,9 +22,9 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
-#include <hw/hw.h>
-#include <hw/ppc_mac.h>
-#include <hw/mac_dbdma.h>
+#include "hw/hw.h"
+#include "hw/ppc/mac.h"
+#include "hw/mac_dbdma.h"
 #include "block/block.h"
 #include "sysemu/dma.h"
 
hw/mac_nvram.c +1 -1
index 71093c2..eec7ca4 100644
@@ -25,7 +25,7 @@
 #include "hw.h"
 #include "firmware_abi.h"
 #include "sysemu/sysemu.h"
-#include "ppc_mac.h"
+#include "ppc/mac.h"
 
 /* debug NVR */
 //#define DEBUG_NVR
hw/macio.c +1 -1
index 675a71c..f01fc57 100644
@@ -23,7 +23,7 @@
  * THE SOFTWARE.
  */
 #include "hw.h"
-#include "ppc_mac.h"
+#include "ppc/mac.h"
 #include "pci/pci.h"
 #include "escc.h"
 
hw/openpic.c +1 -1
index 23fa8f9..7423685 100644
@@ -34,7 +34,7 @@
  *
  */
 #include "hw.h"
-#include "ppc_mac.h"
+#include "ppc/mac.h"
 #include "pci/pci.h"
 #include "openpic.h"
 #include "sysbus.h"
hw/ppc/Makefile.objs +5 -4
index afdcc0e..462146b 100644
@@ -3,10 +3,6 @@ obj-y = ppc.o ppc_booke.o
 # PREP target
 obj-y += mc146818rtc.o
 obj-y += ppc_prep.o
-# OldWorld PowerMac
-obj-y += ppc_oldworld.o
-# NewWorld PowerMac
-obj-y += ppc_newworld.o
 # IBM pSeries (sPAPR)
 obj-$(CONFIG_PSERIES) += spapr.o spapr_hcall.o spapr_rtas.o spapr_vio.o
 obj-$(CONFIG_PSERIES) += xics.o spapr_vty.o spapr_llan.o spapr_vscsi.o
@@ -28,4 +24,9 @@ obj-y += xilinx_ethlite.o
 
 obj-y := $(addprefix ../,$(obj-y))
 
+# OldWorld PowerMac
+obj-y += mac_oldworld.o
+# NewWorld PowerMac
+obj-y += mac_newworld.o
+# e500
 obj-$(CONFIG_FDT) += e500.o mpc8544ds.o e500plat.o
hw/ppc/mac.h renamed from hw/ppc_mac.h +0 -0
similarity index 100%
rename from hw/ppc_mac.h
rename to hw/ppc/mac.h
hw/ppc/mac_newworld.c renamed from hw/ppc_newworld.c +14 -14
similarity index 98%
rename from hw/ppc_newworld.c
rename to hw/ppc/mac_newworld.c
index fabcc08..adf111c 100644
@@ -46,28 +46,28 @@
  * 0001:05:0c.0 IDE interface [0101]: Broadcom K2 SATA [1166:0240]
  *
  */
-#include "hw.h"
-#include "ppc.h"
-#include "ppc_mac.h"
-#include "adb.h"
-#include "mac_dbdma.h"
-#include "nvram.h"
-#include "pci/pci.h"
+#include "hw/hw.h"
+#include "hw/ppc.h"
+#include "hw/ppc/mac.h"
+#include "hw/adb.h"
+#include "hw/mac_dbdma.h"
+#include "hw/nvram.h"
+#include "hw/pci/pci.h"
 #include "net/net.h"
 #include "sysemu/sysemu.h"
-#include "boards.h"
-#include "fw_cfg.h"
-#include "escc.h"
-#include "openpic.h"
-#include "ide.h"
-#include "loader.h"
+#include "hw/boards.h"
+#include "hw/fw_cfg.h"
+#include "hw/escc.h"
+#include "hw/openpic.h"
+#include "hw/ide.h"
+#include "hw/loader.h"
 #include "elf.h"
 #include "sysemu/kvm.h"
 #include "kvm_ppc.h"
 #include "hw/usb.h"
 #include "sysemu/blockdev.h"
 #include "exec/address-spaces.h"
-#include "sysbus.h"
+#include "hw/sysbus.h"
 
 #define MAX_IDE_BUS 2
 #define CFG_ADDR 0xf0000510
hw/ppc/mac_oldworld.c renamed from hw/ppc_oldworld.c +13 -13
similarity index 97%
rename from hw/ppc_oldworld.c
rename to hw/ppc/mac_oldworld.c
index fff5129..0d9f65b 100644
@@ -23,21 +23,21 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
-#include "hw.h"
-#include "ppc.h"
-#include "ppc_mac.h"
-#include "adb.h"
-#include "mac_dbdma.h"
-#include "nvram.h"
+#include "hw/hw.h"
+#include "hw/ppc.h"
+#include "mac.h"
+#include "hw/adb.h"
+#include "hw/mac_dbdma.h"
+#include "hw/nvram.h"
 #include "sysemu/sysemu.h"
 #include "net/net.h"
-#include "isa.h"
-#include "pci/pci.h"
-#include "boards.h"
-#include "fw_cfg.h"
-#include "escc.h"
-#include "ide.h"
-#include "loader.h"
+#include "hw/isa.h"
+#include "hw/pci/pci.h"
+#include "hw/boards.h"
+#include "hw/fw_cfg.h"
+#include "hw/escc.h"
+#include "hw/ide.h"
+#include "hw/loader.h"
 #include "elf.h"
 #include "sysemu/kvm.h"
 #include "kvm_ppc.h"
hw/unin_pci.c +1 -1
index 4675792..f1c3c20 100644
@@ -22,7 +22,7 @@
  * THE SOFTWARE.
  */
 #include "hw.h"
-#include "ppc_mac.h"
+#include "ppc/mac.h"
 #include "pci/pci.h"
 #include "pci/pci_host.h"
 
Signature · 1 line
1.7.10.4
#10 lore raw

RFC v3 3/10 macio: QOM'ify some more

In reply to Andreas Färber

Move bar MemoryRegion initialization to an instance_init.

---
 hw/macio.c |   25 +++++++++++++++++++------

1 Datei geändert, 19 Zeilen hinzugefügt(+), 6 Zeilen entfernt(-)

hw/macio.c +19 -6
index f01fc57..770e3bd 100644
@@ -27,9 +27,15 @@
 #include "pci/pci.h"
 #include "escc.h"
 
+#define TYPE_MACIO "macio"
+#define MACIO(obj) OBJECT_CHECK(MacIOState, (obj), TYPE_MACIO)
+
 typedef struct MacIOState
 {
+    /*< private >*/
     PCIDevice parent;
+    /*< public >*/
+
     int is_oldworld;
     MemoryRegion bar;
     MemoryRegion *pic_mem;
@@ -46,7 +52,6 @@ static void macio_bar_setup(MacIOState *macio_state)
     int i;
     MemoryRegion *bar = &macio_state->bar;
 
-    memory_region_init(bar, "macio", 0x80000);
     if (macio_state->pic_mem) {
         if (macio_state->is_oldworld) {
             /* Heathrow PIC */
@@ -81,6 +86,13 @@ static int macio_initfn(PCIDevice *d)
     return 0;
 }
 
+static void macio_instance_init(Object *obj)
+{
+    MacIOState *s = MACIO(obj);
+
+    memory_region_init(&s->bar, "macio", 0x80000);
+}
+
 static void macio_class_init(ObjectClass *klass, void *data)
 {
     PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
@@ -90,16 +102,17 @@ static void macio_class_init(ObjectClass *klass, void *data)
     k->class_id = PCI_CLASS_OTHERS << 8;
 }
 
-static const TypeInfo macio_info = {
-    .name          = "macio",
+static const TypeInfo macio_type_info = {
+    .name          = TYPE_MACIO,
     .parent        = TYPE_PCI_DEVICE,
     .instance_size = sizeof(MacIOState),
+    .instance_init = macio_instance_init,
     .class_init    = macio_class_init,
 };
 
 static void macio_register_types(void)
 {
-    type_register_static(&macio_info);
+    type_register_static(&macio_type_info);
 }
 
 type_init(macio_register_types)
@@ -114,9 +127,9 @@ void macio_init (PCIBus *bus, int device_id, int is_oldworld,
     MacIOState *macio_state;
     int i;
 
-    d = pci_create_simple(bus, -1, "macio");
+    d = pci_create_simple(bus, -1, TYPE_MACIO);
 
-    macio_state = DO_UPCAST(MacIOState, parent, d);
+    macio_state = MACIO(d);
     macio_state->is_oldworld = is_oldworld;
     macio_state->pic_mem = pic_mem;
     macio_state->dbdma_mem = dbdma_mem;
Signature · 1 line
1.7.10.4
#11 lore raw

RFC v3 4/10 macio: Delay qdev init until all fields are initialized

In reply to Andreas Färber

This turns macio_bar_setup() into an implementation detail of the qdev initfn, to be removed step by step.

---
 hw/macio.c |   11 ++++++++---

1 Datei geändert, 8 Zeilen hinzugefügt(+), 3 Zeilen entfernt(-)

hw/macio.c +8 -3
index 770e3bd..8b4b48d 100644
@@ -82,7 +82,13 @@ static void macio_bar_setup(MacIOState *macio_state)
 
 static int macio_initfn(PCIDevice *d)
 {
+    MacIOState *s = MACIO(d);
+
     d->config[0x3d] = 0x01; // interrupt on pin 1
+
+    macio_bar_setup(s);
+    pci_register_bar(d, 0, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->bar);
+
     return 0;
 }
 
@@ -127,7 +133,7 @@ void macio_init (PCIBus *bus, int device_id, int is_oldworld,
     MacIOState *macio_state;
     int i;
 
-    d = pci_create_simple(bus, -1, TYPE_MACIO);
+    d = pci_create(bus, -1, TYPE_MACIO);
 
     macio_state = MACIO(d);
     macio_state->is_oldworld = is_oldworld;
@@ -148,6 +154,5 @@ void macio_init (PCIBus *bus, int device_id, int is_oldworld,
 
     pci_config_set_device_id(d->config, device_id);
 
-    macio_bar_setup(macio_state);
-    pci_register_bar(d, 0, PCI_BASE_ADDRESS_SPACE_MEMORY, &macio_state->bar);
+    qdev_init_nofail(DEVICE(d));
 }
Signature · 1 line
1.7.10.4
#12 lore raw

RFC v3 5/10 macio: Split MacIO in two

In reply to Andreas Färber

Let the machines create two different types. This prepares to move knowledge about sub-devices from the machines into the devices.

---
 hw/macio.c            |   97 +++++++++++++++++++++++++++++++++++--------------
 hw/ppc/mac.h          |   10 +++--
 hw/ppc/mac_newworld.c |    4 +-
 hw/ppc/mac_oldworld.c |    4 +-

4 Dateien geändert, 82 Zeilen hinzugefügt(+), 33 Zeilen entfernt(-)

hw/macio.c +70 -27
index 8b4b48d..0e6fc8d 100644
@@ -36,7 +36,6 @@ typedef struct MacIOState
     PCIDevice parent;
     /*< public >*/
 
-    int is_oldworld;
     MemoryRegion bar;
     MemoryRegion *pic_mem;
     MemoryRegion *dbdma_mem;
@@ -52,15 +51,6 @@ static void macio_bar_setup(MacIOState *macio_state)
     int i;
     MemoryRegion *bar = &macio_state->bar;
 
-    if (macio_state->pic_mem) {
-        if (macio_state->is_oldworld) {
-            /* Heathrow PIC */
-            memory_region_add_subregion(bar, 0x00000, macio_state->pic_mem);
-        } else {
-            /* OpenPIC */
-            memory_region_add_subregion(bar, 0x40000, macio_state->pic_mem);
-        }
-    }
     if (macio_state->dbdma_mem) {
         memory_region_add_subregion(bar, 0x08000, macio_state->dbdma_mem);
     }
@@ -80,7 +70,7 @@ static void macio_bar_setup(MacIOState *macio_state)
         macio_nvram_setup_bar(macio_state->nvram, bar, 0x60000);
 }
 
-static int macio_initfn(PCIDevice *d)
+static int macio_common_initfn(PCIDevice *d)
 {
     MacIOState *s = MACIO(d);
 
@@ -92,6 +82,38 @@ static int macio_initfn(PCIDevice *d)
     return 0;
 }
 
+static int macio_oldworld_initfn(PCIDevice *d)
+{
+    MacIOState *s = MACIO(d);
+    int ret = macio_common_initfn(d);
+    if (ret < 0) {
+        return ret;
+    }
+
+    if (s->pic_mem) {
+        /* Heathrow PIC */
+        memory_region_add_subregion(&s->bar, 0x00000, s->pic_mem);
+    }
+
+    return 0;
+}
+
+static int macio_newworld_initfn(PCIDevice *d)
+{
+    MacIOState *s = MACIO(d);
+    int ret = macio_common_initfn(d);
+    if (ret < 0) {
+        return ret;
+    }
+
+    if (s->pic_mem) {
+        /* OpenPIC */
+        memory_region_add_subregion(&s->bar, 0x40000, s->pic_mem);
+    }
+
+    return 0;
+}
+
 static void macio_instance_init(Object *obj)
 {
     MacIOState *s = MACIO(obj);
@@ -99,44 +121,69 @@ static void macio_instance_init(Object *obj)
     memory_region_init(&s->bar, "macio", 0x80000);
 }
 
+static void macio_oldworld_class_init(ObjectClass *oc, void *data)
+{
+    PCIDeviceClass *pdc = PCI_DEVICE_CLASS(oc);
+
+    pdc->init = macio_oldworld_initfn;
+    pdc->device_id = PCI_DEVICE_ID_APPLE_343S1201;
+}
+
+static void macio_newworld_class_init(ObjectClass *oc, void *data)
+{
+    PCIDeviceClass *pdc = PCI_DEVICE_CLASS(oc);
+
+    pdc->init = macio_newworld_initfn;
+    pdc->device_id = PCI_DEVICE_ID_APPLE_UNI_N_KEYL;
+}
+
 static void macio_class_init(ObjectClass *klass, void *data)
 {
     PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
 
-    k->init = macio_initfn;
     k->vendor_id = PCI_VENDOR_ID_APPLE;
     k->class_id = PCI_CLASS_OTHERS << 8;
 }
 
+static const TypeInfo macio_oldworld_type_info = {
+    .name          = TYPE_OLDWORLD_MACIO,
+    .parent        = TYPE_MACIO,
+    .class_init    = macio_oldworld_class_init,
+};
+
+static const TypeInfo macio_newworld_type_info = {
+    .name          = TYPE_NEWWORLD_MACIO,
+    .parent        = TYPE_MACIO,
+    .class_init    = macio_newworld_class_init,
+};
+
 static const TypeInfo macio_type_info = {
     .name          = TYPE_MACIO,
     .parent        = TYPE_PCI_DEVICE,
     .instance_size = sizeof(MacIOState),
     .instance_init = macio_instance_init,
+    .abstract      = true,
     .class_init    = macio_class_init,
 };
 
 static void macio_register_types(void)
 {
     type_register_static(&macio_type_info);
+    type_register_static(&macio_oldworld_type_info);
+    type_register_static(&macio_newworld_type_info);
 }
 
 type_init(macio_register_types)
 
-void macio_init (PCIBus *bus, int device_id, int is_oldworld,
-                 MemoryRegion *pic_mem, MemoryRegion *dbdma_mem,
-                 MemoryRegion *cuda_mem, void *nvram,
-                 int nb_ide, MemoryRegion **ide_mem,
-                 MemoryRegion *escc_mem)
+void macio_init(PCIDevice *d,
+                MemoryRegion *pic_mem, MemoryRegion *dbdma_mem,
+                MemoryRegion *cuda_mem, void *nvram,
+                int nb_ide, MemoryRegion **ide_mem,
+                MemoryRegion *escc_mem)
 {
-    PCIDevice *d;
-    MacIOState *macio_state;
+    MacIOState *macio_state = MACIO(d);
     int i;
 
-    d = pci_create(bus, -1, TYPE_MACIO);
-
-    macio_state = MACIO(d);
-    macio_state->is_oldworld = is_oldworld;
     macio_state->pic_mem = pic_mem;
     macio_state->dbdma_mem = dbdma_mem;
     macio_state->cuda_mem = cuda_mem;
@@ -147,12 +194,8 @@ void macio_init (PCIBus *bus, int device_id, int is_oldworld,
     macio_state->nb_ide = nb_ide;
     for (i = 0; i < nb_ide; i++)
         macio_state->ide_mem[i] = ide_mem[i];
-    for (; i < 4; i++)
-        macio_state->ide_mem[i] = NULL;
     /* Note: this code is strongly inspirated from the corresponding code
        in PearPC */
 
-    pci_config_set_device_id(d->config, device_id);
-
     qdev_init_nofail(DEVICE(d));
 }
hw/ppc/mac.h +6 -4
index 89c7d66..864a610 100644
@@ -45,10 +45,12 @@
 void cuda_init (MemoryRegion **cuda_mem, qemu_irq irq);
 
 /* MacIO */
-void macio_init (PCIBus *bus, int device_id, int is_oldworld,
-                 MemoryRegion *pic_mem, MemoryRegion *dbdma_mem,
-                 MemoryRegion *cuda_mem, void *nvram,
-                 int nb_ide, MemoryRegion **ide_mem, MemoryRegion *escc_mem);
+#define TYPE_OLDWORLD_MACIO "macio-oldworld"
+#define TYPE_NEWWORLD_MACIO "macio-newworld"
+void macio_init(PCIDevice *dev,
+                MemoryRegion *pic_mem, MemoryRegion *dbdma_mem,
+                MemoryRegion *cuda_mem, void *nvram,
+                int nb_ide, MemoryRegion **ide_mem, MemoryRegion *escc_mem);
 
 /* Heathrow PIC */
 qemu_irq *heathrow_pic_init(MemoryRegion **pmem,
hw/ppc/mac_newworld.c +3 -1
index adf111c..d1329dc 100644
@@ -147,6 +147,7 @@ static void ppc_core99_init(QEMUMachineInitArgs *args)
     hwaddr kernel_base, initrd_base, cmdline_base = 0;
     long kernel_size, initrd_size;
     PCIBus *pci_bus;
+    PCIDevice *macio;
     MacIONVRAMState *nvr;
     int bios_size;
     MemoryRegion *pic_mem, *dbdma_mem, *cuda_mem, *escc_mem;
@@ -374,7 +375,8 @@ static void ppc_core99_init(QEMUMachineInitArgs *args)
     adb_kbd_init(&adb_bus);
     adb_mouse_init(&adb_bus);
 
-    macio_init(pci_bus, PCI_DEVICE_ID_APPLE_UNI_N_KEYL, 0, pic_mem,
+    macio = pci_create(pci_bus, -1, TYPE_NEWWORLD_MACIO);
+    macio_init(macio, pic_mem,
                dbdma_mem, cuda_mem, NULL, 3, ide_mem, escc_bar);
 
     if (usb_enabled(machine_arch == ARCH_MAC99_U3)) {
hw/ppc/mac_oldworld.c +3 -1
index 0d9f65b..74b3878 100644
@@ -90,6 +90,7 @@ static void ppc_heathrow_init(QEMUMachineInitArgs *args)
     uint32_t kernel_base, initrd_base, cmdline_base = 0;
     int32_t kernel_size, initrd_size;
     PCIBus *pci_bus;
+    PCIDevice *macio;
     MacIONVRAMState *nvr;
     int bios_size;
     MemoryRegion *pic_mem, *dbdma_mem, *cuda_mem;
@@ -283,7 +284,8 @@ static void ppc_heathrow_init(QEMUMachineInitArgs *args)
     nvr = macio_nvram_init(0x2000, 4);
     pmac_format_nvram_partition(nvr, 0x2000);
 
-    macio_init(pci_bus, PCI_DEVICE_ID_APPLE_343S1201, 1, pic_mem,
+    macio = pci_create(pci_bus, -1, TYPE_OLDWORLD_MACIO);
+    macio_init(macio, pic_mem,
                dbdma_mem, cuda_mem, nvr, 2, ide_mem, escc_bar);
 
     if (usb_enabled(false)) {
Signature · 1 line
1.7.10.4
#13 lore raw

RFC v3 6/10 mac_nvram: Clean up public API

In reply to Andreas Färber

The state data field is accessed in uint8_t quantities, so switch from uint32_t argument and return value to uint8_t.

Fix debug format specifiers while at it.

---
 hw/mac_nvram.c |   21 ++++++++++-----------
 hw/ppc/mac.h   |    4 ++--

2 Dateien geändert, 12 Zeilen hinzugefügt(+), 13 Zeilen entfernt(-)

hw/mac_nvram.c +10 -11
index eec7ca4..bcde07d 100644
@@ -47,27 +47,26 @@ struct MacIONVRAMState {
 #define DEF_SYSTEM_SIZE 0xc10
 
 /* Direct access to NVRAM */
-uint32_t macio_nvram_read (void *opaque, uint32_t addr)
+uint8_t macio_nvram_read(MacIONVRAMState *s, uint32_t addr)
 {
-    MacIONVRAMState *s = opaque;
     uint32_t ret;
 
-    if (addr < s->size)
+    if (addr < s->size) {
         ret = s->data[addr];
-    else
+    } else {
         ret = -1;
-    NVR_DPRINTF("read addr %04x val %x\n", addr, ret);
+    }
+    NVR_DPRINTF("read addr %04" PRIx32 " val %" PRIx8 "\n", addr, ret);
 
     return ret;
 }
 
-void macio_nvram_write (void *opaque, uint32_t addr, uint32_t val)
+void macio_nvram_write(MacIONVRAMState *s, uint32_t addr, uint8_t val)
 {
-    MacIONVRAMState *s = opaque;
-
-    NVR_DPRINTF("write addr %04x val %x\n", addr, val);
-    if (addr < s->size)
+    NVR_DPRINTF("write addr %04" PRIx32 " val %" PRIx8 "\n", addr, val);
+    if (addr < s->size) {
         s->data[addr] = val;
+    }
 }
 
 /* macio style NVRAM device */
@@ -78,7 +77,7 @@ static void macio_nvram_writeb(void *opaque, hwaddr addr,
 
     addr = (addr >> s->it_shift) & (s->size - 1);
     s->data[addr] = value;
-    NVR_DPRINTF("writeb addr %04x val %x\n", (int)addr, value);
+    NVR_DPRINTF("writeb addr %04" PHYS_PRIx " val %" PRIx64 "\n", addr, value);
 }
 
 static uint64_t macio_nvram_readb(void *opaque, hwaddr addr,
hw/ppc/mac.h +2 -2
index 864a610..6441794 100644
@@ -78,6 +78,6 @@ MacIONVRAMState *macio_nvram_init (hwaddr size,
 void macio_nvram_setup_bar(MacIONVRAMState *s, MemoryRegion *bar,
                            hwaddr mem_base);
 void pmac_format_nvram_partition (MacIONVRAMState *nvr, int len);
-uint32_t macio_nvram_read (void *opaque, uint32_t addr);
-void macio_nvram_write (void *opaque, uint32_t addr, uint32_t val);
+uint8_t macio_nvram_read(MacIONVRAMState *s, uint32_t addr);
+void macio_nvram_write(MacIONVRAMState *s, uint32_t addr, uint8_t val);
 #endif /* !defined(__PPC_MAC_H__) */
Signature · 1 line
1.7.10.4
#14 lore raw

RFC v3 7/10 mac_nvram: Mark as Big Endian

In reply to Andreas Färber
---
 hw/mac_nvram.c |    2 +-

1 Datei geändert, 1 Zeile hinzugefügt(+), 1 Zeile entfernt(-)

hw/mac_nvram.c +1 -1
index bcde07d..0a22e66 100644
@@ -96,7 +96,7 @@ static uint64_t macio_nvram_readb(void *opaque, hwaddr addr,
 static const MemoryRegionOps macio_nvram_ops = {
     .read = macio_nvram_readb,
     .write = macio_nvram_writeb,
-    .endianness = DEVICE_NATIVE_ENDIAN,
+    .endianness = DEVICE_BIG_ENDIAN,
 };
 
 static const VMStateDescription vmstate_macio_nvram = {
Signature · 1 line
1.7.10.4
#15 lore raw

RFC v3 8/10 mac_nvram: QOM'ify MacIO NVRAM

In reply to Andreas Färber

It was not qdev'ified before, turn it into a SysBusDevice and initialize it via static properties.

Prepare Old World specific MacIO state and embed the NVRAM state there.

Drop macio_nvram_setup_bar() in favor of sysbus_mmio_map() or direct use of Memory API.

---
 hw/mac_nvram.c        |   57 ++++++++++++++++++++++++++++++-------------------
 hw/macio.c            |   41 ++++++++++++++++++++++++++++++-----
 hw/ppc/mac.h          |   23 ++++++++++++++------
 hw/ppc/mac_newworld.c |   10 ++++++---
 hw/ppc/mac_oldworld.c |    6 +-----

5 Dateien geändert, 96 Zeilen hinzugefügt(+), 41 Zeilen entfernt(-)

hw/mac_nvram.c +35 -22
index 0a22e66..a832dda 100644
@@ -37,13 +37,6 @@
 #define NVR_DPRINTF(fmt, ...)
 #endif
 
-struct MacIONVRAMState {
-    uint32_t size;
-    MemoryRegion mem;
-    unsigned int it_shift;
-    uint8_t *data;
-};
-
 #define DEF_SYSTEM_SIZE 0xc10
 
 /* Direct access to NVRAM */
@@ -111,32 +104,50 @@ static const VMStateDescription vmstate_macio_nvram = {
 };
 
 
-static void macio_nvram_reset(void *opaque)
+static void macio_nvram_reset(DeviceState *dev)
 {
 }
 
-MacIONVRAMState *macio_nvram_init (hwaddr size,
-                                   unsigned int it_shift)
+static int macio_nvram_initfn(SysBusDevice *d)
 {
-    MacIONVRAMState *s;
+    MacIONVRAMState *s = MACIO_NVRAM(d);
 
-    s = g_malloc0(sizeof(MacIONVRAMState));
-    s->data = g_malloc0(size);
-    s->size = size;
-    s->it_shift = it_shift;
+    s->data = g_malloc0(s->size);
 
     memory_region_init_io(&s->mem, &macio_nvram_ops, s, "macio-nvram",
-                          size << it_shift);
-    vmstate_register(NULL, -1, &vmstate_macio_nvram, s);
-    qemu_register_reset(macio_nvram_reset, s);
+                          s->size << s->it_shift);
+    sysbus_init_mmio(d, &s->mem);
 
-    return s;
+    return 0;
 }
 
-void macio_nvram_setup_bar(MacIONVRAMState *s, MemoryRegion *bar,
-                           hwaddr mem_base)
+static Property macio_nvram_properties[] = {
+    DEFINE_PROP_UINT32("size", MacIONVRAMState, size, 0),
+    DEFINE_PROP_UINT32("it_shift", MacIONVRAMState, it_shift, 0),
+    DEFINE_PROP_END_OF_LIST()
+};
+
+static void macio_nvram_class_init(ObjectClass *oc, void *data)
 {
-    memory_region_add_subregion(bar, mem_base, &s->mem);
+    DeviceClass *dc = DEVICE_CLASS(oc);
+    SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(oc);
+
+    sdc->init = macio_nvram_initfn;
+    dc->reset = macio_nvram_reset;
+    dc->vmsd = &vmstate_macio_nvram;
+    dc->props = macio_nvram_properties;
+}
+
+static const TypeInfo macio_nvram_type_info = {
+    .name = TYPE_MACIO_NVRAM,
+    .parent = TYPE_SYS_BUS_DEVICE,
+    .instance_size = sizeof(MacIONVRAMState),
+    .class_init = macio_nvram_class_init,
+};
+
+static void macio_nvram_register_types(void)
+{
+    type_register_static(&macio_nvram_type_info);
 }
 
 /* Set up a system OpenBIOS NVRAM partition */
@@ -175,3 +186,5 @@ void pmac_format_nvram_partition (MacIONVRAMState *nvr, int len)
     end = len;
     OpenBIOS_finish_partition(part_header, end - start);
 }
+
+type_init(macio_nvram_register_types)
hw/macio.c +36 -5

92 lines not on this page · raw message

hw/ppc/mac.h +17 -6
index 6441794..581e95c 100644
@@ -26,6 +26,7 @@
 #define __PPC_MAC_H__
 
 #include "exec/memory.h"
+#include "hw/sysbus.h"
 
 /* SMP is not enabled, for now */
 #define MAX_CPUS 1
@@ -49,7 +50,7 @@ void cuda_init (MemoryRegion **cuda_mem, qemu_irq irq);
 #define TYPE_NEWWORLD_MACIO "macio-newworld"
 void macio_init(PCIDevice *dev,
                 MemoryRegion *pic_mem, MemoryRegion *dbdma_mem,
-                MemoryRegion *cuda_mem, void *nvram,
+                MemoryRegion *cuda_mem,
                 int nb_ide, MemoryRegion **ide_mem, MemoryRegion *escc_mem);
 
 /* Heathrow PIC */
@@ -71,12 +72,22 @@ PCIBus *pci_pmac_u3_init(qemu_irq *pic,
                          MemoryRegion *address_space_io);
 
 /* Mac NVRAM */
-typedef struct MacIONVRAMState MacIONVRAMState;
+#define TYPE_MACIO_NVRAM "macio-nvram"
+#define MACIO_NVRAM(obj) \
+    OBJECT_CHECK(MacIONVRAMState, (obj), TYPE_MACIO_NVRAM)
+
+typedef struct MacIONVRAMState {
+    /*< private >*/
+    SysBusDevice parent_obj;
+    /*< public >*/
+
+    uint32_t size;
+    uint32_t it_shift;
+
+    MemoryRegion mem;
+    uint8_t *data;
+} MacIONVRAMState;
 
-MacIONVRAMState *macio_nvram_init (hwaddr size,
-                                   unsigned int it_shift);
-void macio_nvram_setup_bar(MacIONVRAMState *s, MemoryRegion *bar,
-                           hwaddr mem_base);
 void pmac_format_nvram_partition (MacIONVRAMState *nvr, int len);
 uint8_t macio_nvram_read(MacIONVRAMState *s, uint32_t addr);
 void macio_nvram_write(MacIONVRAMState *s, uint32_t addr, uint8_t val);
hw/ppc/mac_newworld.c +7 -3
index d1329dc..4aef010 100644
@@ -377,7 +377,7 @@ static void ppc_core99_init(QEMUMachineInitArgs *args)
 
     macio = pci_create(pci_bus, -1, TYPE_NEWWORLD_MACIO);
     macio_init(macio, pic_mem,
-               dbdma_mem, cuda_mem, NULL, 3, ide_mem, escc_bar);
+               dbdma_mem, cuda_mem, 3, ide_mem, escc_bar);
 
     if (usb_enabled(machine_arch == ARCH_MAC99_U3)) {
         pci_create_simple(pci_bus, -1, "pci-ohci");
@@ -393,9 +393,13 @@ static void ppc_core99_init(QEMUMachineInitArgs *args)
         graphic_depth = 15;
 
     /* The NewWorld NVRAM is not located in the MacIO device */
-    nvr = macio_nvram_init(0x2000, 1);
+    dev = qdev_create(NULL, TYPE_MACIO_NVRAM);
+    qdev_prop_set_uint32(dev, "size", 0x2000);
+    qdev_prop_set_uint32(dev, "it_shift", 1);
+    qdev_init_nofail(dev);
+    sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, 0xFFF04000);
+    nvr = MACIO_NVRAM(dev);
     pmac_format_nvram_partition(nvr, 0x2000);
-    macio_nvram_setup_bar(nvr, get_system_memory(), 0xFFF04000);
     /* No PCI init: the BIOS will do it */
 
     fw_cfg = fw_cfg_init(0, 0, CFG_ADDR, CFG_ADDR + 2);
hw/ppc/mac_oldworld.c +1 -5
index 74b3878..d1bfbff 100644
@@ -91,7 +91,6 @@ static void ppc_heathrow_init(QEMUMachineInitArgs *args)
     int32_t kernel_size, initrd_size;
     PCIBus *pci_bus;
     PCIDevice *macio;
-    MacIONVRAMState *nvr;
     int bios_size;
     MemoryRegion *pic_mem, *dbdma_mem, *cuda_mem;
     MemoryRegion *escc_mem, *escc_bar = g_new(MemoryRegion, 1), *ide_mem[2];
@@ -281,12 +280,9 @@ static void ppc_heathrow_init(QEMUMachineInitArgs *args)
     adb_kbd_init(&adb_bus);
     adb_mouse_init(&adb_bus);
 
-    nvr = macio_nvram_init(0x2000, 4);
-    pmac_format_nvram_partition(nvr, 0x2000);
-
     macio = pci_create(pci_bus, -1, TYPE_OLDWORLD_MACIO);
     macio_init(macio, pic_mem,
-               dbdma_mem, cuda_mem, nvr, 2, ide_mem, escc_bar);
+               dbdma_mem, cuda_mem, 2, ide_mem, escc_bar);
 
     if (usb_enabled(false)) {
         pci_create_simple(pci_bus, -1, "pci-ohci");
Signature · 1 line
1.7.10.4
#16 lore raw

Re: [Qemu-devel] [RFC ppc-next v3 08/10] mac_nvram: QOM'ify MacIO NVRAM

Quoted 7 lines · Andreas Färber

It was not qdev'ified before, turn it into a SysBusDevice and initialize it via static properties.

Prepare Old World specific MacIO state and embed the NVRAM state there.

Drop macio_nvram_setup_bar() in favor of sysbus_mmio_map() or direct use of Memory API.

[...]

Quoted 4 lines
hw/macio.c +0 -0
index 0e6fc8d..32f359c 100644

[...]

hw/macio.c static int macio_common_initfn(PCIDevice *d) · line 96

Quoted 5 lines
hw/macio.c +1 -0
@@ -85,11 +93,22 @@ static int macio_common_initfn(PCIDevice *d)
 static int macio_oldworld_initfn(PCIDevice *d)
 {
     MacIOState *s = MACIO(d);
+    OldWorldMacIOState *os = OLDWORLD_MACIO(d);

I find aliasing pointers like these mildly confusing, and prefer to avoid aliases. Matter of taste, I guess.

Quoted 4 lines
hw/macio.c +1 -0
+    SysBusDevice *sysbus_dev;
     int ret = macio_common_initfn(d);
     if (ret < 0) {
         return ret;

[...]

#17 lore raw

Re: [Qemu-devel] [RFC ppc-next v3 08/10] mac_nvram: QOM'ify MacIO NVRAM

Am 14.01.2013 13:34, schrieb Markus Armbruster:

Quoted 15 lines
Quoted 7 lines · Andreas Färber

It was not qdev'ified before, turn it into a SysBusDevice and initialize it via static properties.

Prepare Old World specific MacIO state and embed the NVRAM state there.

Drop macio_nvram_setup_bar() in favor of sysbus_mmio_map() or direct use of Memory API.

[...]

Quoted 4 lines
hw/macio.c +0 -0
index 0e6fc8d..32f359c 100644

[...]

Quoted 8 lines

hw/macio.c static int macio_common_initfn(PCIDevice *d) · line 96

Quoted 5 lines
hw/macio.c +1 -0
@@ -85,11 +93,22 @@ static int macio_common_initfn(PCIDevice *d)
 static int macio_oldworld_initfn(PCIDevice *d)
 {
     MacIOState *s = MACIO(d);
+    OldWorldMacIOState *os = OLDWORLD_MACIO(d);

I find aliasing pointers like these mildly confusing, and prefer to avoid aliases. Matter of taste, I guess.

What would you propose instead? When accessing fields we are not supposed to use FOO(x)->bar so I don't see any alternative. (This notation was chosen I think because it is compatible with C++/ObjC/... when exchanging the cast macro.)

Andreas

Quoted 6 lines
Quoted 5 lines
hw/macio.c +1 -0
+    SysBusDevice *sysbus_dev;
     int ret = macio_common_initfn(d);
     if (ret < 0) {
         return ret;

[...]

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#18 lore raw

Re: [Qemu-devel] [RFC ppc-next v3 08/10] mac_nvram: QOM'ify MacIO NVRAM

Quoted 25 lines · Andreas Färber

Am 14.01.2013 13:34, schrieb Markus Armbruster:

Quoted 15 lines
Quoted 7 lines · Andreas Färber

It was not qdev'ified before, turn it into a SysBusDevice and initialize it via static properties.

Prepare Old World specific MacIO state and embed the NVRAM state there.

Drop macio_nvram_setup_bar() in favor of sysbus_mmio_map() or direct use of Memory API.

[...]

Quoted 4 lines
hw/macio.c +0 -0
index 0e6fc8d..32f359c 100644

[...]

Quoted 8 lines

hw/macio.c static int macio_common_initfn(PCIDevice *d) · line 96

Quoted 5 lines
hw/macio.c +1 -0
@@ -85,11 +93,22 @@ static int macio_common_initfn(PCIDevice *d)
 static int macio_oldworld_initfn(PCIDevice *d)
 {
     MacIOState *s = MACIO(d);
+    OldWorldMacIOState *os = OLDWORLD_MACIO(d);

I find aliasing pointers like these mildly confusing, and prefer to avoid aliases. Matter of taste, I guess.

Quoted 4 lines

What would you propose instead? When accessing fields we are not supposed to use FOO(x)->bar so I don't see any alternative. (This notation was chosen I think because it is compatible with C++/ObjC/... when exchanging the cast macro.)

Isn't &os->parent_obj == s ? s-> then becomes os->parent_obj.

Repeat: matter of taste, use your judgement.

#19 lore raw

RFC v3 9/10 ide/macio: QOM'ify MacIO IDE

In reply to Andreas Färber

It was not qdev'ified before, turn it into a SysBusDevice. Embed them into the MacIO devices.

Cc Markus Armbruster <[email protected]>
---
 hw/ide.h              |    4 --
 hw/ide/macio.c        |   81 ++++++++++++++++++++++++++++-----------
 hw/macio.c            |  102 ++++++++++++++++++++++++++++++++++++++-----------
 hw/ppc/mac.h          |   25 +++++++++++-
 hw/ppc/mac_newworld.c |   28 ++++++++------
 hw/ppc/mac_oldworld.c |   36 ++++++++---------

6 Dateien geändert, 198 Zeilen hinzugefügt(+), 78 Zeilen entfernt(-)

hw/ide.h +0 -4
index 7e23cda..9b357c0 100644
@@ -19,10 +19,6 @@ PCIDevice *pci_piix3_ide_init(PCIBus *bus, DriveInfo **hd_table, int devfn);
 PCIDevice *pci_piix4_ide_init(PCIBus *bus, DriveInfo **hd_table, int devfn);
 void vt82c686b_ide_init(PCIBus *bus, DriveInfo **hd_table, int devfn);
 
-/* ide-macio.c */
-MemoryRegion *pmac_ide_init (DriveInfo **hd_table, qemu_irq irq,
-		   void *dbdma, int channel, qemu_irq dma_irq);
-
 /* ide-mmio.c */
 void mmio_ide_init (hwaddr membase, hwaddr membase2,
                     MemoryRegion *address_space,
hw/ide/macio.c +59 -22

101 lines not on this page · raw message

hw/macio.c +80 -22

193 lines not on this page · raw message

hw/ppc/mac.h +23 -2
index 581e95c..3e390d3 100644
@@ -27,6 +27,7 @@
 
 #include "exec/memory.h"
 #include "hw/sysbus.h"
+#include "hw/ide/internal.h"
 
 /* SMP is not enabled, for now */
 #define MAX_CPUS 1
@@ -48,10 +49,30 @@ void cuda_init (MemoryRegion **cuda_mem, qemu_irq irq);
 /* MacIO */
 #define TYPE_OLDWORLD_MACIO "macio-oldworld"
 #define TYPE_NEWWORLD_MACIO "macio-newworld"
+
+#define TYPE_MACIO_IDE "macio-ide"
+#define MACIO_IDE(obj) OBJECT_CHECK(MACIOIDEState, (obj), TYPE_MACIO_IDE)
+
+typedef struct MACIOIDEState {
+    /*< private >*/
+    SysBusDevice parent_obj;
+    /*< public >*/
+
+    qemu_irq irq;
+    qemu_irq dma_irq;
+
+    MemoryRegion mem;
+    IDEBus bus;
+    BlockDriverAIOCB *aiocb;
+} MACIOIDEState;
+
+void macio_ide_init_drives(MACIOIDEState *ide, DriveInfo **hd_table);
+void macio_ide_register_dma(MACIOIDEState *ide, void *dbdma, int channel);
+
 void macio_init(PCIDevice *dev,
-                MemoryRegion *pic_mem, MemoryRegion *dbdma_mem,
+                MemoryRegion *pic_mem,
                 MemoryRegion *cuda_mem,
-                int nb_ide, MemoryRegion **ide_mem, MemoryRegion *escc_mem);
+                MemoryRegion *escc_mem);
 
 /* Heathrow PIC */
 qemu_irq *heathrow_pic_init(MemoryRegion **pmem,
hw/ppc/mac_newworld.c +17 -11
index 4aef010..9a91c91 100644
@@ -148,15 +148,14 @@ static void ppc_core99_init(QEMUMachineInitArgs *args)
     long kernel_size, initrd_size;
     PCIBus *pci_bus;
     PCIDevice *macio;
+    MACIOIDEState *macio_ide;
     MacIONVRAMState *nvr;
     int bios_size;
-    MemoryRegion *pic_mem, *dbdma_mem, *cuda_mem, *escc_mem;
+    MemoryRegion *pic_mem, *cuda_mem, *escc_mem;
     MemoryRegion *escc_bar = g_new(MemoryRegion, 1);
-    MemoryRegion *ide_mem[3];
     int ppc_boot_device;
     DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
     void *fw_cfg;
-    void *dbdma;
     int machine_arch;
     SysBusDevice *s;
     DeviceState *dev;
@@ -363,12 +362,6 @@ static void ppc_core99_init(QEMUMachineInitArgs *args)
         pci_nic_init_nofail(&nd_table[i], "ne2k_pci", NULL);
 
     ide_drive_get(hd, MAX_IDE_BUS);
-    dbdma = DBDMA_init(&dbdma_mem);
-
-    /* We only emulate 2 out of 3 IDE controllers for now */
-    ide_mem[0] = NULL;
-    ide_mem[1] = pmac_ide_init(hd, pic[0x0d], dbdma, 0x16, pic[0x02]);
-    ide_mem[2] = pmac_ide_init(&hd[MAX_IDE_DEVS], pic[0x0e], dbdma, 0x1a, pic[0x02]);
 
     cuda_init(&cuda_mem, pic[0x19]);
 
@@ -376,8 +369,21 @@ static void ppc_core99_init(QEMUMachineInitArgs *args)
     adb_mouse_init(&adb_bus);
 
     macio = pci_create(pci_bus, -1, TYPE_NEWWORLD_MACIO);
-    macio_init(macio, pic_mem,
-               dbdma_mem, cuda_mem, 3, ide_mem, escc_bar);
+    dev = DEVICE(macio);
+    qdev_connect_gpio_out(dev, 0, pic[0x0d]); /* IDE */
+    qdev_connect_gpio_out(dev, 1, pic[0x02]); /* IDE DMA */
+    qdev_connect_gpio_out(dev, 2, pic[0x0e]); /* IDE */
+    qdev_connect_gpio_out(dev, 3, pic[0x02]); /* IDE DMA */
+    macio_init(macio, pic_mem, cuda_mem, escc_bar);
+
+    /* We only emulate 2 out of 3 IDE controllers for now */
+    macio_ide = MACIO_IDE(object_resolve_path_component(OBJECT(macio),
+                                                        "ide[0]"));
+    macio_ide_init_drives(macio_ide, hd);
+
+    macio_ide = MACIO_IDE(object_resolve_path_component(OBJECT(macio),
+                                                        "ide[1]"));
+    macio_ide_init_drives(macio_ide, &hd[MAX_IDE_DEVS]);
 
     if (usb_enabled(machine_arch == ARCH_MAC99_U3)) {
         pci_create_simple(pci_bus, -1, "pci-ohci");
hw/ppc/mac_oldworld.c +19 -17
index d1bfbff..7014b4c 100644
@@ -27,7 +27,6 @@
 #include "hw/ppc.h"
 #include "mac.h"
 #include "hw/adb.h"
-#include "hw/mac_dbdma.h"
 #include "hw/nvram.h"
 #include "sysemu/sysemu.h"
 #include "net/net.h"
@@ -91,13 +90,14 @@ static void ppc_heathrow_init(QEMUMachineInitArgs *args)
     int32_t kernel_size, initrd_size;
     PCIBus *pci_bus;
     PCIDevice *macio;
+    MACIOIDEState *macio_ide;
+    DeviceState *dev;
     int bios_size;
-    MemoryRegion *pic_mem, *dbdma_mem, *cuda_mem;
-    MemoryRegion *escc_mem, *escc_bar = g_new(MemoryRegion, 1), *ide_mem[2];
+    MemoryRegion *pic_mem, *cuda_mem;
+    MemoryRegion *escc_mem, *escc_bar = g_new(MemoryRegion, 1);
     uint16_t ppc_boot_device;
     DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
     void *fw_cfg;
-    void *dbdma;
 
     linux_boot = (kernel_filename != NULL);
 
@@ -263,17 +263,6 @@ static void ppc_heathrow_init(QEMUMachineInitArgs *args)
 
     ide_drive_get(hd, MAX_IDE_BUS);
 
-    /* First IDE channel is a MAC IDE on the MacIO bus */
-    dbdma = DBDMA_init(&dbdma_mem);
-    ide_mem[0] = NULL;
-    ide_mem[1] = pmac_ide_init(hd, pic[0x0D], dbdma, 0x16, pic[0x02]);
-
-    /* Second IDE channel is a CMD646 on the PCI bus */
-    hd[0] = hd[MAX_IDE_DEVS];
-    hd[1] = hd[MAX_IDE_DEVS + 1];
-    hd[3] = hd[2] = NULL;
-    pci_cmd646_ide_init(pci_bus, hd, 0);
-
     /* cuda also initialize ADB */
     cuda_init(&cuda_mem, pic[0x12]);
 
@@ -281,8 +270,21 @@ static void ppc_heathrow_init(QEMUMachineInitArgs *args)
     adb_mouse_init(&adb_bus);
 
     macio = pci_create(pci_bus, -1, TYPE_OLDWORLD_MACIO);
-    macio_init(macio, pic_mem,
-               dbdma_mem, cuda_mem, 2, ide_mem, escc_bar);
+    dev = DEVICE(macio);
+    qdev_connect_gpio_out(dev, 0, pic[0x0D]); /* IDE */
+    qdev_connect_gpio_out(dev, 1, pic[0x02]); /* IDE DMA */
+    macio_init(macio, pic_mem, cuda_mem, escc_bar);
+
+    /* First IDE channel is a MAC IDE on the MacIO bus */
+    macio_ide = MACIO_IDE(object_resolve_path_component(OBJECT(macio),
+                                                        "ide"));
+    macio_ide_init_drives(macio_ide, hd);
+
+    /* Second IDE channel is a CMD646 on the PCI bus */
+    hd[0] = hd[MAX_IDE_DEVS];
+    hd[1] = hd[MAX_IDE_DEVS + 1];
+    hd[3] = hd[2] = NULL;
+    pci_cmd646_ide_init(pci_bus, hd, 0);
 
     if (usb_enabled(false)) {
         pci_create_simple(pci_bus, -1, "pci-ohci");
Signature · 1 line
1.7.10.4
#20 lore raw

RFC v3 10/10 cuda: QOM'ify CUDA

In reply to Andreas Färber

It was not qdev'ified before, turn it into a SysBusDevice and embed it in MacIO.

---
 hw/cuda.c             |   98 ++++++++++++++++++++++---------------------------
 hw/macio.c            |   43 +++++++++++++++-------
 hw/ppc/mac.h          |   68 +++++++++++++++++++++++++++++++++-
 hw/ppc/mac_newworld.c |   21 +++++------
 hw/ppc/mac_oldworld.c |   18 ++++-----

5 Dateien geändert, 157 Zeilen hinzugefügt(+), 91 Zeilen entfernt(-)

hw/cuda.c +44 -54
index bbd1fda..26c96cc 100644
@@ -108,48 +108,6 @@
 /* CUDA returns time_t's offset from Jan 1, 1904, not 1970 */
 #define RTC_OFFSET                      2082844800
 
-typedef struct CUDATimer {
-    int index;
-    uint16_t latch;
-    uint16_t counter_value; /* counter value at load time */
-    int64_t load_time;
-    int64_t next_irq_time;
-    QEMUTimer *timer;
-} CUDATimer;
-
-typedef struct CUDAState {
-    MemoryRegion mem;
-    /* cuda registers */
-    uint8_t b;      /* B-side data */
-    uint8_t a;      /* A-side data */
-    uint8_t dirb;   /* B-side direction (1=output) */
-    uint8_t dira;   /* A-side direction (1=output) */
-    uint8_t sr;     /* Shift register */
-    uint8_t acr;    /* Auxiliary control register */
-    uint8_t pcr;    /* Peripheral control register */
-    uint8_t ifr;    /* Interrupt flag register */
-    uint8_t ier;    /* Interrupt enable register */
-    uint8_t anh;    /* A-side data, no handshake */
-
-    CUDATimer timers[2];
-
-    uint32_t tick_offset;
-
-    uint8_t last_b; /* last value of B register */
-    uint8_t last_acr; /* last value of B register */
-
-    int data_in_size;
-    int data_in_index;
-    int data_out_index;
-
-    qemu_irq irq;
-    uint8_t autopoll;
-    uint8_t data_in[128];
-    uint8_t data_out[16];
-    QEMUTimer *adb_poll_timer;
-} CUDAState;
-
-static CUDAState cuda_state;
 ADBBusState adb_bus;
 
 static void cuda_update(CUDAState *s);
@@ -701,9 +659,9 @@ static const VMStateDescription vmstate_cuda = {
     }
 };
 
-static void cuda_reset(void *opaque)
+static void cuda_reset(DeviceState *dev)
 {
-    CUDAState *s = opaque;
+    CUDAState *s = CUDA(dev);
 
     s->b = 0;
     s->a = 0;
@@ -728,25 +686,57 @@ static void cuda_reset(void *opaque)
     set_counter(s, &s->timers[1], 0xffff);
 }
 
-void cuda_init (MemoryRegion **cuda_mem, qemu_irq irq)
+static int cuda_initfn(SysBusDevice *d)
 {
+    CUDAState *s = CUDA(d);
     struct tm tm;
-    CUDAState *s = &cuda_state;
-
-    s->irq = irq;
 
-    s->timers[0].index = 0;
     s->timers[0].timer = qemu_new_timer_ns(vm_clock, cuda_timer1, s);
 
-    s->timers[1].index = 1;
-
     qemu_get_timedate(&tm, 0);
     s->tick_offset = (uint32_t)mktimegm(&tm) + RTC_OFFSET;
 
     s->adb_poll_timer = qemu_new_timer_ns(vm_clock, cuda_adb_poll, s);
+
+    return 0;
+}
+
+static void cuda_init(Object *obj)
+{
+    SysBusDevice *d = SYS_BUS_DEVICE(obj);
+    CUDAState *s = CUDA(obj);
+    int i;
+
     memory_region_init_io(&s->mem, &cuda_ops, s, "cuda", 0x2000);
+    sysbus_init_mmio(d, &s->mem);
+    sysbus_init_irq(d, &s->irq);
+
+    for (i = 0; i < 2; i++) {
+        s->timers[i].index = i;
+    }
+}
+
+static void cuda_class_init(ObjectClass *oc, void *data)
+{
+    DeviceClass *dc = DEVICE_CLASS(oc);
+    SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(oc);
+
+    sdc->init = cuda_initfn;
+    dc->reset = cuda_reset;
+    dc->vmsd = &vmstate_cuda;
+}
+
+static const TypeInfo cuda_type_info = {
+    .name = TYPE_CUDA,
+    .parent = TYPE_SYS_BUS_DEVICE,
+    .instance_size = sizeof(CUDAState),
+    .instance_init = cuda_init,
+    .class_init = cuda_class_init,
+};
 
-    *cuda_mem = &s->mem;
-    vmstate_register(NULL, -1, &vmstate_cuda, s);
-    qemu_register_reset(cuda_reset, s);
+static void cuda_register_types(void)
+{
+    type_register_static(&cuda_type_info);
 }
+
+type_init(cuda_register_types)
hw/macio.c +29 -14

124 lines not on this page · raw message

hw/ppc/mac.h +66 -2

80 lines not on this page · raw message

hw/ppc/mac_newworld.c +10 -11
index 9a91c91..1ba1c0b 100644
@@ -151,7 +151,7 @@ static void ppc_core99_init(QEMUMachineInitArgs *args)
     MACIOIDEState *macio_ide;
     MacIONVRAMState *nvr;
     int bios_size;
-    MemoryRegion *pic_mem, *cuda_mem, *escc_mem;
+    MemoryRegion *pic_mem, *escc_mem;
     MemoryRegion *escc_bar = g_new(MemoryRegion, 1);
     int ppc_boot_device;
     DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
@@ -363,18 +363,14 @@ static void ppc_core99_init(QEMUMachineInitArgs *args)
 
     ide_drive_get(hd, MAX_IDE_BUS);
 
-    cuda_init(&cuda_mem, pic[0x19]);
-
-    adb_kbd_init(&adb_bus);
-    adb_mouse_init(&adb_bus);
-
     macio = pci_create(pci_bus, -1, TYPE_NEWWORLD_MACIO);
     dev = DEVICE(macio);
-    qdev_connect_gpio_out(dev, 0, pic[0x0d]); /* IDE */
-    qdev_connect_gpio_out(dev, 1, pic[0x02]); /* IDE DMA */
-    qdev_connect_gpio_out(dev, 2, pic[0x0e]); /* IDE */
-    qdev_connect_gpio_out(dev, 3, pic[0x02]); /* IDE DMA */
-    macio_init(macio, pic_mem, cuda_mem, escc_bar);
+    qdev_connect_gpio_out(dev, 0, pic[0x19]); /* CUDA */
+    qdev_connect_gpio_out(dev, 1, pic[0x0d]); /* IDE */
+    qdev_connect_gpio_out(dev, 2, pic[0x02]); /* IDE DMA */
+    qdev_connect_gpio_out(dev, 3, pic[0x0e]); /* IDE */
+    qdev_connect_gpio_out(dev, 4, pic[0x02]); /* IDE DMA */
+    macio_init(macio, pic_mem, escc_bar);
 
     /* We only emulate 2 out of 3 IDE controllers for now */
     macio_ide = MACIO_IDE(object_resolve_path_component(OBJECT(macio),
@@ -385,6 +381,9 @@ static void ppc_core99_init(QEMUMachineInitArgs *args)
                                                         "ide[1]"));
     macio_ide_init_drives(macio_ide, &hd[MAX_IDE_DEVS]);
 
+    adb_kbd_init(&adb_bus);
+    adb_mouse_init(&adb_bus);
+
     if (usb_enabled(machine_arch == ARCH_MAC99_U3)) {
         pci_create_simple(pci_bus, -1, "pci-ohci");
         /* U3 needs to use USB for input because Linux doesn't support via-cuda
hw/ppc/mac_oldworld.c +8 -10
index 7014b4c..4ffdd01 100644
@@ -93,7 +93,7 @@ static void ppc_heathrow_init(QEMUMachineInitArgs *args)
     MACIOIDEState *macio_ide;
     DeviceState *dev;
     int bios_size;
-    MemoryRegion *pic_mem, *cuda_mem;
+    MemoryRegion *pic_mem;
     MemoryRegion *escc_mem, *escc_bar = g_new(MemoryRegion, 1);
     uint16_t ppc_boot_device;
     DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
@@ -263,17 +263,12 @@ static void ppc_heathrow_init(QEMUMachineInitArgs *args)
 
     ide_drive_get(hd, MAX_IDE_BUS);
 
-    /* cuda also initialize ADB */
-    cuda_init(&cuda_mem, pic[0x12]);
-
-    adb_kbd_init(&adb_bus);
-    adb_mouse_init(&adb_bus);
-
     macio = pci_create(pci_bus, -1, TYPE_OLDWORLD_MACIO);
     dev = DEVICE(macio);
-    qdev_connect_gpio_out(dev, 0, pic[0x0D]); /* IDE */
-    qdev_connect_gpio_out(dev, 1, pic[0x02]); /* IDE DMA */
-    macio_init(macio, pic_mem, cuda_mem, escc_bar);
+    qdev_connect_gpio_out(dev, 0, pic[0x12]); /* CUDA */
+    qdev_connect_gpio_out(dev, 1, pic[0x0D]); /* IDE */
+    qdev_connect_gpio_out(dev, 2, pic[0x02]); /* IDE DMA */
+    macio_init(macio, pic_mem, escc_bar);
 
     /* First IDE channel is a MAC IDE on the MacIO bus */
     macio_ide = MACIO_IDE(object_resolve_path_component(OBJECT(macio),
@@ -286,6 +281,9 @@ static void ppc_heathrow_init(QEMUMachineInitArgs *args)
     hd[3] = hd[2] = NULL;
     pci_cmd646_ide_init(pci_bus, hd, 0);
 
+    adb_kbd_init(&adb_bus);
+    adb_mouse_init(&adb_bus);
+
     if (usb_enabled(false)) {
         pci_create_simple(pci_bus, -1, "pci-ohci");
     }
Signature · 1 line
1.7.10.4
#21 lore raw
In reply to Andreas Färber
Quoted 17 lines · Andreas Färber

Hello,

As requested by Markus, here's a conversion of MacIO IDE to QOM. There's more work to be done, but in light of the approaching Soft Freeze here's my current state of affairs, lightly tested.

Patch 1 is a generic QOM API fix and could be applied independent of the ppc device conversion.

Patch 2 goes on to move PowerMac machines to hw/ppc/ as discussed with Alex. The intent would be to do the same for PReP once applied.

The remainder revives an old patch from the time of QOM introduction to split MacIO in two, allowing to move more logic into the device from the machine. This time it adopts new QOM concepts for embedding the sub-devices converted in the following patches. TODO: finalization support / object_unref().

Quoted 4 lines

ADB is still being worked on. DBDMA still TODO (but then again so is x86 DMA). ESCC would affect sparc as well.
The PICs pose cyclic dependency issues (mapped inside MacIO but MacIO as a PCIDevice needing a PCIBus, the Grackle/UniNorth PHBs needing a PIC IRQ).

Looks like a useful step forward to me already, and I'm looking forward to patches you consider merge-worthy. Thanks!

#22 lore raw
In reply to Andreas Färber

On 13/01/13 23:54, Andreas Färber wrote:

Hi Andreas,

Quoted 4 lines

ADB is still being worked on. DBDMA still TODO (but then again so is x86 DMA). ESCC would affect sparc as well.
The PICs pose cyclic dependency issues (mapped inside MacIO but MacIO as a PCIDevice needing a PCIBus, the Grackle/UniNorth PHBs needing a PIC IRQ).

I'll be very interested to test anything that involves converting the SPARC devices to QOM/qdev, as it's been on my TODO list for quite a while to see if it is possible to model SBus within QEMU.

ATB,

Mark.

#23 lore raw

Hi Mark,

Am 14.01.2013 22:56, schrieb Mark Cave-Ayland:

Quoted 6 lines · Andreas Färber
Quoted 1 line

ESCC would affect sparc as well.

I'll be very interested to test anything that involves converting the SPARC devices to QOM/qdev, as it's been on my TODO list for quite a while to see if it is possible to model SBus within QEMU.

The issue here is an organizational one: If I touch sparc then it's not suitable for ppc-next tree. If I do escc separately then the two series will conflict. So what I meant was I'll need to get ppc prereqs merged first before I get to escc (we're not under pressure for escc yet).

Thanks for the offer, I'll keep it in mind! I have a half-done conversion of ADB on git://repo.or.cz/qemu/afaerber.git macio:
http://repo.or.cz/w/qemu/afaerber.git/shortlog/refs/heads/macio

Cheers,
Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg