* [Qemu-devel] [RFC ppc-next v3 00/10] target-ppc: MacIO QOM'ification
@ 2013-01-13 23:54 Andreas Färber
2013-01-13 23:54 ` [Qemu-devel] [PATCH 01/10] qom: Make object_resolve_path_component() path argument const Andreas Färber
` (11 more replies)
0 siblings, 12 replies; 24+ messages in thread
From: Andreas Färber @ 2013-01-13 23:54 UTC (permalink / raw)
To: qemu-devel
Cc: Kevin Wolf, agraf, armbru, Blue Swirl, qemu-ppc,
Hervé Poussineau, 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().
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 <agraf@suse.de>
Cc: qemu-ppc <qemu-ppc@nongnu.org>
Cc: Markus Armbruster <armbru@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>
Cc: Blue Swirl <blauwirbel@gmail.com>
Cc: Hervé Poussineau <hpoussin@reactos.org>
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
--
1.7.10.4
^ permalink raw reply [flat|nested] 24+ messages in thread
* [Qemu-devel] [PATCH 01/10] qom: Make object_resolve_path_component() path argument const
2013-01-13 23:54 [Qemu-devel] [RFC ppc-next v3 00/10] target-ppc: MacIO QOM'ification Andreas Färber
@ 2013-01-13 23:54 ` Andreas Färber
2013-01-14 12:19 ` Markus Armbruster
2013-01-13 23:54 ` [Qemu-devel] [RFC ppc-next v3 02/10] ppc: Move Mac machines to hw/ppc/ Andreas Färber
` (10 subsequent siblings)
11 siblings, 1 reply; 24+ messages in thread
From: Andreas Färber @ 2013-01-13 23:54 UTC (permalink / raw)
To: qemu-devel; +Cc: Anthony Liguori, qemu-ppc, agraf, Andreas Färber, armbru
This allows to navigate partial well-known paths from an object.
Signed-off-by: Andreas Färber <afaerber@suse.de>
Cc: Anthony Liguori <anthony@codemonkey.ws>
---
include/qom/object.h | 2 +-
qom/object.c | 2 +-
2 Dateien geändert, 2 Zeilen hinzugefügt(+), 2 Zeilen entfernt(-)
diff --git a/include/qom/object.h b/include/qom/object.h
index d43b289..1ef2f0e 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -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:
diff --git a/qom/object.c b/qom/object.c
index 351b88c..03e6f24 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -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) {
--
1.7.10.4
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [Qemu-devel] [RFC ppc-next v3 02/10] ppc: Move Mac machines to hw/ppc/
2013-01-13 23:54 [Qemu-devel] [RFC ppc-next v3 00/10] target-ppc: MacIO QOM'ification Andreas Färber
2013-01-13 23:54 ` [Qemu-devel] [PATCH 01/10] qom: Make object_resolve_path_component() path argument const Andreas Färber
@ 2013-01-13 23:54 ` Andreas Färber
2013-01-13 23:54 ` [Qemu-devel] [RFC ppc-next v3 03/10] macio: QOM'ify some more Andreas Färber
` (9 subsequent siblings)
11 siblings, 0 replies; 24+ messages in thread
From: Andreas Färber @ 2013-01-13 23:54 UTC (permalink / raw)
To: qemu-devel; +Cc: Kevin Wolf, qemu-ppc, agraf, Andreas Färber, armbru
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
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%)
diff --git a/hw/cuda.c b/hw/cuda.c
index d59e0ae..bbd1fda 100644
--- a/hw/cuda.c
+++ b/hw/cuda.c
@@ -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"
diff --git a/hw/grackle_pci.c b/hw/grackle_pci.c
index 9484166..95639d5 100644
--- a/hw/grackle_pci.c
+++ b/hw/grackle_pci.c
@@ -24,7 +24,7 @@
*/
#include "pci/pci_host.h"
-#include "ppc_mac.h"
+#include "ppc/mac.h"
#include "pci/pci.h"
/* debug Grackle */
diff --git a/hw/heathrow_pic.c b/hw/heathrow_pic.c
index b9ec8e7..c0a71c3 100644
--- a/hw/heathrow_pic.c
+++ b/hw/heathrow_pic.c
@@ -23,7 +23,7 @@
* THE SOFTWARE.
*/
#include "hw.h"
-#include "ppc_mac.h"
+#include "ppc/mac.h"
/* debug PIC */
//#define DEBUG_PIC
diff --git a/hw/ide/macio.c b/hw/ide/macio.c
index d8f9b4b..e0f04dc 100644
--- a/hw/ide/macio.c
+++ b/hw/ide/macio.c
@@ -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"
diff --git a/hw/mac_nvram.c b/hw/mac_nvram.c
index 71093c2..eec7ca4 100644
--- a/hw/mac_nvram.c
+++ b/hw/mac_nvram.c
@@ -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
diff --git a/hw/macio.c b/hw/macio.c
index 675a71c..f01fc57 100644
--- a/hw/macio.c
+++ b/hw/macio.c
@@ -23,7 +23,7 @@
* THE SOFTWARE.
*/
#include "hw.h"
-#include "ppc_mac.h"
+#include "ppc/mac.h"
#include "pci/pci.h"
#include "escc.h"
diff --git a/hw/openpic.c b/hw/openpic.c
index 23fa8f9..7423685 100644
--- a/hw/openpic.c
+++ b/hw/openpic.c
@@ -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"
diff --git a/hw/ppc/Makefile.objs b/hw/ppc/Makefile.objs
index afdcc0e..462146b 100644
--- a/hw/ppc/Makefile.objs
+++ b/hw/ppc/Makefile.objs
@@ -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
diff --git a/hw/ppc_mac.h b/hw/ppc/mac.h
similarity index 100%
rename from hw/ppc_mac.h
rename to hw/ppc/mac.h
diff --git a/hw/ppc_newworld.c b/hw/ppc/mac_newworld.c
similarity index 98%
rename from hw/ppc_newworld.c
rename to hw/ppc/mac_newworld.c
index fabcc08..adf111c 100644
--- a/hw/ppc_newworld.c
+++ b/hw/ppc/mac_newworld.c
@@ -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
diff --git a/hw/ppc_oldworld.c b/hw/ppc/mac_oldworld.c
similarity index 97%
rename from hw/ppc_oldworld.c
rename to hw/ppc/mac_oldworld.c
index fff5129..0d9f65b 100644
--- a/hw/ppc_oldworld.c
+++ b/hw/ppc/mac_oldworld.c
@@ -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"
diff --git a/hw/unin_pci.c b/hw/unin_pci.c
index 4675792..f1c3c20 100644
--- a/hw/unin_pci.c
+++ b/hw/unin_pci.c
@@ -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"
--
1.7.10.4
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [Qemu-devel] [RFC ppc-next v3 03/10] macio: QOM'ify some more
2013-01-13 23:54 [Qemu-devel] [RFC ppc-next v3 00/10] target-ppc: MacIO QOM'ification Andreas Färber
2013-01-13 23:54 ` [Qemu-devel] [PATCH 01/10] qom: Make object_resolve_path_component() path argument const Andreas Färber
2013-01-13 23:54 ` [Qemu-devel] [RFC ppc-next v3 02/10] ppc: Move Mac machines to hw/ppc/ Andreas Färber
@ 2013-01-13 23:54 ` Andreas Färber
2013-01-13 23:54 ` [Qemu-devel] [RFC ppc-next v3 04/10] macio: Delay qdev init until all fields are initialized Andreas Färber
` (8 subsequent siblings)
11 siblings, 0 replies; 24+ messages in thread
From: Andreas Färber @ 2013-01-13 23:54 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-ppc, agraf, Andreas Färber, armbru
Move bar MemoryRegion initialization to an instance_init.
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
hw/macio.c | 25 +++++++++++++++++++------
1 Datei geändert, 19 Zeilen hinzugefügt(+), 6 Zeilen entfernt(-)
diff --git a/hw/macio.c b/hw/macio.c
index f01fc57..770e3bd 100644
--- a/hw/macio.c
+++ b/hw/macio.c
@@ -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;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [Qemu-devel] [RFC ppc-next v3 04/10] macio: Delay qdev init until all fields are initialized
2013-01-13 23:54 [Qemu-devel] [RFC ppc-next v3 00/10] target-ppc: MacIO QOM'ification Andreas Färber
` (2 preceding siblings ...)
2013-01-13 23:54 ` [Qemu-devel] [RFC ppc-next v3 03/10] macio: QOM'ify some more Andreas Färber
@ 2013-01-13 23:54 ` Andreas Färber
2013-01-13 23:54 ` [Qemu-devel] [RFC ppc-next v3 05/10] macio: Split MacIO in two Andreas Färber
` (7 subsequent siblings)
11 siblings, 0 replies; 24+ messages in thread
From: Andreas Färber @ 2013-01-13 23:54 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-ppc, agraf, Andreas Färber, armbru
This turns macio_bar_setup() into an implementation detail of the qdev
initfn, to be removed step by step.
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
hw/macio.c | 11 ++++++++---
1 Datei geändert, 8 Zeilen hinzugefügt(+), 3 Zeilen entfernt(-)
diff --git a/hw/macio.c b/hw/macio.c
index 770e3bd..8b4b48d 100644
--- a/hw/macio.c
+++ b/hw/macio.c
@@ -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));
}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [Qemu-devel] [RFC ppc-next v3 05/10] macio: Split MacIO in two
2013-01-13 23:54 [Qemu-devel] [RFC ppc-next v3 00/10] target-ppc: MacIO QOM'ification Andreas Färber
` (3 preceding siblings ...)
2013-01-13 23:54 ` [Qemu-devel] [RFC ppc-next v3 04/10] macio: Delay qdev init until all fields are initialized Andreas Färber
@ 2013-01-13 23:54 ` Andreas Färber
2013-01-13 23:55 ` [Qemu-devel] [RFC ppc-next v3 06/10] mac_nvram: Clean up public API Andreas Färber
` (6 subsequent siblings)
11 siblings, 0 replies; 24+ messages in thread
From: Andreas Färber @ 2013-01-13 23:54 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-ppc, agraf, Andreas Färber, armbru
Let the machines create two different types. This prepares to move
knowledge about sub-devices from the machines into the devices.
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
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(-)
diff --git a/hw/macio.c b/hw/macio.c
index 8b4b48d..0e6fc8d 100644
--- a/hw/macio.c
+++ b/hw/macio.c
@@ -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));
}
diff --git a/hw/ppc/mac.h b/hw/ppc/mac.h
index 89c7d66..864a610 100644
--- a/hw/ppc/mac.h
+++ b/hw/ppc/mac.h
@@ -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,
diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c
index adf111c..d1329dc 100644
--- a/hw/ppc/mac_newworld.c
+++ b/hw/ppc/mac_newworld.c
@@ -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)) {
diff --git a/hw/ppc/mac_oldworld.c b/hw/ppc/mac_oldworld.c
index 0d9f65b..74b3878 100644
--- a/hw/ppc/mac_oldworld.c
+++ b/hw/ppc/mac_oldworld.c
@@ -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)) {
--
1.7.10.4
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [Qemu-devel] [RFC ppc-next v3 06/10] mac_nvram: Clean up public API
2013-01-13 23:54 [Qemu-devel] [RFC ppc-next v3 00/10] target-ppc: MacIO QOM'ification Andreas Färber
` (4 preceding siblings ...)
2013-01-13 23:54 ` [Qemu-devel] [RFC ppc-next v3 05/10] macio: Split MacIO in two Andreas Färber
@ 2013-01-13 23:55 ` Andreas Färber
2013-01-13 23:55 ` [Qemu-devel] [RFC ppc-next v3 07/10] mac_nvram: Mark as Big Endian Andreas Färber
` (5 subsequent siblings)
11 siblings, 0 replies; 24+ messages in thread
From: Andreas Färber @ 2013-01-13 23:55 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-ppc, agraf, Andreas Färber, armbru
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.
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
hw/mac_nvram.c | 21 ++++++++++-----------
hw/ppc/mac.h | 4 ++--
2 Dateien geändert, 12 Zeilen hinzugefügt(+), 13 Zeilen entfernt(-)
diff --git a/hw/mac_nvram.c b/hw/mac_nvram.c
index eec7ca4..bcde07d 100644
--- a/hw/mac_nvram.c
+++ b/hw/mac_nvram.c
@@ -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,
diff --git a/hw/ppc/mac.h b/hw/ppc/mac.h
index 864a610..6441794 100644
--- a/hw/ppc/mac.h
+++ b/hw/ppc/mac.h
@@ -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__) */
--
1.7.10.4
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [Qemu-devel] [RFC ppc-next v3 07/10] mac_nvram: Mark as Big Endian
2013-01-13 23:54 [Qemu-devel] [RFC ppc-next v3 00/10] target-ppc: MacIO QOM'ification Andreas Färber
` (5 preceding siblings ...)
2013-01-13 23:55 ` [Qemu-devel] [RFC ppc-next v3 06/10] mac_nvram: Clean up public API Andreas Färber
@ 2013-01-13 23:55 ` Andreas Färber
2013-01-13 23:55 ` [Qemu-devel] [RFC ppc-next v3 08/10] mac_nvram: QOM'ify MacIO NVRAM Andreas Färber
` (4 subsequent siblings)
11 siblings, 0 replies; 24+ messages in thread
From: Andreas Färber @ 2013-01-13 23:55 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-ppc, agraf, Andreas Färber, armbru
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
hw/mac_nvram.c | 2 +-
1 Datei geändert, 1 Zeile hinzugefügt(+), 1 Zeile entfernt(-)
diff --git a/hw/mac_nvram.c b/hw/mac_nvram.c
index bcde07d..0a22e66 100644
--- a/hw/mac_nvram.c
+++ b/hw/mac_nvram.c
@@ -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 = {
--
1.7.10.4
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [Qemu-devel] [RFC ppc-next v3 08/10] mac_nvram: QOM'ify MacIO NVRAM
2013-01-13 23:54 [Qemu-devel] [RFC ppc-next v3 00/10] target-ppc: MacIO QOM'ification Andreas Färber
` (6 preceding siblings ...)
2013-01-13 23:55 ` [Qemu-devel] [RFC ppc-next v3 07/10] mac_nvram: Mark as Big Endian Andreas Färber
@ 2013-01-13 23:55 ` Andreas Färber
2013-01-14 12:34 ` Markus Armbruster
2013-01-13 23:55 ` [Qemu-devel] [RFC ppc-next v3 09/10] ide/macio: QOM'ify MacIO IDE Andreas Färber
` (3 subsequent siblings)
11 siblings, 1 reply; 24+ messages in thread
From: Andreas Färber @ 2013-01-13 23:55 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-ppc, agraf, Andreas Färber, armbru
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.
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
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(-)
diff --git a/hw/mac_nvram.c b/hw/mac_nvram.c
index 0a22e66..a832dda 100644
--- a/hw/mac_nvram.c
+++ b/hw/mac_nvram.c
@@ -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)
diff --git a/hw/macio.c b/hw/macio.c
index 0e6fc8d..32f359c 100644
--- a/hw/macio.c
+++ b/hw/macio.c
@@ -41,11 +41,21 @@ typedef struct MacIOState
MemoryRegion *dbdma_mem;
MemoryRegion *cuda_mem;
MemoryRegion *escc_mem;
- void *nvram;
int nb_ide;
MemoryRegion *ide_mem[4];
} MacIOState;
+#define OLDWORLD_MACIO(obj) \
+ OBJECT_CHECK(OldWorldMacIOState, (obj), TYPE_OLDWORLD_MACIO)
+
+typedef struct OldWorldMacIOState {
+ /*< private >*/
+ MacIOState parent_obj;
+ /*< public >*/
+
+ MacIONVRAMState nvram;
+} OldWorldMacIOState;
+
static void macio_bar_setup(MacIOState *macio_state)
{
int i;
@@ -66,8 +76,6 @@ static void macio_bar_setup(MacIOState *macio_state)
macio_state->ide_mem[i]);
}
}
- if (macio_state->nvram != NULL)
- macio_nvram_setup_bar(macio_state->nvram, bar, 0x60000);
}
static int macio_common_initfn(PCIDevice *d)
@@ -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);
+ SysBusDevice *sysbus_dev;
int ret = macio_common_initfn(d);
if (ret < 0) {
return ret;
}
+ ret = qdev_init(DEVICE(&os->nvram));
+ if (ret < 0) {
+ return ret;
+ }
+ sysbus_dev = SYS_BUS_DEVICE(&os->nvram);
+ memory_region_add_subregion(&s->bar, 0x60000,
+ sysbus_mmio_get_region(sysbus_dev, 0));
+ pmac_format_nvram_partition(&os->nvram, os->nvram.size);
+
if (s->pic_mem) {
/* Heathrow PIC */
memory_region_add_subregion(&s->bar, 0x00000, s->pic_mem);
@@ -98,6 +117,17 @@ static int macio_oldworld_initfn(PCIDevice *d)
return 0;
}
+static void macio_oldworld_init(Object *obj)
+{
+ OldWorldMacIOState *os = OLDWORLD_MACIO(obj);
+ DeviceState *dev;
+
+ object_initialize(&os->nvram, TYPE_MACIO_NVRAM);
+ dev = DEVICE(&os->nvram);
+ qdev_prop_set_uint32(dev, "size", 0x2000);
+ qdev_prop_set_uint32(dev, "it_shift", 4);
+}
+
static int macio_newworld_initfn(PCIDevice *d)
{
MacIOState *s = MACIO(d);
@@ -148,6 +178,8 @@ static void macio_class_init(ObjectClass *klass, void *data)
static const TypeInfo macio_oldworld_type_info = {
.name = TYPE_OLDWORLD_MACIO,
.parent = TYPE_MACIO,
+ .instance_size = sizeof(OldWorldMacIOState),
+ .instance_init = macio_oldworld_init,
.class_init = macio_oldworld_class_init,
};
@@ -177,7 +209,7 @@ type_init(macio_register_types)
void macio_init(PCIDevice *d,
MemoryRegion *pic_mem, MemoryRegion *dbdma_mem,
- MemoryRegion *cuda_mem, void *nvram,
+ MemoryRegion *cuda_mem,
int nb_ide, MemoryRegion **ide_mem,
MemoryRegion *escc_mem)
{
@@ -188,7 +220,6 @@ void macio_init(PCIDevice *d,
macio_state->dbdma_mem = dbdma_mem;
macio_state->cuda_mem = cuda_mem;
macio_state->escc_mem = escc_mem;
- macio_state->nvram = nvram;
if (nb_ide > 4)
nb_ide = 4;
macio_state->nb_ide = nb_ide;
diff --git a/hw/ppc/mac.h b/hw/ppc/mac.h
index 6441794..581e95c 100644
--- a/hw/ppc/mac.h
+++ b/hw/ppc/mac.h
@@ -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);
diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c
index d1329dc..4aef010 100644
--- a/hw/ppc/mac_newworld.c
+++ b/hw/ppc/mac_newworld.c
@@ -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);
diff --git a/hw/ppc/mac_oldworld.c b/hw/ppc/mac_oldworld.c
index 74b3878..d1bfbff 100644
--- a/hw/ppc/mac_oldworld.c
+++ b/hw/ppc/mac_oldworld.c
@@ -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");
--
1.7.10.4
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [Qemu-devel] [RFC ppc-next v3 09/10] ide/macio: QOM'ify MacIO IDE
2013-01-13 23:54 [Qemu-devel] [RFC ppc-next v3 00/10] target-ppc: MacIO QOM'ification Andreas Färber
` (7 preceding siblings ...)
2013-01-13 23:55 ` [Qemu-devel] [RFC ppc-next v3 08/10] mac_nvram: QOM'ify MacIO NVRAM Andreas Färber
@ 2013-01-13 23:55 ` Andreas Färber
2013-01-13 23:55 ` [Qemu-devel] [RFC ppc-next v3 10/10] cuda: QOM'ify CUDA Andreas Färber
` (2 subsequent siblings)
11 siblings, 0 replies; 24+ messages in thread
From: Andreas Färber @ 2013-01-13 23:55 UTC (permalink / raw)
To: qemu-devel; +Cc: Kevin Wolf, qemu-ppc, agraf, Andreas Färber, armbru
It was not qdev'ified before, turn it into a SysBusDevice.
Embed them into the MacIO devices.
Signed-off-by: Andreas Färber <afaerber@suse.de>
Cc: Markus Armbruster <armbru@redhat.com>
---
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(-)
diff --git a/hw/ide.h b/hw/ide.h
index 7e23cda..9b357c0 100644
--- a/hw/ide.h
+++ b/hw/ide.h
@@ -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,
diff --git a/hw/ide/macio.c b/hw/ide/macio.c
index e0f04dc..ca018f6 100644
--- a/hw/ide/macio.c
+++ b/hw/ide/macio.c
@@ -33,12 +33,6 @@
/***********************************************************/
/* MacIO based PowerPC IDE */
-typedef struct MACIOIDEState {
- MemoryRegion mem;
- IDEBus bus;
- BlockDriverAIOCB *aiocb;
-} MACIOIDEState;
-
#define MACIO_PAGE_SIZE 4096
static void pmac_ide_atapi_transfer_cb(void *opaque, int ret)
@@ -321,30 +315,73 @@ static const VMStateDescription vmstate_pmac = {
}
};
-static void pmac_ide_reset(void *opaque)
+static void macio_ide_reset(DeviceState *dev)
{
- MACIOIDEState *d = opaque;
+ MACIOIDEState *d = MACIO_IDE(dev);
ide_bus_reset(&d->bus);
}
-/* hd_table must contain 4 block drivers */
-/* PowerMac uses memory mapped registers, not I/O. Return the memory
- I/O index to access the ide. */
-MemoryRegion *pmac_ide_init (DriveInfo **hd_table, qemu_irq irq,
- void *dbdma, int channel, qemu_irq dma_irq)
+static int macio_ide_initfn(SysBusDevice *d)
{
- MACIOIDEState *d;
+ MACIOIDEState *s = MACIO_IDE(d);
- d = g_malloc0(sizeof(MACIOIDEState));
- ide_init2_with_non_qdev_drives(&d->bus, hd_table[0], hd_table[1], irq);
+ ide_init2(&s->bus, s->irq);
- if (dbdma)
- DBDMA_register_channel(dbdma, channel, dma_irq, pmac_ide_transfer, pmac_ide_flush, d);
+ return 0;
+}
+
+static void macio_ide_init(Object *obj)
+{
+ SysBusDevice *d = SYS_BUS_DEVICE(obj);
+ MACIOIDEState *s = MACIO_IDE(obj);
+
+ ide_bus_new(&s->bus, DEVICE(obj), 0);
+ memory_region_init_io(&s->mem, &pmac_ide_ops, s, "pmac-ide", 0x1000);
+ sysbus_init_mmio(d, &s->mem);
+ sysbus_init_irq(d, &s->irq);
+ sysbus_init_irq(d, &s->dma_irq);
+}
- memory_region_init_io(&d->mem, &pmac_ide_ops, d, "pmac-ide", 0x1000);
- vmstate_register(NULL, 0, &vmstate_pmac, d);
- qemu_register_reset(pmac_ide_reset, d);
+static void macio_ide_class_init(ObjectClass *oc, void *data)
+{
+ DeviceClass *dc = DEVICE_CLASS(oc);
+ SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(oc);
- return &d->mem;
+ dc->reset = macio_ide_reset;
+ dc->vmsd = &vmstate_pmac;
+ sdc->init = macio_ide_initfn;
}
+
+static const TypeInfo macio_ide_type_info = {
+ .name = TYPE_MACIO_IDE,
+ .parent = TYPE_SYS_BUS_DEVICE,
+ .instance_size = sizeof(MACIOIDEState),
+ .instance_init = macio_ide_init,
+ .class_init = macio_ide_class_init,
+};
+
+static void macio_ide_register_types(void)
+{
+ type_register_static(&macio_ide_type_info);
+}
+
+/* hd_table must contain 4 block drivers */
+void macio_ide_init_drives(MACIOIDEState *s, DriveInfo **hd_table)
+{
+ int i;
+
+ for (i = 0; i < 2; i++) {
+ if (hd_table[i]) {
+ ide_create_drive(&s->bus, i, hd_table[i]);
+ }
+ }
+}
+
+void macio_ide_register_dma(MACIOIDEState *s, void *dbdma, int channel)
+{
+ DBDMA_register_channel(dbdma, channel, s->dma_irq,
+ pmac_ide_transfer, pmac_ide_flush, s);
+}
+
+type_init(macio_ide_register_types)
diff --git a/hw/macio.c b/hw/macio.c
index 32f359c..36c00e3 100644
--- a/hw/macio.c
+++ b/hw/macio.c
@@ -25,6 +25,7 @@
#include "hw.h"
#include "ppc/mac.h"
#include "pci/pci.h"
+#include "mac_dbdma.h"
#include "escc.h"
#define TYPE_MACIO "macio"
@@ -37,12 +38,10 @@ typedef struct MacIOState
/*< public >*/
MemoryRegion bar;
+ void *dbdma;
MemoryRegion *pic_mem;
- MemoryRegion *dbdma_mem;
MemoryRegion *cuda_mem;
MemoryRegion *escc_mem;
- int nb_ide;
- MemoryRegion *ide_mem[4];
} MacIOState;
#define OLDWORLD_MACIO(obj) \
@@ -53,29 +52,33 @@ typedef struct OldWorldMacIOState {
MacIOState parent_obj;
/*< public >*/
+ qemu_irq irqs[2];
+
MacIONVRAMState nvram;
+ MACIOIDEState ide;
} OldWorldMacIOState;
+#define NEWWORLD_MACIO(obj) \
+ OBJECT_CHECK(NewWorldMacIOState, (obj), TYPE_NEWWORLD_MACIO)
+
+typedef struct NewWorldMacIOState {
+ /*< private >*/
+ MacIOState parent_obj;
+ /*< public >*/
+ qemu_irq irqs[4];
+ MACIOIDEState ide[2];
+} NewWorldMacIOState;
+
static void macio_bar_setup(MacIOState *macio_state)
{
- int i;
MemoryRegion *bar = &macio_state->bar;
- if (macio_state->dbdma_mem) {
- memory_region_add_subregion(bar, 0x08000, macio_state->dbdma_mem);
- }
if (macio_state->escc_mem) {
memory_region_add_subregion(bar, 0x13000, macio_state->escc_mem);
}
if (macio_state->cuda_mem) {
memory_region_add_subregion(bar, 0x16000, macio_state->cuda_mem);
}
- for (i = 0; i < macio_state->nb_ide; i++) {
- if (macio_state->ide_mem[i]) {
- memory_region_add_subregion(bar, 0x1f000 + (i * 0x1000),
- macio_state->ide_mem[i]);
- }
- }
}
static int macio_common_initfn(PCIDevice *d)
@@ -114,23 +117,42 @@ static int macio_oldworld_initfn(PCIDevice *d)
memory_region_add_subregion(&s->bar, 0x00000, s->pic_mem);
}
+ sysbus_dev = SYS_BUS_DEVICE(&os->ide);
+ sysbus_connect_irq(sysbus_dev, 0, os->irqs[0]);
+ sysbus_connect_irq(sysbus_dev, 1, os->irqs[1]);
+ macio_ide_register_dma(&os->ide, s->dbdma, 0x16);
+ ret = qdev_init(DEVICE(&os->ide));
+ if (ret < 0) {
+ return ret;
+ }
+
return 0;
}
static void macio_oldworld_init(Object *obj)
{
+ MacIOState *s = MACIO(obj);
OldWorldMacIOState *os = OLDWORLD_MACIO(obj);
DeviceState *dev;
+ qdev_init_gpio_out(DEVICE(obj), os->irqs, ARRAY_SIZE(os->irqs));
+
object_initialize(&os->nvram, TYPE_MACIO_NVRAM);
dev = DEVICE(&os->nvram);
qdev_prop_set_uint32(dev, "size", 0x2000);
qdev_prop_set_uint32(dev, "it_shift", 4);
+
+ object_initialize(&os->ide, TYPE_MACIO_IDE);
+ qdev_set_parent_bus(DEVICE(&os->ide), sysbus_get_default());
+ memory_region_add_subregion(&s->bar, 0x1f000 + (1 * 0x1000), &os->ide.mem);
+ object_property_add_child(obj, "ide", OBJECT(&os->ide), NULL);
}
static int macio_newworld_initfn(PCIDevice *d)
{
MacIOState *s = MACIO(d);
+ NewWorldMacIOState *ns = NEWWORLD_MACIO(d);
+ SysBusDevice *sysbus_dev;
int ret = macio_common_initfn(d);
if (ret < 0) {
return ret;
@@ -141,14 +163,56 @@ static int macio_newworld_initfn(PCIDevice *d)
memory_region_add_subregion(&s->bar, 0x40000, s->pic_mem);
}
+ sysbus_dev = SYS_BUS_DEVICE(&ns->ide[0]);
+ sysbus_connect_irq(sysbus_dev, 0, ns->irqs[0]);
+ sysbus_connect_irq(sysbus_dev, 1, ns->irqs[1]);
+ macio_ide_register_dma(&ns->ide[0], s->dbdma, 0x16);
+ ret = qdev_init(DEVICE(&ns->ide[0]));
+ if (ret < 0) {
+ return ret;
+ }
+
+ sysbus_dev = SYS_BUS_DEVICE(&ns->ide[1]);
+ sysbus_connect_irq(sysbus_dev, 0, ns->irqs[2]);
+ sysbus_connect_irq(sysbus_dev, 1, ns->irqs[3]);
+ macio_ide_register_dma(&ns->ide[0], s->dbdma, 0x1a);
+ ret = qdev_init(DEVICE(&ns->ide[1]));
+ if (ret < 0) {
+ return ret;
+ }
+
return 0;
}
+static void macio_newworld_init(Object *obj)
+{
+ MacIOState *s = MACIO(obj);
+ NewWorldMacIOState *ns = NEWWORLD_MACIO(obj);
+ int i;
+ gchar *name;
+
+ qdev_init_gpio_out(DEVICE(obj), ns->irqs, ARRAY_SIZE(ns->irqs));
+
+ for (i = 0; i < 2; i++) {
+ object_initialize(&ns->ide[i], TYPE_MACIO_IDE);
+ qdev_set_parent_bus(DEVICE(&ns->ide[i]), sysbus_get_default());
+ memory_region_add_subregion(&s->bar, 0x1f000 + ((i + 1) * 0x1000),
+ &ns->ide[i].mem);
+ name = g_strdup_printf("ide[%i]", i);
+ object_property_add_child(obj, name, OBJECT(&ns->ide[i]), NULL);
+ g_free(name);
+ }
+}
+
static void macio_instance_init(Object *obj)
{
MacIOState *s = MACIO(obj);
+ MemoryRegion *dbdma_mem;
memory_region_init(&s->bar, "macio", 0x80000);
+
+ s->dbdma = DBDMA_init(&dbdma_mem);
+ memory_region_add_subregion(&s->bar, 0x08000, dbdma_mem);
}
static void macio_oldworld_class_init(ObjectClass *oc, void *data)
@@ -186,6 +250,8 @@ static const TypeInfo macio_oldworld_type_info = {
static const TypeInfo macio_newworld_type_info = {
.name = TYPE_NEWWORLD_MACIO,
.parent = TYPE_MACIO,
+ .instance_size = sizeof(NewWorldMacIOState),
+ .instance_init = macio_newworld_init,
.class_init = macio_newworld_class_init,
};
@@ -208,23 +274,15 @@ static void macio_register_types(void)
type_init(macio_register_types)
void macio_init(PCIDevice *d,
- MemoryRegion *pic_mem, MemoryRegion *dbdma_mem,
+ MemoryRegion *pic_mem,
MemoryRegion *cuda_mem,
- int nb_ide, MemoryRegion **ide_mem,
MemoryRegion *escc_mem)
{
MacIOState *macio_state = MACIO(d);
- int i;
macio_state->pic_mem = pic_mem;
- macio_state->dbdma_mem = dbdma_mem;
macio_state->cuda_mem = cuda_mem;
macio_state->escc_mem = escc_mem;
- if (nb_ide > 4)
- nb_ide = 4;
- macio_state->nb_ide = nb_ide;
- for (i = 0; i < nb_ide; i++)
- macio_state->ide_mem[i] = ide_mem[i];
/* Note: this code is strongly inspirated from the corresponding code
in PearPC */
diff --git a/hw/ppc/mac.h b/hw/ppc/mac.h
index 581e95c..3e390d3 100644
--- a/hw/ppc/mac.h
+++ b/hw/ppc/mac.h
@@ -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,
diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c
index 4aef010..9a91c91 100644
--- a/hw/ppc/mac_newworld.c
+++ b/hw/ppc/mac_newworld.c
@@ -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");
diff --git a/hw/ppc/mac_oldworld.c b/hw/ppc/mac_oldworld.c
index d1bfbff..7014b4c 100644
--- a/hw/ppc/mac_oldworld.c
+++ b/hw/ppc/mac_oldworld.c
@@ -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");
--
1.7.10.4
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [Qemu-devel] [RFC ppc-next v3 10/10] cuda: QOM'ify CUDA
2013-01-13 23:54 [Qemu-devel] [RFC ppc-next v3 00/10] target-ppc: MacIO QOM'ification Andreas Färber
` (8 preceding siblings ...)
2013-01-13 23:55 ` [Qemu-devel] [RFC ppc-next v3 09/10] ide/macio: QOM'ify MacIO IDE Andreas Färber
@ 2013-01-13 23:55 ` Andreas Färber
2013-01-14 12:47 ` [Qemu-devel] [RFC ppc-next v3 00/10] target-ppc: MacIO QOM'ification Markus Armbruster
2013-01-14 21:56 ` [Qemu-devel] [Qemu-ppc] " Mark Cave-Ayland
11 siblings, 0 replies; 24+ messages in thread
From: Andreas Färber @ 2013-01-13 23:55 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-ppc, agraf, Andreas Färber, armbru
It was not qdev'ified before, turn it into a SysBusDevice and embed it
in MacIO.
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
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(-)
diff --git a/hw/cuda.c b/hw/cuda.c
index bbd1fda..26c96cc 100644
--- a/hw/cuda.c
+++ b/hw/cuda.c
@@ -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)
diff --git a/hw/macio.c b/hw/macio.c
index 36c00e3..74bdcd1 100644
--- a/hw/macio.c
+++ b/hw/macio.c
@@ -38,9 +38,9 @@ typedef struct MacIOState
/*< public >*/
MemoryRegion bar;
+ CUDAState cuda;
void *dbdma;
MemoryRegion *pic_mem;
- MemoryRegion *cuda_mem;
MemoryRegion *escc_mem;
} MacIOState;
@@ -52,7 +52,7 @@ typedef struct OldWorldMacIOState {
MacIOState parent_obj;
/*< public >*/
- qemu_irq irqs[2];
+ qemu_irq irqs[3];
MacIONVRAMState nvram;
MACIOIDEState ide;
@@ -65,7 +65,7 @@ typedef struct NewWorldMacIOState {
/*< private >*/
MacIOState parent_obj;
/*< public >*/
- qemu_irq irqs[4];
+ qemu_irq irqs[5];
MACIOIDEState ide[2];
} NewWorldMacIOState;
@@ -76,17 +76,24 @@ static void macio_bar_setup(MacIOState *macio_state)
if (macio_state->escc_mem) {
memory_region_add_subregion(bar, 0x13000, macio_state->escc_mem);
}
- if (macio_state->cuda_mem) {
- memory_region_add_subregion(bar, 0x16000, macio_state->cuda_mem);
- }
}
static int macio_common_initfn(PCIDevice *d)
{
MacIOState *s = MACIO(d);
+ SysBusDevice *sysbus_dev;
+ int ret;
d->config[0x3d] = 0x01; // interrupt on pin 1
+ ret = qdev_init(DEVICE(&s->cuda));
+ if (ret < 0) {
+ return ret;
+ }
+ sysbus_dev = SYS_BUS_DEVICE(&s->cuda);
+ memory_region_add_subregion(&s->bar, 0x16000,
+ sysbus_mmio_get_region(sysbus_dev, 0));
+
macio_bar_setup(s);
pci_register_bar(d, 0, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->bar);
@@ -103,6 +110,9 @@ static int macio_oldworld_initfn(PCIDevice *d)
return ret;
}
+ sysbus_dev = SYS_BUS_DEVICE(&s->cuda);
+ sysbus_connect_irq(sysbus_dev, 0, os->irqs[0]);
+
ret = qdev_init(DEVICE(&os->nvram));
if (ret < 0) {
return ret;
@@ -118,8 +128,8 @@ static int macio_oldworld_initfn(PCIDevice *d)
}
sysbus_dev = SYS_BUS_DEVICE(&os->ide);
- sysbus_connect_irq(sysbus_dev, 0, os->irqs[0]);
- sysbus_connect_irq(sysbus_dev, 1, os->irqs[1]);
+ sysbus_connect_irq(sysbus_dev, 0, os->irqs[1]);
+ sysbus_connect_irq(sysbus_dev, 1, os->irqs[2]);
macio_ide_register_dma(&os->ide, s->dbdma, 0x16);
ret = qdev_init(DEVICE(&os->ide));
if (ret < 0) {
@@ -158,14 +168,17 @@ static int macio_newworld_initfn(PCIDevice *d)
return ret;
}
+ sysbus_dev = SYS_BUS_DEVICE(&s->cuda);
+ sysbus_connect_irq(sysbus_dev, 0, ns->irqs[0]);
+
if (s->pic_mem) {
/* OpenPIC */
memory_region_add_subregion(&s->bar, 0x40000, s->pic_mem);
}
sysbus_dev = SYS_BUS_DEVICE(&ns->ide[0]);
- sysbus_connect_irq(sysbus_dev, 0, ns->irqs[0]);
- sysbus_connect_irq(sysbus_dev, 1, ns->irqs[1]);
+ sysbus_connect_irq(sysbus_dev, 0, ns->irqs[1]);
+ sysbus_connect_irq(sysbus_dev, 1, ns->irqs[2]);
macio_ide_register_dma(&ns->ide[0], s->dbdma, 0x16);
ret = qdev_init(DEVICE(&ns->ide[0]));
if (ret < 0) {
@@ -173,8 +186,8 @@ static int macio_newworld_initfn(PCIDevice *d)
}
sysbus_dev = SYS_BUS_DEVICE(&ns->ide[1]);
- sysbus_connect_irq(sysbus_dev, 0, ns->irqs[2]);
- sysbus_connect_irq(sysbus_dev, 1, ns->irqs[3]);
+ sysbus_connect_irq(sysbus_dev, 0, ns->irqs[3]);
+ sysbus_connect_irq(sysbus_dev, 1, ns->irqs[4]);
macio_ide_register_dma(&ns->ide[0], s->dbdma, 0x1a);
ret = qdev_init(DEVICE(&ns->ide[1]));
if (ret < 0) {
@@ -211,6 +224,10 @@ static void macio_instance_init(Object *obj)
memory_region_init(&s->bar, "macio", 0x80000);
+ object_initialize(&s->cuda, TYPE_CUDA);
+ qdev_set_parent_bus(DEVICE(&s->cuda), sysbus_get_default());
+ object_property_add_child(obj, "cuda", OBJECT(&s->cuda), NULL);
+
s->dbdma = DBDMA_init(&dbdma_mem);
memory_region_add_subregion(&s->bar, 0x08000, dbdma_mem);
}
@@ -275,13 +292,11 @@ type_init(macio_register_types)
void macio_init(PCIDevice *d,
MemoryRegion *pic_mem,
- MemoryRegion *cuda_mem,
MemoryRegion *escc_mem)
{
MacIOState *macio_state = MACIO(d);
macio_state->pic_mem = pic_mem;
- macio_state->cuda_mem = cuda_mem;
macio_state->escc_mem = escc_mem;
/* Note: this code is strongly inspirated from the corresponding code
in PearPC */
diff --git a/hw/ppc/mac.h b/hw/ppc/mac.h
index 3e390d3..26cb497 100644
--- a/hw/ppc/mac.h
+++ b/hw/ppc/mac.h
@@ -44,7 +44,72 @@
#define ESCC_CLOCK 3686400
/* Cuda */
-void cuda_init (MemoryRegion **cuda_mem, qemu_irq irq);
+#define TYPE_CUDA "cuda"
+#define CUDA(obj) OBJECT_CHECK(CUDAState, (obj), TYPE_CUDA)
+
+/**
+ * CUDATimer:
+ * @counter_value: counter value at load time
+ */
+typedef struct CUDATimer {
+ int index;
+ uint16_t latch;
+ uint16_t counter_value;
+ int64_t load_time;
+ int64_t next_irq_time;
+ QEMUTimer *timer;
+} CUDATimer;
+
+/**
+ * CUDAState:
+ * @b: B-side data
+ * @a: A-side data
+ * @dirb: B-side direction (1=output)
+ * @dira: A-side direction (1=output)
+ * @sr: Shift register
+ * @acr: Auxiliary control register
+ * @pcr: Peripheral control register
+ * @ifr: Interrupt flag register
+ * @ier: Interrupt enable register
+ * @anh: A-side data, no handshake
+ * @last_b: last value of B register
+ * @last_acr: last value of ACR register
+ */
+typedef struct CUDAState {
+ /*< private >*/
+ SysBusDevice parent_obj;
+ /*< public >*/
+
+ MemoryRegion mem;
+ /* cuda registers */
+ uint8_t b;
+ uint8_t a;
+ uint8_t dirb;
+ uint8_t dira;
+ uint8_t sr;
+ uint8_t acr;
+ uint8_t pcr;
+ uint8_t ifr;
+ uint8_t ier;
+ uint8_t anh;
+
+ CUDATimer timers[2];
+
+ uint32_t tick_offset;
+
+ uint8_t last_b;
+ uint8_t last_acr;
+
+ 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;
/* MacIO */
#define TYPE_OLDWORLD_MACIO "macio-oldworld"
@@ -71,7 +136,6 @@ void macio_ide_register_dma(MACIOIDEState *ide, void *dbdma, int channel);
void macio_init(PCIDevice *dev,
MemoryRegion *pic_mem,
- MemoryRegion *cuda_mem,
MemoryRegion *escc_mem);
/* Heathrow PIC */
diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c
index 9a91c91..1ba1c0b 100644
--- a/hw/ppc/mac_newworld.c
+++ b/hw/ppc/mac_newworld.c
@@ -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
diff --git a/hw/ppc/mac_oldworld.c b/hw/ppc/mac_oldworld.c
index 7014b4c..4ffdd01 100644
--- a/hw/ppc/mac_oldworld.c
+++ b/hw/ppc/mac_oldworld.c
@@ -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");
}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 24+ messages in thread
* Re: [Qemu-devel] [PATCH 01/10] qom: Make object_resolve_path_component() path argument const
2013-01-13 23:54 ` [Qemu-devel] [PATCH 01/10] qom: Make object_resolve_path_component() path argument const Andreas Färber
@ 2013-01-14 12:19 ` Markus Armbruster
2013-01-14 16:52 ` Andreas Färber
0 siblings, 1 reply; 24+ messages in thread
From: Markus Armbruster @ 2013-01-14 12:19 UTC (permalink / raw)
To: Andreas Färber; +Cc: qemu-ppc, qemu-devel, Anthony Liguori, agraf
Andreas Färber <afaerber@suse.de> writes:
> This allows to navigate partial well-known paths from an object.
Why does making the argument const allow such navigation?
> Signed-off-by: Andreas Färber <afaerber@suse.de>
> Cc: Anthony Liguori <anthony@codemonkey.ws>
> ---
> include/qom/object.h | 2 +-
> qom/object.c | 2 +-
> 2 Dateien geändert, 2 Zeilen hinzugefügt(+), 2 Zeilen entfernt(-)
>
> diff --git a/include/qom/object.h b/include/qom/object.h
> index d43b289..1ef2f0e 100644
> --- a/include/qom/object.h
> +++ b/include/qom/object.h
> @@ -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:
> diff --git a/qom/object.c b/qom/object.c
> index 351b88c..03e6f24 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -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?
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [Qemu-devel] [RFC ppc-next v3 08/10] mac_nvram: QOM'ify MacIO NVRAM
2013-01-13 23:55 ` [Qemu-devel] [RFC ppc-next v3 08/10] mac_nvram: QOM'ify MacIO NVRAM Andreas Färber
@ 2013-01-14 12:34 ` Markus Armbruster
2013-01-14 16:22 ` Andreas Färber
0 siblings, 1 reply; 24+ messages in thread
From: Markus Armbruster @ 2013-01-14 12:34 UTC (permalink / raw)
To: Andreas Färber; +Cc: qemu-ppc, qemu-devel, agraf
Andreas Färber <afaerber@suse.de> writes:
> 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.
[...]
> diff --git a/hw/macio.c b/hw/macio.c
> index 0e6fc8d..32f359c 100644
> --- a/hw/macio.c
> +++ b/hw/macio.c
[...]
> @@ -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.
> + SysBusDevice *sysbus_dev;
> int ret = macio_common_initfn(d);
> if (ret < 0) {
> return ret;
[...]
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [Qemu-devel] [RFC ppc-next v3 00/10] target-ppc: MacIO QOM'ification
2013-01-13 23:54 [Qemu-devel] [RFC ppc-next v3 00/10] target-ppc: MacIO QOM'ification Andreas Färber
` (9 preceding siblings ...)
2013-01-13 23:55 ` [Qemu-devel] [RFC ppc-next v3 10/10] cuda: QOM'ify CUDA Andreas Färber
@ 2013-01-14 12:47 ` Markus Armbruster
2013-01-14 21:56 ` [Qemu-devel] [Qemu-ppc] " Mark Cave-Ayland
11 siblings, 0 replies; 24+ messages in thread
From: Markus Armbruster @ 2013-01-14 12:47 UTC (permalink / raw)
To: Andreas Färber
Cc: Kevin Wolf, qemu-devel, agraf, Blue Swirl, Hervé Poussineau,
qemu-ppc
Andreas Färber <afaerber@suse.de> writes:
> 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).
Looks like a useful step forward to me already, and I'm looking forward
to patches you consider merge-worthy. Thanks!
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [Qemu-devel] [RFC ppc-next v3 08/10] mac_nvram: QOM'ify MacIO NVRAM
2013-01-14 12:34 ` Markus Armbruster
@ 2013-01-14 16:22 ` Andreas Färber
2013-01-14 17:30 ` Markus Armbruster
0 siblings, 1 reply; 24+ messages in thread
From: Andreas Färber @ 2013-01-14 16:22 UTC (permalink / raw)
To: Markus Armbruster; +Cc: qemu-ppc, qemu-devel, agraf
Am 14.01.2013 13:34, schrieb Markus Armbruster:
> Andreas Färber <afaerber@suse.de> writes:
>
>> 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.
> [...]
>> diff --git a/hw/macio.c b/hw/macio.c
>> index 0e6fc8d..32f359c 100644
>> --- a/hw/macio.c
>> +++ b/hw/macio.c
> [...]
>> @@ -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
>
>> + SysBusDevice *sysbus_dev;
>> int ret = macio_common_initfn(d);
>> if (ret < 0) {
>> return ret;
> [...]
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [Qemu-devel] [PATCH 01/10] qom: Make object_resolve_path_component() path argument const
2013-01-14 12:19 ` Markus Armbruster
@ 2013-01-14 16:52 ` Andreas Färber
2013-01-14 17:27 ` Markus Armbruster
2013-01-14 19:01 ` [Qemu-devel] Go along with glib's basic type typedef silliness? (was: [PATCH 01/10] qom: Make object_resolve_path_component() path argument const) Markus Armbruster
0 siblings, 2 replies; 24+ messages in thread
From: Andreas Färber @ 2013-01-14 16:52 UTC (permalink / raw)
To: Markus Armbruster
Cc: qemu-trivial, qemu-ppc, qemu-devel, Anthony Liguori, agraf
Am 14.01.2013 13:19, schrieb Markus Armbruster:
> Andreas Färber <afaerber@suse.de> writes:
>
>> 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]);
>> Signed-off-by: Andreas Färber <afaerber@suse.de>
>> Cc: Anthony Liguori <anthony@codemonkey.ws>
>> ---
>> include/qom/object.h | 2 +-
>> qom/object.c | 2 +-
>> 2 Dateien geändert, 2 Zeilen hinzugefügt(+), 2 Zeilen entfernt(-)
>>
>> diff --git a/include/qom/object.h b/include/qom/object.h
>> index d43b289..1ef2f0e 100644
>> --- a/include/qom/object.h
>> +++ b/include/qom/object.h
>> @@ -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:
>> diff --git a/qom/object.c b/qom/object.c
>> index 351b88c..03e6f24 100644
>> --- a/qom/object.c
>> +++ b/qom/object.c
>> @@ -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?
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
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [Qemu-devel] [PATCH 01/10] qom: Make object_resolve_path_component() path argument const
2013-01-14 16:52 ` Andreas Färber
@ 2013-01-14 17:27 ` Markus Armbruster
2013-01-14 19:01 ` [Qemu-devel] Go along with glib's basic type typedef silliness? (was: [PATCH 01/10] qom: Make object_resolve_path_component() path argument const) Markus Armbruster
1 sibling, 0 replies; 24+ messages in thread
From: Markus Armbruster @ 2013-01-14 17:27 UTC (permalink / raw)
To: Andreas Färber
Cc: qemu-trivial, qemu-ppc, qemu-devel, Anthony Liguori, agraf
Andreas Färber <afaerber@suse.de> writes:
> Am 14.01.2013 13:19, schrieb Markus Armbruster:
>> Andreas Färber <afaerber@suse.de> writes:
>>
>>> 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]);
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.
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [Qemu-devel] [RFC ppc-next v3 08/10] mac_nvram: QOM'ify MacIO NVRAM
2013-01-14 16:22 ` Andreas Färber
@ 2013-01-14 17:30 ` Markus Armbruster
0 siblings, 0 replies; 24+ messages in thread
From: Markus Armbruster @ 2013-01-14 17:30 UTC (permalink / raw)
To: Andreas Färber; +Cc: qemu-ppc, qemu-devel, agraf
Andreas Färber <afaerber@suse.de> writes:
> Am 14.01.2013 13:34, schrieb Markus Armbruster:
>> Andreas Färber <afaerber@suse.de> writes:
>>
>>> 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.
>> [...]
>>> diff --git a/hw/macio.c b/hw/macio.c
>>> index 0e6fc8d..32f359c 100644
>>> --- a/hw/macio.c
>>> +++ b/hw/macio.c
>> [...]
>>> @@ -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.)
Isn't &os->parent_obj == s ? s-> then becomes os->parent_obj.
Repeat: matter of taste, use your judgement.
^ permalink raw reply [flat|nested] 24+ messages in thread
* [Qemu-devel] Go along with glib's basic type typedef silliness? (was: [PATCH 01/10] qom: Make object_resolve_path_component() path argument const)
2013-01-14 16:52 ` Andreas Färber
2013-01-14 17:27 ` Markus Armbruster
@ 2013-01-14 19:01 ` Markus Armbruster
2013-01-17 20:26 ` Blue Swirl
1 sibling, 1 reply; 24+ messages in thread
From: Markus Armbruster @ 2013-01-14 19:01 UTC (permalink / raw)
To: Andreas Färber
Cc: qemu-trivial, qemu-ppc, qemu-devel, Anthony Liguori, agraf
[Thread hijack, dropping cc: qemu-trivial, qemu-ppc]
Andreas Färber <afaerber@suse.de> writes:
> Am 14.01.2013 13:19, schrieb Markus Armbruster:
>> Andreas Färber <afaerber@suse.de> writes:
[...]
>>> diff --git a/qom/object.c b/qom/object.c
>>> index 351b88c..03e6f24 100644
>>> --- a/qom/object.c
>>> +++ b/qom/object.c
>>> @@ -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?
>
> 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
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [Qemu-devel] [Qemu-ppc] [RFC ppc-next v3 00/10] target-ppc: MacIO QOM'ification
2013-01-13 23:54 [Qemu-devel] [RFC ppc-next v3 00/10] target-ppc: MacIO QOM'ification Andreas Färber
` (10 preceding siblings ...)
2013-01-14 12:47 ` [Qemu-devel] [RFC ppc-next v3 00/10] target-ppc: MacIO QOM'ification Markus Armbruster
@ 2013-01-14 21:56 ` Mark Cave-Ayland
2013-01-18 16:36 ` Andreas Färber
11 siblings, 1 reply; 24+ messages in thread
From: Mark Cave-Ayland @ 2013-01-14 21:56 UTC (permalink / raw)
To: qemu-devel
On 13/01/13 23:54, Andreas Färber wrote:
Hi Andreas,
> 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.
^ permalink raw reply [flat|nested] 24+ messages in thread
* 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)
2013-01-14 19:01 ` [Qemu-devel] Go along with glib's basic type typedef silliness? (was: [PATCH 01/10] qom: Make object_resolve_path_component() path argument const) Markus Armbruster
@ 2013-01-17 20:26 ` Blue Swirl
2013-01-18 15:36 ` [Qemu-devel] Go along with glib's basic type typedef silliness? Markus Armbruster
0 siblings, 1 reply; 24+ messages in thread
From: Blue Swirl @ 2013-01-17 20:26 UTC (permalink / raw)
To: Markus Armbruster
Cc: qemu-trivial, agraf, qemu-devel, qemu-ppc, Anthony Liguori,
Andreas Färber
On Mon, Jan 14, 2013 at 7:01 PM, Markus Armbruster <armbru@redhat.com> wrote:
> [Thread hijack, dropping cc: qemu-trivial, qemu-ppc]
>
> Andreas Färber <afaerber@suse.de> writes:
>
>> Am 14.01.2013 13:19, schrieb Markus Armbruster:
>>> Andreas Färber <afaerber@suse.de> writes:
> [...]
>>>> diff --git a/qom/object.c b/qom/object.c
>>>> index 351b88c..03e6f24 100644
>>>> --- a/qom/object.c
>>>> +++ b/qom/object.c
>>>> @@ -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?
>>
>> 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.
CONST, WORD, PWORD, DWORD, FLOAT etc. in a certain platform...
>
> [...]
>
>
> [*] http://developer.gnome.org/glib/stable/glib-Basic-Types.html
>
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [Qemu-devel] Go along with glib's basic type typedef silliness?
2013-01-17 20:26 ` Blue Swirl
@ 2013-01-18 15:36 ` Markus Armbruster
2013-01-19 9:13 ` Blue Swirl
0 siblings, 1 reply; 24+ messages in thread
From: Markus Armbruster @ 2013-01-18 15:36 UTC (permalink / raw)
To: Blue Swirl
Cc: qemu-trivial, agraf, qemu-devel, qemu-ppc, Anthony Liguori,
Andreas Färber
Blue Swirl <blauwirbel@gmail.com> writes:
> On Mon, Jan 14, 2013 at 7:01 PM, Markus Armbruster <armbru@redhat.com> wrote:
>> [Thread hijack, dropping cc: qemu-trivial, qemu-ppc]
>>
>> Andreas Färber <afaerber@suse.de> writes:
>>
>>> Am 14.01.2013 13:19, schrieb Markus Armbruster:
>>>> Andreas Färber <afaerber@suse.de> writes:
>> [...]
>>>>> diff --git a/qom/object.c b/qom/object.c
>>>>> index 351b88c..03e6f24 100644
>>>>> --- a/qom/object.c
>>>>> +++ b/qom/object.c
>>>>> @@ -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?
>>>
>>> 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.
>
> CONST, WORD, PWORD, DWORD, FLOAT etc. in a certain platform...
MY EYES, MY EYES, WHAT DID YOU DO TO MY EYES!!!
[...]
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [Qemu-devel] [Qemu-ppc] [RFC ppc-next v3 00/10] target-ppc: MacIO QOM'ification
2013-01-14 21:56 ` [Qemu-devel] [Qemu-ppc] " Mark Cave-Ayland
@ 2013-01-18 16:36 ` Andreas Färber
0 siblings, 0 replies; 24+ messages in thread
From: Andreas Färber @ 2013-01-18 16:36 UTC (permalink / raw)
To: Mark Cave-Ayland; +Cc: qemu-devel
Hi Mark,
Am 14.01.2013 22:56, schrieb Mark Cave-Ayland:
> On 13/01/13 23:54, Andreas Färber wrote:
>> 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
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [Qemu-devel] Go along with glib's basic type typedef silliness?
2013-01-18 15:36 ` [Qemu-devel] Go along with glib's basic type typedef silliness? Markus Armbruster
@ 2013-01-19 9:13 ` Blue Swirl
0 siblings, 0 replies; 24+ messages in thread
From: Blue Swirl @ 2013-01-19 9:13 UTC (permalink / raw)
To: Markus Armbruster
Cc: qemu-trivial, agraf, qemu-devel, qemu-ppc, Anthony Liguori,
Andreas Färber
On Fri, Jan 18, 2013 at 3:36 PM, Markus Armbruster <armbru@redhat.com> wrote:
> Blue Swirl <blauwirbel@gmail.com> writes:
>
>> On Mon, Jan 14, 2013 at 7:01 PM, Markus Armbruster <armbru@redhat.com> wrote:
>>> [Thread hijack, dropping cc: qemu-trivial, qemu-ppc]
>>>
>>> Andreas Färber <afaerber@suse.de> writes:
>>>
>>>> Am 14.01.2013 13:19, schrieb Markus Armbruster:
>>>>> Andreas Färber <afaerber@suse.de> writes:
>>> [...]
>>>>>> diff --git a/qom/object.c b/qom/object.c
>>>>>> index 351b88c..03e6f24 100644
>>>>>> --- a/qom/object.c
>>>>>> +++ b/qom/object.c
>>>>>> @@ -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?
>>>>
>>>> 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.
>>
>> 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
>
> [...]
^ permalink raw reply [flat|nested] 24+ messages in thread
end of thread, other threads:[~2013-01-19 9:13 UTC | newest]
Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-13 23:54 [Qemu-devel] [RFC ppc-next v3 00/10] target-ppc: MacIO QOM'ification Andreas Färber
2013-01-13 23:54 ` [Qemu-devel] [PATCH 01/10] qom: Make object_resolve_path_component() path argument const Andreas Färber
2013-01-14 12:19 ` Markus Armbruster
2013-01-14 16:52 ` Andreas Färber
2013-01-14 17:27 ` Markus Armbruster
2013-01-14 19:01 ` [Qemu-devel] Go along with glib's basic type typedef silliness? (was: [PATCH 01/10] qom: Make object_resolve_path_component() path argument const) Markus Armbruster
2013-01-17 20:26 ` Blue Swirl
2013-01-18 15:36 ` [Qemu-devel] Go along with glib's basic type typedef silliness? Markus Armbruster
2013-01-19 9:13 ` Blue Swirl
2013-01-13 23:54 ` [Qemu-devel] [RFC ppc-next v3 02/10] ppc: Move Mac machines to hw/ppc/ Andreas Färber
2013-01-13 23:54 ` [Qemu-devel] [RFC ppc-next v3 03/10] macio: QOM'ify some more Andreas Färber
2013-01-13 23:54 ` [Qemu-devel] [RFC ppc-next v3 04/10] macio: Delay qdev init until all fields are initialized Andreas Färber
2013-01-13 23:54 ` [Qemu-devel] [RFC ppc-next v3 05/10] macio: Split MacIO in two Andreas Färber
2013-01-13 23:55 ` [Qemu-devel] [RFC ppc-next v3 06/10] mac_nvram: Clean up public API Andreas Färber
2013-01-13 23:55 ` [Qemu-devel] [RFC ppc-next v3 07/10] mac_nvram: Mark as Big Endian Andreas Färber
2013-01-13 23:55 ` [Qemu-devel] [RFC ppc-next v3 08/10] mac_nvram: QOM'ify MacIO NVRAM Andreas Färber
2013-01-14 12:34 ` Markus Armbruster
2013-01-14 16:22 ` Andreas Färber
2013-01-14 17:30 ` Markus Armbruster
2013-01-13 23:55 ` [Qemu-devel] [RFC ppc-next v3 09/10] ide/macio: QOM'ify MacIO IDE Andreas Färber
2013-01-13 23:55 ` [Qemu-devel] [RFC ppc-next v3 10/10] cuda: QOM'ify CUDA Andreas Färber
2013-01-14 12:47 ` [Qemu-devel] [RFC ppc-next v3 00/10] target-ppc: MacIO QOM'ification Markus Armbruster
2013-01-14 21:56 ` [Qemu-devel] [Qemu-ppc] " Mark Cave-Ayland
2013-01-18 16:36 ` Andreas Färber
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).