* [Qemu-devel] [RESEND][PATCH 1/9] pxa2xx_pcmcia: qdevify
@ 2011-04-25 9:06 Dmitry Eremin-Solenikov
2011-04-25 9:06 ` [Qemu-devel] [RESEND][PATCH 2/9] PCMCIA: start qdev'ication Dmitry Eremin-Solenikov
` (8 more replies)
0 siblings, 9 replies; 21+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-04-25 9:06 UTC (permalink / raw)
To: qemu-devel
Use qdev insfrastructure for managing PXA PCMCIA devices. PCMCIA bus
itself isn't converted to QBus (yet). pxa2xx_pcmcia_init() function is
moved to pcmcia.h as it will be used by other cores/devices (like
StrongARM).
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
hw/mainstone.c | 14 +++++----
hw/pcmcia.h | 3 ++
hw/pxa.h | 5 +---
hw/pxa2xx.c | 9 +++---
hw/pxa2xx_pcmcia.c | 77 +++++++++++++++++++++++++++++++++++++--------------
hw/spitz.c | 20 ++++++++-----
hw/tosa.c | 12 ++++----
7 files changed, 91 insertions(+), 49 deletions(-)
diff --git a/hw/mainstone.c b/hw/mainstone.c
index 4792f0e..11de723 100644
--- a/hw/mainstone.c
+++ b/hw/mainstone.c
@@ -148,12 +148,14 @@ static void mainstone_common_init(ram_addr_t ram_size,
/* MMC/SD host */
pxa2xx_mmci_handlers(cpu->mmc, NULL, qdev_get_gpio_in(mst_irq, MMC_IRQ));
- pxa2xx_pcmcia_set_irq_cb(cpu->pcmcia[0],
- qdev_get_gpio_in(mst_irq, S0_IRQ),
- qdev_get_gpio_in(mst_irq, S0_CD_IRQ));
- pxa2xx_pcmcia_set_irq_cb(cpu->pcmcia[1],
- qdev_get_gpio_in(mst_irq, S1_IRQ),
- qdev_get_gpio_in(mst_irq, S1_CD_IRQ));
+ sysbus_connect_irq(sysbus_from_qdev(cpu->pcmcia[0]), 0,
+ qdev_get_gpio_in(mst_irq, S0_IRQ));
+ sysbus_connect_irq(sysbus_from_qdev(cpu->pcmcia[0]), 1,
+ qdev_get_gpio_in(mst_irq, S0_CD_IRQ));
+ sysbus_connect_irq(sysbus_from_qdev(cpu->pcmcia[1]), 0,
+ qdev_get_gpio_in(mst_irq, S1_IRQ));
+ sysbus_connect_irq(sysbus_from_qdev(cpu->pcmcia[1]), 1,
+ qdev_get_gpio_in(mst_irq, S1_CD_IRQ));
smc91c111_init(&nd_table[0], MST_ETH_PHYS,
qdev_get_gpio_in(mst_irq, ETHERNET_IRQ));
diff --git a/hw/pcmcia.h b/hw/pcmcia.h
index 50648c9..f0b16b8 100644
--- a/hw/pcmcia.h
+++ b/hw/pcmcia.h
@@ -47,5 +47,8 @@ struct PCMCIACardState {
#define CISTPL_END 0xff /* Tuple End */
#define CISTPL_ENDMARK 0xff
+/* pxa2xx_pcmcia.h -- used also for StrongARM */
+DeviceState *pxa2xx_pcmcia_init(target_phys_addr_t base, uint8_t id);
+
/* dscm1xxxx.c */
PCMCIACardState *dscm1xxxx_init(DriveInfo *bdrv);
diff --git a/hw/pxa.h b/hw/pxa.h
index d982f00..25176ef 100644
--- a/hw/pxa.h
+++ b/hw/pxa.h
@@ -90,11 +90,8 @@ void pxa2xx_mmci_handlers(PXA2xxMMCIState *s, qemu_irq readonly,
qemu_irq coverswitch);
/* pxa2xx_pcmcia.c */
-typedef struct PXA2xxPCMCIAState PXA2xxPCMCIAState;
-PXA2xxPCMCIAState *pxa2xx_pcmcia_init(target_phys_addr_t base);
int pxa2xx_pcmcia_attach(void *opaque, PCMCIACardState *card);
int pxa2xx_pcmcia_dettach(void *opaque);
-void pxa2xx_pcmcia_set_irq_cb(void *opaque, qemu_irq irq, qemu_irq cd_irq);
/* pxa2xx_keypad.c */
struct keymap {
@@ -126,7 +123,7 @@ typedef struct {
SSIBus **ssp;
PXA2xxI2CState *i2c[2];
PXA2xxMMCIState *mmc;
- PXA2xxPCMCIAState *pcmcia[2];
+ DeviceState *pcmcia[2];
PXA2xxI2SState *i2s;
PXA2xxFIrState *fir;
PXA2xxKeyPadState *kp;
diff --git a/hw/pxa2xx.c b/hw/pxa2xx.c
index ac5d95d..6ae8c8c 100644
--- a/hw/pxa2xx.c
+++ b/hw/pxa2xx.c
@@ -13,6 +13,7 @@
#include "pc.h"
#include "i2c.h"
#include "ssi.h"
+#include "pcmcia.h"
#include "qemu-char.h"
#include "blockdev.h"
@@ -2175,8 +2176,8 @@ PXA2xxState *pxa270_init(unsigned int sdram_size, const char *revision)
qdev_get_gpio_in(s->pic, PXA2XX_PIC_USBH1));
}
- s->pcmcia[0] = pxa2xx_pcmcia_init(0x20000000);
- s->pcmcia[1] = pxa2xx_pcmcia_init(0x30000000);
+ s->pcmcia[0] = pxa2xx_pcmcia_init(0x20000000, 0);
+ s->pcmcia[1] = pxa2xx_pcmcia_init(0x30000000, 1);
sysbus_create_simple("pxa2xx_rtc", 0x40900000,
qdev_get_gpio_in(s->pic, PXA2XX_PIC_RTCALARM));
@@ -2311,8 +2312,8 @@ PXA2xxState *pxa255_init(unsigned int sdram_size)
qdev_get_gpio_in(s->pic, PXA2XX_PIC_USBH1));
}
- s->pcmcia[0] = pxa2xx_pcmcia_init(0x20000000);
- s->pcmcia[1] = pxa2xx_pcmcia_init(0x30000000);
+ s->pcmcia[0] = pxa2xx_pcmcia_init(0x20000000, 0);
+ s->pcmcia[1] = pxa2xx_pcmcia_init(0x30000000, 1);
sysbus_create_simple("pxa2xx_rtc", 0x40900000,
qdev_get_gpio_in(s->pic, PXA2XX_PIC_RTCALARM));
diff --git a/hw/pxa2xx_pcmcia.c b/hw/pxa2xx_pcmcia.c
index 50d4649..3d93829 100644
--- a/hw/pxa2xx_pcmcia.c
+++ b/hw/pxa2xx_pcmcia.c
@@ -9,15 +9,19 @@
#include "hw.h"
#include "pcmcia.h"
+#include "sysbus.h"
#include "pxa.h"
-struct PXA2xxPCMCIAState {
+typedef struct PXA2xxPCMCIAState {
+ SysBusDevice busdev;
+
+ uint8_t id;
PCMCIASocket slot;
PCMCIACardState *card;
qemu_irq irq;
qemu_irq cd_irq;
-};
+} PXA2xxPCMCIAState;
static uint32_t pxa2xx_pcmcia_common_read(void *opaque,
target_phys_addr_t offset)
@@ -130,39 +134,61 @@ static void pxa2xx_pcmcia_set_irq(void *opaque, int line, int level)
qemu_set_irq(s->irq, level);
}
-PXA2xxPCMCIAState *pxa2xx_pcmcia_init(target_phys_addr_t base)
+DeviceState *pxa2xx_pcmcia_init(target_phys_addr_t base, uint8_t id)
{
- int iomemtype;
- PXA2xxPCMCIAState *s;
+ SysBusDevice *dev;
+
+ dev = sysbus_from_qdev(qdev_create(NULL, "pxa2xx-pcmcia"));
+ qdev_prop_set_uint8(&dev->qdev, "id", id);
+ qdev_init_nofail(&dev->qdev);
+
+ sysbus_mmio_map(dev, 0, base | 0x00000000);
+ sysbus_mmio_map(dev, 1, base | 0x08000000);
+ sysbus_mmio_map(dev, 2, base | 0x0c000000);
+ /* IRQs are mapped in the board code */
- s = (PXA2xxPCMCIAState *)
- qemu_mallocz(sizeof(PXA2xxPCMCIAState));
+ return &dev->qdev;
+}
+
+static int pxa2xx_pcmcia_initfn(SysBusDevice *dev)
+{
+ int iomemtype;
+ char *str;
+ PXA2xxPCMCIAState *s = FROM_SYSBUS(PXA2xxPCMCIAState, dev);
/* Socket I/O Memory Space */
iomemtype = cpu_register_io_memory(pxa2xx_pcmcia_io_readfn,
pxa2xx_pcmcia_io_writefn, s, DEVICE_NATIVE_ENDIAN);
- cpu_register_physical_memory(base | 0x00000000, 0x04000000, iomemtype);
+ sysbus_init_mmio(dev, 0x04000000, iomemtype);
/* Then next 64 MB is reserved */
/* Socket Attribute Memory Space */
iomemtype = cpu_register_io_memory(pxa2xx_pcmcia_attr_readfn,
pxa2xx_pcmcia_attr_writefn, s, DEVICE_NATIVE_ENDIAN);
- cpu_register_physical_memory(base | 0x08000000, 0x04000000, iomemtype);
+ sysbus_init_mmio(dev, 0x04000000, iomemtype);
/* Socket Common Memory Space */
iomemtype = cpu_register_io_memory(pxa2xx_pcmcia_common_readfn,
pxa2xx_pcmcia_common_writefn, s, DEVICE_NATIVE_ENDIAN);
- cpu_register_physical_memory(base | 0x0c000000, 0x04000000, iomemtype);
+ sysbus_init_mmio(dev, 0x04000000, iomemtype);
+
+ sysbus_init_irq(dev, &s->irq);
+ sysbus_init_irq(dev, &s->cd_irq);
+
+ if (!dev->qdev.id) {
+ str = qemu_mallocz(256);
+ snprintf(str, 256, "pxa2xx-pcmcia.%d", s->id);
+ dev->qdev.id = str;
+ }
+
+ str = qemu_mallocz(256);
+ snprintf(str, 256, "PXA PC Card Socket %d", s->id);
+ s->slot.slot_string = str;
- if (base == 0x30000000)
- s->slot.slot_string = "PXA PC Card Socket 1";
- else
- s->slot.slot_string = "PXA PC Card Socket 0";
s->slot.irq = qemu_allocate_irqs(pxa2xx_pcmcia_set_irq, s, 1)[0];
pcmcia_socket_register(&s->slot);
-
- return s;
+ return 0;
}
/* Insert a new card into a slot */
@@ -206,10 +232,19 @@ int pxa2xx_pcmcia_dettach(void *opaque)
return 0;
}
-/* Who to notify on card events */
-void pxa2xx_pcmcia_set_irq_cb(void *opaque, qemu_irq irq, qemu_irq cd_irq)
+static SysBusDeviceInfo pxa2xx_pcmcia_info = {
+ .init = pxa2xx_pcmcia_initfn,
+ .qdev.name = "pxa2xx-pcmcia",
+ .qdev.desc = "PXA2xx PCMCIA controller",
+ .qdev.size = sizeof(PXA2xxPCMCIAState),
+ .qdev.props = (Property[]) {
+ DEFINE_PROP_UINT8("id", struct PXA2xxPCMCIAState, id, 0),
+ DEFINE_PROP_END_OF_LIST(),
+ },
+};
+
+static void pxa2xx_pcmcia_register(void)
{
- PXA2xxPCMCIAState *s = (PXA2xxPCMCIAState *) opaque;
- s->irq = irq;
- s->cd_irq = cd_irq;
+ sysbus_register_withprop(&pxa2xx_pcmcia_info);
}
+device_init(pxa2xx_pcmcia_register);
diff --git a/hw/spitz.c b/hw/spitz.c
index 006f7a9..ce19b5a 100644
--- a/hw/spitz.c
+++ b/hw/spitz.c
@@ -870,14 +870,18 @@ static void spitz_gpio_setup(PXA2xxState *cpu, int slots)
qdev_connect_gpio_out(cpu->gpio, SPITZ_GPIO_ON_RESET, cpu->reset);
/* PCMCIA signals: card's IRQ and Card-Detect */
- if (slots >= 1)
- pxa2xx_pcmcia_set_irq_cb(cpu->pcmcia[0],
- qdev_get_gpio_in(cpu->gpio, SPITZ_GPIO_CF1_IRQ),
- qdev_get_gpio_in(cpu->gpio, SPITZ_GPIO_CF1_CD));
- if (slots >= 2)
- pxa2xx_pcmcia_set_irq_cb(cpu->pcmcia[1],
- qdev_get_gpio_in(cpu->gpio, SPITZ_GPIO_CF2_IRQ),
- qdev_get_gpio_in(cpu->gpio, SPITZ_GPIO_CF2_CD));
+ if (slots >= 1) {
+ sysbus_connect_irq(sysbus_from_qdev(cpu->pcmcia[0]), 0,
+ qdev_get_gpio_in(cpu->gpio, SPITZ_GPIO_CF1_IRQ));
+ sysbus_connect_irq(sysbus_from_qdev(cpu->pcmcia[0]), 1,
+ qdev_get_gpio_in(cpu->gpio, SPITZ_GPIO_CF1_CD));
+ }
+ if (slots >= 2) {
+ sysbus_connect_irq(sysbus_from_qdev(cpu->pcmcia[1]), 0,
+ qdev_get_gpio_in(cpu->gpio, SPITZ_GPIO_CF2_IRQ));
+ sysbus_connect_irq(sysbus_from_qdev(cpu->pcmcia[1]), 1,
+ qdev_get_gpio_in(cpu->gpio, SPITZ_GPIO_CF2_CD));
+ }
}
/* Board init. */
diff --git a/hw/tosa.c b/hw/tosa.c
index a7967a2..577b59f 100644
--- a/hw/tosa.c
+++ b/hw/tosa.c
@@ -101,13 +101,13 @@ static void tosa_gpio_setup(PXA2xxState *cpu,
qdev_connect_gpio_out(cpu->gpio, TOSA_GPIO_ON_RESET, cpu->reset);
/* PCMCIA signals: card's IRQ and Card-Detect */
- pxa2xx_pcmcia_set_irq_cb(cpu->pcmcia[0],
- qdev_get_gpio_in(cpu->gpio, TOSA_GPIO_CF_IRQ),
- qdev_get_gpio_in(cpu->gpio, TOSA_GPIO_CF_CD));
+ sysbus_connect_irq(sysbus_from_qdev(cpu->pcmcia[0]), 0,
+ qdev_get_gpio_in(cpu->gpio, TOSA_GPIO_CF_IRQ));
+ sysbus_connect_irq(sysbus_from_qdev(cpu->pcmcia[0]), 1,
+ qdev_get_gpio_in(cpu->gpio, TOSA_GPIO_CF_CD));
- pxa2xx_pcmcia_set_irq_cb(cpu->pcmcia[1],
- qdev_get_gpio_in(cpu->gpio, TOSA_GPIO_JC_CF_IRQ),
- NULL);
+ sysbus_connect_irq(sysbus_from_qdev(cpu->pcmcia[1]), 0,
+ qdev_get_gpio_in(cpu->gpio, TOSA_GPIO_JC_CF_IRQ));
qdev_connect_gpio_out(scp1, TOSA_GPIO_BT_LED, outsignals[0]);
qdev_connect_gpio_out(scp1, TOSA_GPIO_NOTE_LED, outsignals[1]);
--
1.7.4.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [RESEND][PATCH 2/9] PCMCIA: start qdev'ication
2011-04-25 9:06 [Qemu-devel] [RESEND][PATCH 1/9] pxa2xx_pcmcia: qdevify Dmitry Eremin-Solenikov
@ 2011-04-25 9:06 ` Dmitry Eremin-Solenikov
2011-05-16 1:52 ` andrzej zaborowski
2011-04-25 9:06 ` [Qemu-devel] [RESEND][PATCH 3/9] microdrive: qdevify Dmitry Eremin-Solenikov
` (7 subsequent siblings)
8 siblings, 1 reply; 21+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-04-25 9:06 UTC (permalink / raw)
To: qemu-devel
Convert PCMCIA bus handling code to use QBus internally.
MicroDrive code is still unaffected.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
Makefile.objs | 3 ++
hw/pcmcia.c | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++++
hw/pcmcia.h | 15 +++++++-
hw/pxa2xx_pcmcia.c | 2 +-
vl.c | 43 ----------------------
5 files changed, 120 insertions(+), 45 deletions(-)
create mode 100644 hw/pcmcia.c
diff --git a/Makefile.objs b/Makefile.objs
index 44ce368..153a148 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -289,6 +289,9 @@ hw-obj-$(CONFIG_REALLY_VIRTFS) += virtio-9p-debug.o
hw-obj-$(CONFIG_VIRTFS) += virtio-9p-local.o virtio-9p-xattr.o
hw-obj-$(CONFIG_VIRTFS) += virtio-9p-xattr-user.o virtio-9p-posix-acl.o
+# PCMCIA
+hw-obj-y += pcmcia.o
+
######################################################################
# libdis
# NOTE: the disassembler code is only needed for debugging
diff --git a/hw/pcmcia.c b/hw/pcmcia.c
new file mode 100644
index 0000000..17a49b6
--- /dev/null
+++ b/hw/pcmcia.c
@@ -0,0 +1,102 @@
+/*
+ * QEMU System Emulator
+ * PCMCIA subsystem
+ *
+ * Copyright (c) 2003-2008 Fabrice Bellard
+ * Copyright (c) 2011 Dmitry Eremin-Solenikov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+#include "hw.h"
+#include "pcmcia.h"
+#include "monitor.h"
+
+/***********************************************************/
+/* PCMCIA/Cardbus */
+
+static struct pcmcia_socket_entry_s {
+ PCMCIASocket *socket;
+ struct pcmcia_socket_entry_s *next;
+} *pcmcia_sockets = 0;
+
+static BusInfo pcmcia_bus_info = {
+ .name = "PCMCIA",
+ .size = sizeof(PCMCIASocket),
+};
+
+void pcmcia_socket_register(PCMCIASocket *socket, DeviceState *parent)
+{
+ struct pcmcia_socket_entry_s *entry;
+
+ qbus_create_inplace(&socket->qbus, &pcmcia_bus_info,
+ parent, "pcmcia");
+
+ entry = qemu_malloc(sizeof(struct pcmcia_socket_entry_s));
+ entry->socket = socket;
+ entry->next = pcmcia_sockets;
+ pcmcia_sockets = entry;
+}
+
+void pcmcia_socket_unregister(PCMCIASocket *socket)
+{
+ struct pcmcia_socket_entry_s *entry, **ptr;
+
+ ptr = &pcmcia_sockets;
+ for (entry = *ptr; entry; ptr = &entry->next, entry = *ptr)
+ if (entry->socket == socket) {
+ *ptr = entry->next;
+ qemu_free(entry);
+ }
+
+ qbus_free(&socket->qbus);
+}
+
+void pcmcia_info(Monitor *mon)
+{
+ struct pcmcia_socket_entry_s *iter;
+
+ if (!pcmcia_sockets) {
+ monitor_printf(mon, "No PCMCIA sockets\n");
+ }
+
+ for (iter = pcmcia_sockets; iter; iter = iter->next) {
+ monitor_printf(mon, "%s: %s\n", iter->socket->slot_string,
+ iter->socket->attached ? iter->socket->card_string :
+ "Empty");
+ }
+}
+
+static int pcmcia_device_init(DeviceState *dev, DeviceInfo *info)
+{
+ PCMCIACardState *state = DO_UPCAST(PCMCIACardState, dev, dev);
+ PCMCIACardInfo *pinfo = DO_UPCAST(PCMCIACardInfo, qdev, info);
+ int rc;
+
+ state->info = pinfo;
+ rc = pinfo->init(state);
+ return rc;
+}
+
+void pcmcia_card_register(PCMCIACardInfo *info)
+{
+ info->qdev.init = pcmcia_device_init;
+ info->qdev.bus_info = &pcmcia_bus_info;
+ assert(info->qdev.size >= sizeof(PCMCIACardState));
+ qdev_register(&info->qdev);
+}
diff --git a/hw/pcmcia.h b/hw/pcmcia.h
index f0b16b8..561d86c 100644
--- a/hw/pcmcia.h
+++ b/hw/pcmcia.h
@@ -1,19 +1,30 @@
/* PCMCIA/Cardbus */
#include "qemu-common.h"
+#include "qdev.h"
typedef struct {
+ BusState qbus;
qemu_irq irq;
int attached;
const char *slot_string;
const char *card_string;
} PCMCIASocket;
-void pcmcia_socket_register(PCMCIASocket *socket);
+void pcmcia_socket_register(PCMCIASocket *socket, DeviceState *parent);
void pcmcia_socket_unregister(PCMCIASocket *socket);
void pcmcia_info(Monitor *mon);
+typedef struct PCMCIACardInfo {
+ DeviceInfo qdev;
+
+ int (*init)(PCMCIACardState *state);
+} PCMCIACardInfo;
+
struct PCMCIACardState {
+ DeviceState dev;
+ PCMCIACardInfo *info;
+
void *state;
PCMCIASocket *slot;
int (*attach)(void *state);
@@ -30,6 +41,8 @@ struct PCMCIACardState {
void (*io_write)(void *state, uint32_t address, uint16_t value);
};
+void pcmcia_card_register(PCMCIACardInfo *info);
+
#define CISTPL_DEVICE 0x01 /* 5V Device Information Tuple */
#define CISTPL_NO_LINK 0x14 /* No Link Tuple */
#define CISTPL_VERS_1 0x15 /* Level 1 Version Tuple */
diff --git a/hw/pxa2xx_pcmcia.c b/hw/pxa2xx_pcmcia.c
index 3d93829..61afaf1 100644
--- a/hw/pxa2xx_pcmcia.c
+++ b/hw/pxa2xx_pcmcia.c
@@ -187,7 +187,7 @@ static int pxa2xx_pcmcia_initfn(SysBusDevice *dev)
s->slot.slot_string = str;
s->slot.irq = qemu_allocate_irqs(pxa2xx_pcmcia_set_irq, s, 1)[0];
- pcmcia_socket_register(&s->slot);
+ pcmcia_socket_register(&s->slot, &s->busdev.qdev);
return 0;
}
diff --git a/vl.c b/vl.c
index 68c3b53..2b277a6 100644
--- a/vl.c
+++ b/vl.c
@@ -980,49 +980,6 @@ void do_usb_del(Monitor *mon, const QDict *qdict)
}
/***********************************************************/
-/* PCMCIA/Cardbus */
-
-static struct pcmcia_socket_entry_s {
- PCMCIASocket *socket;
- struct pcmcia_socket_entry_s *next;
-} *pcmcia_sockets = 0;
-
-void pcmcia_socket_register(PCMCIASocket *socket)
-{
- struct pcmcia_socket_entry_s *entry;
-
- entry = qemu_malloc(sizeof(struct pcmcia_socket_entry_s));
- entry->socket = socket;
- entry->next = pcmcia_sockets;
- pcmcia_sockets = entry;
-}
-
-void pcmcia_socket_unregister(PCMCIASocket *socket)
-{
- struct pcmcia_socket_entry_s *entry, **ptr;
-
- ptr = &pcmcia_sockets;
- for (entry = *ptr; entry; ptr = &entry->next, entry = *ptr)
- if (entry->socket == socket) {
- *ptr = entry->next;
- qemu_free(entry);
- }
-}
-
-void pcmcia_info(Monitor *mon)
-{
- struct pcmcia_socket_entry_s *iter;
-
- if (!pcmcia_sockets)
- monitor_printf(mon, "No PCMCIA sockets\n");
-
- for (iter = pcmcia_sockets; iter; iter = iter->next)
- monitor_printf(mon, "%s: %s\n", iter->socket->slot_string,
- iter->socket->attached ? iter->socket->card_string :
- "Empty");
-}
-
-/***********************************************************/
/* machine registration */
static QEMUMachine *first_machine = NULL;
--
1.7.4.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [RESEND][PATCH 3/9] microdrive: qdevify
2011-04-25 9:06 [Qemu-devel] [RESEND][PATCH 1/9] pxa2xx_pcmcia: qdevify Dmitry Eremin-Solenikov
2011-04-25 9:06 ` [Qemu-devel] [RESEND][PATCH 2/9] PCMCIA: start qdev'ication Dmitry Eremin-Solenikov
@ 2011-04-25 9:06 ` Dmitry Eremin-Solenikov
2011-05-16 2:01 ` andrzej zaborowski
2011-04-25 9:06 ` [Qemu-devel] [RESEND][PATCH 4/9] pcmcia: move all card callbacks to PCMCIACardInfo Dmitry Eremin-Solenikov
` (6 subsequent siblings)
8 siblings, 1 reply; 21+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-04-25 9:06 UTC (permalink / raw)
To: qemu-devel
Switch dscm1xxxx microdrive driver to use qdev infrastructure.
---
hw/ide/microdrive.c | 49 +++++++++++++++++++++++++++++++++++++++----------
hw/pcmcia.h | 2 +-
hw/spitz.c | 5 ++++-
hw/tosa.c | 5 ++++-
4 files changed, 48 insertions(+), 13 deletions(-)
diff --git a/hw/ide/microdrive.c b/hw/ide/microdrive.c
index 9fbbf0e..7692603 100644
--- a/hw/ide/microdrive.c
+++ b/hw/ide/microdrive.c
@@ -38,8 +38,8 @@
/* DSCM-1XXXX Microdrive hard disk with CF+ II / PCMCIA interface. */
typedef struct {
- IDEBus bus;
PCMCIACardState card;
+ IDEBus bus;
uint32_t attr_base;
uint32_t io_base;
@@ -529,22 +529,51 @@ static int dscm1xxxx_detach(void *opaque)
return 0;
}
-PCMCIACardState *dscm1xxxx_init(DriveInfo *bdrv)
+PCMCIACardState *dscm1xxxx_init(PCMCIASocket *socket, DriveInfo *bdrv)
+{
+ DeviceState *dev;
+ MicroDriveState *md;
+
+ dev = qdev_create(&socket->qbus, "dscm1xxxx");
+ qdev_init_nofail(dev);
+ md = DO_UPCAST(MicroDriveState, card.dev, dev);
+
+ ide_create_drive(&md->bus, 0, bdrv);
+ md->bus.ifs[0].drive_kind = IDE_CFATA;
+ md->bus.ifs[0].mdata_size = METADATA_SIZE;
+ md->bus.ifs[0].mdata_storage = (uint8_t *) qemu_mallocz(METADATA_SIZE);
+
+ return &md->card;
+}
+
+static int dscm1xxxx_initfn(PCMCIACardState *state)
{
- MicroDriveState *md = (MicroDriveState *) qemu_mallocz(sizeof(MicroDriveState));
+ MicroDriveState *md;
+ md = DO_UPCAST(MicroDriveState, card, state);
+
md->card.state = md;
md->card.attach = dscm1xxxx_attach;
md->card.detach = dscm1xxxx_detach;
md->card.cis = dscm1xxxx_cis;
md->card.cis_len = sizeof(dscm1xxxx_cis);
- ide_init2_with_non_qdev_drives(&md->bus, bdrv, NULL,
- qemu_allocate_irqs(md_set_irq, md, 1)[0]);
- md->bus.ifs[0].drive_kind = IDE_CFATA;
- md->bus.ifs[0].mdata_size = METADATA_SIZE;
- md->bus.ifs[0].mdata_storage = (uint8_t *) qemu_mallocz(METADATA_SIZE);
+ ide_bus_new(&md->bus, &state->dev, 0);
+ qdev_init_gpio_in(&state->dev, md_set_irq, 1);
+ ide_init2(&md->bus, qdev_get_gpio_in(&state->dev, 0));
- vmstate_register(NULL, -1, &vmstate_microdrive, md);
+ return 0;
+}
- return &md->card;
+static PCMCIACardInfo dscm1xxxx_info = {
+ .qdev.name = "dscm1xxxx",
+ .qdev.desc = "QEMU CF MicroDrive emulation",
+ .init = dscm1xxxx_initfn,
+ .qdev.size = sizeof(MicroDriveState),
+ .qdev.vmsd = &vmstate_microdrive,
+};
+
+static void dscm1xxxx_register(void)
+{
+ pcmcia_card_register(&dscm1xxxx_info);
}
+device_init(dscm1xxxx_register);
diff --git a/hw/pcmcia.h b/hw/pcmcia.h
index 561d86c..c6b8100 100644
--- a/hw/pcmcia.h
+++ b/hw/pcmcia.h
@@ -64,4 +64,4 @@ void pcmcia_card_register(PCMCIACardInfo *info);
DeviceState *pxa2xx_pcmcia_init(target_phys_addr_t base, uint8_t id);
/* dscm1xxxx.c */
-PCMCIACardState *dscm1xxxx_init(DriveInfo *bdrv);
+PCMCIACardState *dscm1xxxx_init(PCMCIASocket *socket, DriveInfo *bdrv);
diff --git a/hw/spitz.c b/hw/spitz.c
index ce19b5a..51cc08c 100644
--- a/hw/spitz.c
+++ b/hw/spitz.c
@@ -714,7 +714,10 @@ static void spitz_microdrive_attach(PXA2xxState *cpu, int slot)
return;
bs = dinfo->bdrv;
if (bdrv_is_inserted(bs) && !bdrv_is_removable(bs)) {
- md = dscm1xxxx_init(dinfo);
+ md = dscm1xxxx_init(
+ DO_UPCAST(PCMCIASocket, qbus,
+ qdev_get_child_bus(cpu->pcmcia[slot], "pcmcia")),
+ dinfo);
pxa2xx_pcmcia_attach(cpu->pcmcia[slot], md);
}
}
diff --git a/hw/tosa.c b/hw/tosa.c
index 577b59f..f00555b 100644
--- a/hw/tosa.c
+++ b/hw/tosa.c
@@ -59,7 +59,10 @@ static void tosa_microdrive_attach(PXA2xxState *cpu)
return;
bs = dinfo->bdrv;
if (bdrv_is_inserted(bs) && !bdrv_is_removable(bs)) {
- md = dscm1xxxx_init(dinfo);
+ md = dscm1xxxx_init(
+ DO_UPCAST(PCMCIASocket, qbus,
+ qdev_get_child_bus(cpu->pcmcia[0], "pcmcia")),
+ dinfo);
pxa2xx_pcmcia_attach(cpu->pcmcia[0], md);
}
}
--
1.7.4.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [RESEND][PATCH 4/9] pcmcia: move all card callbacks to PCMCIACardInfo
2011-04-25 9:06 [Qemu-devel] [RESEND][PATCH 1/9] pxa2xx_pcmcia: qdevify Dmitry Eremin-Solenikov
2011-04-25 9:06 ` [Qemu-devel] [RESEND][PATCH 2/9] PCMCIA: start qdev'ication Dmitry Eremin-Solenikov
2011-04-25 9:06 ` [Qemu-devel] [RESEND][PATCH 3/9] microdrive: qdevify Dmitry Eremin-Solenikov
@ 2011-04-25 9:06 ` Dmitry Eremin-Solenikov
2011-04-25 9:06 ` [Qemu-devel] [RESEND][PATCH 5/9] pcmcia: move attach and detach socket methods to PCMCIASocket Dmitry Eremin-Solenikov
` (5 subsequent siblings)
8 siblings, 0 replies; 21+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-04-25 9:06 UTC (permalink / raw)
To: qemu-devel
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
last commit fixup
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Revert "microdrive fixup"
This reverts commit 6a9f969b0626e218ff910d84ed1c9eec285cbcd5.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
hw/ide/microdrive.c | 41 ++++++++++++++++++++---------------------
hw/pcmcia.h | 29 +++++++++++++++--------------
hw/pxa2xx_pcmcia.c | 16 ++++++++--------
3 files changed, 43 insertions(+), 43 deletions(-)
diff --git a/hw/ide/microdrive.c b/hw/ide/microdrive.c
index 7692603..c080943 100644
--- a/hw/ide/microdrive.c
+++ b/hw/ide/microdrive.c
@@ -112,9 +112,9 @@ static void md_reset(MicroDriveState *s)
ide_bus_reset(&s->bus);
}
-static uint8_t md_attr_read(void *opaque, uint32_t at)
+static uint8_t md_attr_read(PCMCIACardState *opaque, uint32_t at)
{
- MicroDriveState *s = opaque;
+ MicroDriveState *s = DO_UPCAST(MicroDriveState, card, opaque);
if (at < s->attr_base) {
if (at < s->card.cis_len)
return s->card.cis[at];
@@ -145,9 +145,9 @@ static uint8_t md_attr_read(void *opaque, uint32_t at)
return 0;
}
-static void md_attr_write(void *opaque, uint32_t at, uint8_t value)
+static void md_attr_write(PCMCIACardState *opaque, uint32_t at, uint8_t value)
{
- MicroDriveState *s = opaque;
+ MicroDriveState *s = DO_UPCAST(MicroDriveState, card, opaque);
at -= s->attr_base;
switch (at) {
@@ -176,9 +176,9 @@ static void md_attr_write(void *opaque, uint32_t at, uint8_t value)
}
}
-static uint16_t md_common_read(void *opaque, uint32_t at)
+static uint16_t md_common_read(PCMCIACardState *opaque, uint32_t at)
{
- MicroDriveState *s = opaque;
+ MicroDriveState *s = DO_UPCAST(MicroDriveState, card, opaque);
IDEState *ifs;
uint16_t ret;
at -= s->io_base;
@@ -238,9 +238,9 @@ static uint16_t md_common_read(void *opaque, uint32_t at)
return 0;
}
-static void md_common_write(void *opaque, uint32_t at, uint16_t value)
+static void md_common_write(PCMCIACardState *opaque, uint32_t at, uint16_t value)
{
- MicroDriveState *s = opaque;
+ MicroDriveState *s = DO_UPCAST(MicroDriveState, card, opaque);
at -= s->io_base;
switch (s->opt & OPT_MODE) {
@@ -502,15 +502,9 @@ static const uint8_t dscm1xxxx_cis[0x14a] = {
[0x146] = CISTPL_END, /* Tuple End */
};
-static int dscm1xxxx_attach(void *opaque)
+static int dscm1xxxx_attach(PCMCIACardState *opaque)
{
- MicroDriveState *md = opaque;
- md->card.attr_read = md_attr_read;
- md->card.attr_write = md_attr_write;
- md->card.common_read = md_common_read;
- md->card.common_write = md_common_write;
- md->card.io_read = md_common_read;
- md->card.io_write = md_common_write;
+ MicroDriveState *md = DO_UPCAST(MicroDriveState, card, opaque);
md->attr_base = md->card.cis[0x74] | (md->card.cis[0x76] << 8);
md->io_base = 0x0;
@@ -522,9 +516,9 @@ static int dscm1xxxx_attach(void *opaque)
return 0;
}
-static int dscm1xxxx_detach(void *opaque)
+static int dscm1xxxx_detach(PCMCIACardState *opaque)
{
- MicroDriveState *md = opaque;
+ MicroDriveState *md = DO_UPCAST(MicroDriveState, card, opaque);
md_reset(md);
return 0;
}
@@ -551,9 +545,6 @@ static int dscm1xxxx_initfn(PCMCIACardState *state)
MicroDriveState *md;
md = DO_UPCAST(MicroDriveState, card, state);
- md->card.state = md;
- md->card.attach = dscm1xxxx_attach;
- md->card.detach = dscm1xxxx_detach;
md->card.cis = dscm1xxxx_cis;
md->card.cis_len = sizeof(dscm1xxxx_cis);
@@ -570,6 +561,14 @@ static PCMCIACardInfo dscm1xxxx_info = {
.init = dscm1xxxx_initfn,
.qdev.size = sizeof(MicroDriveState),
.qdev.vmsd = &vmstate_microdrive,
+ .attach = dscm1xxxx_attach,
+ .detach = dscm1xxxx_detach,
+ .attr_read = md_attr_read,
+ .attr_write = md_attr_write,
+ .common_read = md_common_read,
+ .common_write = md_common_write,
+ .io_read = md_common_read,
+ .io_write = md_common_write,
};
static void dscm1xxxx_register(void)
diff --git a/hw/pcmcia.h b/hw/pcmcia.h
index c6b8100..2c012d9 100644
--- a/hw/pcmcia.h
+++ b/hw/pcmcia.h
@@ -3,13 +3,15 @@
#include "qemu-common.h"
#include "qdev.h"
-typedef struct {
+typedef struct PCMCIASocket PCMCIASocket;
+
+struct PCMCIASocket {
BusState qbus;
qemu_irq irq;
int attached;
const char *slot_string;
const char *card_string;
-} PCMCIASocket;
+};
void pcmcia_socket_register(PCMCIASocket *socket, DeviceState *parent);
void pcmcia_socket_unregister(PCMCIASocket *socket);
@@ -19,26 +21,25 @@ typedef struct PCMCIACardInfo {
DeviceInfo qdev;
int (*init)(PCMCIACardState *state);
+
+ int (*attach)(PCMCIACardState *state);
+ int (*detach)(PCMCIACardState *state);
+
+ /* Only valid if attached */
+ uint8_t (*attr_read)(PCMCIACardState *state, uint32_t address);
+ void (*attr_write)(PCMCIACardState *state, uint32_t address, uint8_t value);
+ uint16_t (*common_read)(PCMCIACardState *state, uint32_t address);
+ void (*common_write)(PCMCIACardState *state, uint32_t address, uint16_t value);
+ uint16_t (*io_read)(PCMCIACardState *state, uint32_t address);
+ void (*io_write)(PCMCIACardState *state, uint32_t address, uint16_t value);
} PCMCIACardInfo;
struct PCMCIACardState {
DeviceState dev;
PCMCIACardInfo *info;
-
- void *state;
PCMCIASocket *slot;
- int (*attach)(void *state);
- int (*detach)(void *state);
const uint8_t *cis;
int cis_len;
-
- /* Only valid if attached */
- uint8_t (*attr_read)(void *state, uint32_t address);
- void (*attr_write)(void *state, uint32_t address, uint8_t value);
- uint16_t (*common_read)(void *state, uint32_t address);
- void (*common_write)(void *state, uint32_t address, uint16_t value);
- uint16_t (*io_read)(void *state, uint32_t address);
- void (*io_write)(void *state, uint32_t address, uint16_t value);
};
void pcmcia_card_register(PCMCIACardInfo *info);
diff --git a/hw/pxa2xx_pcmcia.c b/hw/pxa2xx_pcmcia.c
index 61afaf1..ae7d01a 100644
--- a/hw/pxa2xx_pcmcia.c
+++ b/hw/pxa2xx_pcmcia.c
@@ -29,7 +29,7 @@ static uint32_t pxa2xx_pcmcia_common_read(void *opaque,
PXA2xxPCMCIAState *s = (PXA2xxPCMCIAState *) opaque;
if (s->slot.attached) {
- return s->card->common_read(s->card->state, offset);
+ return s->card->info->common_read(s->card, offset);
}
return 0;
@@ -41,7 +41,7 @@ static void pxa2xx_pcmcia_common_write(void *opaque,
PXA2xxPCMCIAState *s = (PXA2xxPCMCIAState *) opaque;
if (s->slot.attached) {
- s->card->common_write(s->card->state, offset, value);
+ s->card->info->common_write(s->card, offset, value);
}
}
@@ -51,7 +51,7 @@ static uint32_t pxa2xx_pcmcia_attr_read(void *opaque,
PXA2xxPCMCIAState *s = (PXA2xxPCMCIAState *) opaque;
if (s->slot.attached) {
- return s->card->attr_read(s->card->state, offset);
+ return s->card->info->attr_read(s->card, offset);
}
return 0;
@@ -63,7 +63,7 @@ static void pxa2xx_pcmcia_attr_write(void *opaque,
PXA2xxPCMCIAState *s = (PXA2xxPCMCIAState *) opaque;
if (s->slot.attached) {
- s->card->attr_write(s->card->state, offset, value);
+ s->card->info->attr_write(s->card, offset, value);
}
}
@@ -73,7 +73,7 @@ static uint32_t pxa2xx_pcmcia_io_read(void *opaque,
PXA2xxPCMCIAState *s = (PXA2xxPCMCIAState *) opaque;
if (s->slot.attached) {
- return s->card->io_read(s->card->state, offset);
+ return s->card->info->io_read(s->card, offset);
}
return 0;
@@ -85,7 +85,7 @@ static void pxa2xx_pcmcia_io_write(void *opaque,
PXA2xxPCMCIAState *s = (PXA2xxPCMCIAState *) opaque;
if (s->slot.attached) {
- s->card->io_write(s->card->state, offset, value);
+ s->card->info->io_write(s->card, offset, value);
}
}
@@ -206,7 +206,7 @@ int pxa2xx_pcmcia_attach(void *opaque, PCMCIACardState *card)
s->slot.attached = 1;
s->card->slot = &s->slot;
- s->card->attach(s->card->state);
+ s->card->info->attach(s->card);
return 0;
}
@@ -218,7 +218,7 @@ int pxa2xx_pcmcia_dettach(void *opaque)
if (!s->slot.attached)
return -ENOENT;
- s->card->detach(s->card->state);
+ s->card->info->detach(s->card);
s->card->slot = NULL;
s->card = NULL;
--
1.7.4.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [RESEND][PATCH 5/9] pcmcia: move attach and detach socket methods to PCMCIASocket
2011-04-25 9:06 [Qemu-devel] [RESEND][PATCH 1/9] pxa2xx_pcmcia: qdevify Dmitry Eremin-Solenikov
` (2 preceding siblings ...)
2011-04-25 9:06 ` [Qemu-devel] [RESEND][PATCH 4/9] pcmcia: move all card callbacks to PCMCIACardInfo Dmitry Eremin-Solenikov
@ 2011-04-25 9:06 ` Dmitry Eremin-Solenikov
2011-04-25 9:06 ` [Qemu-devel] [RESEND][PATCH 6/9] pxa: change order of pcmcia devices instantiation, so that the socket 0 will be default Dmitry Eremin-Solenikov
` (4 subsequent siblings)
8 siblings, 0 replies; 21+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-04-25 9:06 UTC (permalink / raw)
To: qemu-devel
Make attach and detach calls to be automatically called by PCMCIA card
instantiation code, rather than calling them by hand from the board
code.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
hw/pcmcia.c | 45 +++++++++++++++++++++++++++++++-
hw/pcmcia.h | 2 +
hw/pxa.h | 4 ---
hw/pxa2xx_pcmcia.c | 73 +++++++++++++++++++++++----------------------------
hw/spitz.c | 1 -
hw/tosa.c | 1 -
6 files changed, 79 insertions(+), 47 deletions(-)
diff --git a/hw/pcmcia.c b/hw/pcmcia.c
index 17a49b6..d661663 100644
--- a/hw/pcmcia.c
+++ b/hw/pcmcia.c
@@ -86,16 +86,59 @@ static int pcmcia_device_init(DeviceState *dev, DeviceInfo *info)
{
PCMCIACardState *state = DO_UPCAST(PCMCIACardState, dev, dev);
PCMCIACardInfo *pinfo = DO_UPCAST(PCMCIACardInfo, qdev, info);
+ PCMCIASocket *socket = DO_UPCAST(PCMCIASocket, qbus, dev->parent_bus);
int rc;
+ if (socket->attached) {
+ return -1;
+ }
+
state->info = pinfo;
rc = pinfo->init(state);
- return rc;
+ if (rc) {
+ return rc;
+ }
+
+ socket->attached = 1;
+ state->slot = socket;
+
+ rc = socket->attach(socket, state);
+ if (rc) {
+ return rc;
+ }
+
+ rc = state->info->attach(state);
+ if (rc) {
+ socket->detach(socket);
+ return rc;
+ }
+
+ return 0;
+}
+
+static int pcmcia_device_exit(DeviceState *dev)
+{
+ PCMCIACardState *state = DO_UPCAST(PCMCIACardState, dev, dev);
+ PCMCIASocket *socket = DO_UPCAST(PCMCIASocket, qbus, dev->parent_bus);
+
+ if (!socket->attached) {
+ return -ENOENT;
+ }
+
+ state->info->detach(state);
+ state->slot = NULL;
+
+ socket->detach(socket);
+
+ socket->attached = 0;
+
+ return 0;
}
void pcmcia_card_register(PCMCIACardInfo *info)
{
info->qdev.init = pcmcia_device_init;
+ info->qdev.exit = pcmcia_device_exit;
info->qdev.bus_info = &pcmcia_bus_info;
assert(info->qdev.size >= sizeof(PCMCIACardState));
qdev_register(&info->qdev);
diff --git a/hw/pcmcia.h b/hw/pcmcia.h
index 2c012d9..4f90af7 100644
--- a/hw/pcmcia.h
+++ b/hw/pcmcia.h
@@ -11,6 +11,8 @@ struct PCMCIASocket {
int attached;
const char *slot_string;
const char *card_string;
+ int (*attach)(PCMCIASocket *socket, PCMCIACardState *card);
+ int (*detach)(PCMCIASocket *socket);
};
void pcmcia_socket_register(PCMCIASocket *socket, DeviceState *parent);
diff --git a/hw/pxa.h b/hw/pxa.h
index 25176ef..c145029 100644
--- a/hw/pxa.h
+++ b/hw/pxa.h
@@ -89,10 +89,6 @@ PXA2xxMMCIState *pxa2xx_mmci_init(target_phys_addr_t base,
void pxa2xx_mmci_handlers(PXA2xxMMCIState *s, qemu_irq readonly,
qemu_irq coverswitch);
-/* pxa2xx_pcmcia.c */
-int pxa2xx_pcmcia_attach(void *opaque, PCMCIACardState *card);
-int pxa2xx_pcmcia_dettach(void *opaque);
-
/* pxa2xx_keypad.c */
struct keymap {
int column;
diff --git a/hw/pxa2xx_pcmcia.c b/hw/pxa2xx_pcmcia.c
index ae7d01a..efd4c09 100644
--- a/hw/pxa2xx_pcmcia.c
+++ b/hw/pxa2xx_pcmcia.c
@@ -150,6 +150,37 @@ DeviceState *pxa2xx_pcmcia_init(target_phys_addr_t base, uint8_t id)
return &dev->qdev;
}
+/* Insert a new card into a slot */
+static int pxa2xx_pcmcia_attach(PCMCIASocket *socket, PCMCIACardState *card)
+{
+ PXA2xxPCMCIAState *s = container_of(socket, PXA2xxPCMCIAState, slot);
+
+ if (s->cd_irq) {
+ qemu_irq_raise(s->cd_irq);
+ }
+
+ s->card = card;
+
+ return 0;
+}
+
+/* Eject card from the slot */
+static int pxa2xx_pcmcia_detach(PCMCIASocket *socket)
+{
+ PXA2xxPCMCIAState *s = container_of(socket, PXA2xxPCMCIAState, slot);
+
+ s->card = NULL;
+
+ if (s->irq) {
+ qemu_irq_lower(s->irq);
+ }
+ if (s->cd_irq) {
+ qemu_irq_lower(s->cd_irq);
+ }
+
+ return 0;
+}
+
static int pxa2xx_pcmcia_initfn(SysBusDevice *dev)
{
int iomemtype;
@@ -186,48 +217,10 @@ static int pxa2xx_pcmcia_initfn(SysBusDevice *dev)
snprintf(str, 256, "PXA PC Card Socket %d", s->id);
s->slot.slot_string = str;
+ s->slot.attach = pxa2xx_pcmcia_attach;
+ s->slot.detach = pxa2xx_pcmcia_detach;
s->slot.irq = qemu_allocate_irqs(pxa2xx_pcmcia_set_irq, s, 1)[0];
pcmcia_socket_register(&s->slot, &s->busdev.qdev);
- return 0;
-}
-
-/* Insert a new card into a slot */
-int pxa2xx_pcmcia_attach(void *opaque, PCMCIACardState *card)
-{
- PXA2xxPCMCIAState *s = (PXA2xxPCMCIAState *) opaque;
- if (s->slot.attached)
- return -EEXIST;
-
- if (s->cd_irq) {
- qemu_irq_raise(s->cd_irq);
- }
-
- s->card = card;
-
- s->slot.attached = 1;
- s->card->slot = &s->slot;
- s->card->info->attach(s->card);
-
- return 0;
-}
-
-/* Eject card from the slot */
-int pxa2xx_pcmcia_dettach(void *opaque)
-{
- PXA2xxPCMCIAState *s = (PXA2xxPCMCIAState *) opaque;
- if (!s->slot.attached)
- return -ENOENT;
-
- s->card->info->detach(s->card);
- s->card->slot = NULL;
- s->card = NULL;
-
- s->slot.attached = 0;
-
- if (s->irq)
- qemu_irq_lower(s->irq);
- if (s->cd_irq)
- qemu_irq_lower(s->cd_irq);
return 0;
}
diff --git a/hw/spitz.c b/hw/spitz.c
index 51cc08c..cf2ee82 100644
--- a/hw/spitz.c
+++ b/hw/spitz.c
@@ -718,7 +718,6 @@ static void spitz_microdrive_attach(PXA2xxState *cpu, int slot)
DO_UPCAST(PCMCIASocket, qbus,
qdev_get_child_bus(cpu->pcmcia[slot], "pcmcia")),
dinfo);
- pxa2xx_pcmcia_attach(cpu->pcmcia[slot], md);
}
}
diff --git a/hw/tosa.c b/hw/tosa.c
index f00555b..e867dc4 100644
--- a/hw/tosa.c
+++ b/hw/tosa.c
@@ -63,7 +63,6 @@ static void tosa_microdrive_attach(PXA2xxState *cpu)
DO_UPCAST(PCMCIASocket, qbus,
qdev_get_child_bus(cpu->pcmcia[0], "pcmcia")),
dinfo);
- pxa2xx_pcmcia_attach(cpu->pcmcia[0], md);
}
}
--
1.7.4.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [RESEND][PATCH 6/9] pxa: change order of pcmcia devices instantiation, so that the socket 0 will be default
2011-04-25 9:06 [Qemu-devel] [RESEND][PATCH 1/9] pxa2xx_pcmcia: qdevify Dmitry Eremin-Solenikov
` (3 preceding siblings ...)
2011-04-25 9:06 ` [Qemu-devel] [RESEND][PATCH 5/9] pcmcia: move attach and detach socket methods to PCMCIASocket Dmitry Eremin-Solenikov
@ 2011-04-25 9:06 ` Dmitry Eremin-Solenikov
2011-04-25 9:06 ` [Qemu-devel] [RESEND][PATCH 7/9] ide-core: allocate metadata storage for CFATA drives Dmitry Eremin-Solenikov
` (3 subsequent siblings)
8 siblings, 0 replies; 21+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-04-25 9:06 UTC (permalink / raw)
To: qemu-devel
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
hw/pxa2xx.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/hw/pxa2xx.c b/hw/pxa2xx.c
index 6ae8c8c..dc44864 100644
--- a/hw/pxa2xx.c
+++ b/hw/pxa2xx.c
@@ -2176,8 +2176,8 @@ PXA2xxState *pxa270_init(unsigned int sdram_size, const char *revision)
qdev_get_gpio_in(s->pic, PXA2XX_PIC_USBH1));
}
- s->pcmcia[0] = pxa2xx_pcmcia_init(0x20000000, 0);
s->pcmcia[1] = pxa2xx_pcmcia_init(0x30000000, 1);
+ s->pcmcia[0] = pxa2xx_pcmcia_init(0x20000000, 0);
sysbus_create_simple("pxa2xx_rtc", 0x40900000,
qdev_get_gpio_in(s->pic, PXA2XX_PIC_RTCALARM));
@@ -2312,8 +2312,8 @@ PXA2xxState *pxa255_init(unsigned int sdram_size)
qdev_get_gpio_in(s->pic, PXA2XX_PIC_USBH1));
}
- s->pcmcia[0] = pxa2xx_pcmcia_init(0x20000000, 0);
s->pcmcia[1] = pxa2xx_pcmcia_init(0x30000000, 1);
+ s->pcmcia[0] = pxa2xx_pcmcia_init(0x20000000, 0);
sysbus_create_simple("pxa2xx_rtc", 0x40900000,
qdev_get_gpio_in(s->pic, PXA2XX_PIC_RTCALARM));
--
1.7.4.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [RESEND][PATCH 7/9] ide-core: allocate metadata storage for CFATA drives
2011-04-25 9:06 [Qemu-devel] [RESEND][PATCH 1/9] pxa2xx_pcmcia: qdevify Dmitry Eremin-Solenikov
` (4 preceding siblings ...)
2011-04-25 9:06 ` [Qemu-devel] [RESEND][PATCH 6/9] pxa: change order of pcmcia devices instantiation, so that the socket 0 will be default Dmitry Eremin-Solenikov
@ 2011-04-25 9:06 ` Dmitry Eremin-Solenikov
2011-04-25 9:06 ` [Qemu-devel] [RESEND][PATCH 8/9] strongarm: add PCMCIA support Dmitry Eremin-Solenikov
` (2 subsequent siblings)
8 siblings, 0 replies; 21+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-04-25 9:06 UTC (permalink / raw)
To: qemu-devel
Currently it's done by hw/ide/microdrive.c To simplify that part,
move this initialization to ide core.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
hw/ide/core.c | 4 ++++
hw/ide/internal.h | 2 ++
hw/ide/microdrive.c | 6 +-----
3 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/hw/ide/core.c b/hw/ide/core.c
index f028ddb..16e6f67 100644
--- a/hw/ide/core.c
+++ b/hw/ide/core.c
@@ -2682,6 +2682,10 @@ int ide_init_drive(IDEState *s, BlockDriverState *bs,
return -1;
}
}
+ if (s->drive_kind == IDE_CFATA) {
+ s->mdata_size = CFA_METADATA_SIZE;
+ s->mdata_storage = qemu_mallocz(CFA_METADATA_SIZE);
+ }
if (serial) {
strncpy(s->drive_serial_str, serial, sizeof(s->drive_serial_str));
} else {
diff --git a/hw/ide/internal.h b/hw/ide/internal.h
index ba7e9a8..769de90 100644
--- a/hw/ide/internal.h
+++ b/hw/ide/internal.h
@@ -364,6 +364,8 @@ typedef struct IDEDMAOps IDEDMAOps;
#define SMART_DISABLE 0xd9
#define SMART_STATUS 0xda
+#define CFA_METADATA_SIZE 0x20
+
typedef enum { IDE_HD, IDE_CD, IDE_CFATA } IDEDriveKind;
typedef void EndTransferFunc(IDEState *);
diff --git a/hw/ide/microdrive.c b/hw/ide/microdrive.c
index c080943..13459a0 100644
--- a/hw/ide/microdrive.c
+++ b/hw/ide/microdrive.c
@@ -34,8 +34,6 @@
/***********************************************************/
/* CF-ATA Microdrive */
-#define METADATA_SIZE 0x20
-
/* DSCM-1XXXX Microdrive hard disk with CF+ II / PCMCIA interface. */
typedef struct {
PCMCIACardState card;
@@ -533,9 +531,6 @@ PCMCIACardState *dscm1xxxx_init(PCMCIASocket *socket, DriveInfo *bdrv)
md = DO_UPCAST(MicroDriveState, card.dev, dev);
ide_create_drive(&md->bus, 0, bdrv);
- md->bus.ifs[0].drive_kind = IDE_CFATA;
- md->bus.ifs[0].mdata_size = METADATA_SIZE;
- md->bus.ifs[0].mdata_storage = (uint8_t *) qemu_mallocz(METADATA_SIZE);
return &md->card;
}
@@ -552,6 +547,7 @@ static int dscm1xxxx_initfn(PCMCIACardState *state)
qdev_init_gpio_in(&state->dev, md_set_irq, 1);
ide_init2(&md->bus, qdev_get_gpio_in(&state->dev, 0));
+ md->bus.ifs[0].drive_kind = IDE_CFATA;
return 0;
}
--
1.7.4.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [RESEND][PATCH 8/9] strongarm: add PCMCIA support
2011-04-25 9:06 [Qemu-devel] [RESEND][PATCH 1/9] pxa2xx_pcmcia: qdevify Dmitry Eremin-Solenikov
` (5 preceding siblings ...)
2011-04-25 9:06 ` [Qemu-devel] [RESEND][PATCH 7/9] ide-core: allocate metadata storage for CFATA drives Dmitry Eremin-Solenikov
@ 2011-04-25 9:06 ` Dmitry Eremin-Solenikov
2011-04-25 9:06 ` [Qemu-devel] [RESEND][PATCH 9/9] collie: add support for PCMCIA bus Dmitry Eremin-Solenikov
2011-04-29 19:40 ` [Qemu-devel] [RESEND][PATCH 1/9] pxa2xx_pcmcia: qdevify Dmitry Eremin-Solenikov
8 siblings, 0 replies; 21+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-04-25 9:06 UTC (permalink / raw)
To: qemu-devel
Add PCMCIA support to StrongARM SoCs reusing PXA devices.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
hw/strongarm.c | 5 ++++-
hw/strongarm.h | 1 +
2 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/hw/strongarm.c b/hw/strongarm.c
index de08bdf..dbc253c 100644
--- a/hw/strongarm.c
+++ b/hw/strongarm.c
@@ -29,6 +29,7 @@
#include "arm-misc.h"
#include "sysemu.h"
#include "ssi.h"
+#include "pcmcia.h"
//#define DEBUG
@@ -40,7 +41,6 @@
- Implement sleep mode/Wake sources
- Implement reset control
- Implement memory control regs
- - PCMCIA handling
- Maybe support MBGNT/MBREQ
- DMA channels
- GPCLK
@@ -1583,6 +1583,9 @@ StrongARMState *sa1110_init(unsigned int sdram_size, const char *rev)
qdev_get_gpio_in(s->pic, SA_PIC_SSP), NULL);
s->ssp_bus = (SSIBus *)qdev_get_child_bus(s->ssp, "ssi");
+ s->pcmcia[1] = pxa2xx_pcmcia_init(0x30000000, 1);
+ s->pcmcia[0] = pxa2xx_pcmcia_init(0x20000000, 0);
+
return s;
}
diff --git a/hw/strongarm.h b/hw/strongarm.h
index a81b110..d1ce538 100644
--- a/hw/strongarm.h
+++ b/hw/strongarm.h
@@ -57,6 +57,7 @@ typedef struct {
DeviceState *ppc;
DeviceState *ssp;
SSIBus *ssp_bus;
+ DeviceState *pcmcia[2];
} StrongARMState;
StrongARMState *sa1110_init(unsigned int sdram_size, const char *rev);
--
1.7.4.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [RESEND][PATCH 9/9] collie: add support for PCMCIA bus
2011-04-25 9:06 [Qemu-devel] [RESEND][PATCH 1/9] pxa2xx_pcmcia: qdevify Dmitry Eremin-Solenikov
` (6 preceding siblings ...)
2011-04-25 9:06 ` [Qemu-devel] [RESEND][PATCH 8/9] strongarm: add PCMCIA support Dmitry Eremin-Solenikov
@ 2011-04-25 9:06 ` Dmitry Eremin-Solenikov
2011-04-29 19:40 ` [Qemu-devel] [RESEND][PATCH 1/9] pxa2xx_pcmcia: qdevify Dmitry Eremin-Solenikov
8 siblings, 0 replies; 21+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-04-25 9:06 UTC (permalink / raw)
To: qemu-devel
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
hw/collie.c | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/hw/collie.c b/hw/collie.c
index 156404d..89d37f7 100644
--- a/hw/collie.c
+++ b/hw/collie.c
@@ -14,6 +14,9 @@
#include "flash.h"
#include "blockdev.h"
+#define COLLIE_GPIO_CF_IRQ (14)
+#define COLLIE_GPIO_CF_CD (22)
+
static struct arm_boot_info collie_binfo = {
.loader_start = SA_SDCS0,
.ram_size = 0x20000000,
@@ -47,6 +50,10 @@ static void collie_init(ram_addr_t ram_size,
512, 4, 0x00, 0x00, 0x00, 0x00, 0);
sysbus_create_simple("scoop", 0x40800000, NULL);
+ sysbus_connect_irq(sysbus_from_qdev(s->pcmcia[0]), 0,
+ qdev_get_gpio_in(s->gpio, COLLIE_GPIO_CF_IRQ));
+ sysbus_connect_irq(sysbus_from_qdev(s->pcmcia[0]), 1,
+ qdev_get_gpio_in(s->gpio, COLLIE_GPIO_CF_CD));
collie_binfo.kernel_filename = kernel_filename;
collie_binfo.kernel_cmdline = kernel_cmdline;
--
1.7.4.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [Qemu-devel] [RESEND][PATCH 1/9] pxa2xx_pcmcia: qdevify
2011-04-25 9:06 [Qemu-devel] [RESEND][PATCH 1/9] pxa2xx_pcmcia: qdevify Dmitry Eremin-Solenikov
` (7 preceding siblings ...)
2011-04-25 9:06 ` [Qemu-devel] [RESEND][PATCH 9/9] collie: add support for PCMCIA bus Dmitry Eremin-Solenikov
@ 2011-04-29 19:40 ` Dmitry Eremin-Solenikov
2011-05-03 9:02 ` Dmitry Eremin-Solenikov
8 siblings, 1 reply; 21+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-04-29 19:40 UTC (permalink / raw)
To: qemu-devel
Hello,
Any chance to get any response for this patches serie?
On 4/25/11, Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> wrote:
> Use qdev insfrastructure for managing PXA PCMCIA devices. PCMCIA bus
> itself isn't converted to QBus (yet). pxa2xx_pcmcia_init() function is
> moved to pcmcia.h as it will be used by other cores/devices (like
> StrongARM).
>
> Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [Qemu-devel] [RESEND][PATCH 1/9] pxa2xx_pcmcia: qdevify
2011-04-29 19:40 ` [Qemu-devel] [RESEND][PATCH 1/9] pxa2xx_pcmcia: qdevify Dmitry Eremin-Solenikov
@ 2011-05-03 9:02 ` Dmitry Eremin-Solenikov
0 siblings, 0 replies; 21+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-05-03 9:02 UTC (permalink / raw)
To: qemu-devel
Hello, colleagues,
On 4/29/11, Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> wrote:
> Hello,
>
> Any chance to get any response for this patches serie?
Still no response at all. Is there anything wrong with my approach? Is there
any problem with patch format? Am I just being ignored?
> On 4/25/11, Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> wrote:
>> Use qdev insfrastructure for managing PXA PCMCIA devices. PCMCIA bus
>> itself isn't converted to QBus (yet). pxa2xx_pcmcia_init() function is
>> moved to pcmcia.h as it will be used by other cores/devices (like
>> StrongARM).
>>
>> Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
>
> --
> With best wishes
> Dmitry
>
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [Qemu-devel] [RESEND][PATCH 2/9] PCMCIA: start qdev'ication
2011-04-25 9:06 ` [Qemu-devel] [RESEND][PATCH 2/9] PCMCIA: start qdev'ication Dmitry Eremin-Solenikov
@ 2011-05-16 1:52 ` andrzej zaborowski
2011-05-16 5:10 ` Dmitry Eremin-Solenikov
0 siblings, 1 reply; 21+ messages in thread
From: andrzej zaborowski @ 2011-05-16 1:52 UTC (permalink / raw)
To: Dmitry Eremin-Solenikov; +Cc: qemu-devel
Hi Dmitry,
On 25 April 2011 11:06, Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> wrote:
> Convert PCMCIA bus handling code to use QBus internally.
> MicroDrive code is still unaffected.
>
> Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
> ---
> Makefile.objs | 3 ++
> hw/pcmcia.c | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++++
> hw/pcmcia.h | 15 +++++++-
> hw/pxa2xx_pcmcia.c | 2 +-
> vl.c | 43 ----------------------
> 5 files changed, 120 insertions(+), 45 deletions(-)
> create mode 100644 hw/pcmcia.c
>
> diff --git a/Makefile.objs b/Makefile.objs
> index 44ce368..153a148 100644
> --- a/Makefile.objs
> +++ b/Makefile.objs
> @@ -289,6 +289,9 @@ hw-obj-$(CONFIG_REALLY_VIRTFS) += virtio-9p-debug.o
> hw-obj-$(CONFIG_VIRTFS) += virtio-9p-local.o virtio-9p-xattr.o
> hw-obj-$(CONFIG_VIRTFS) += virtio-9p-xattr-user.o virtio-9p-posix-acl.o
>
> +# PCMCIA
> +hw-obj-y += pcmcia.o
> +
> ######################################################################
> # libdis
> # NOTE: the disassembler code is only needed for debugging
> diff --git a/hw/pcmcia.c b/hw/pcmcia.c
> new file mode 100644
> index 0000000..17a49b6
> --- /dev/null
> +++ b/hw/pcmcia.c
> @@ -0,0 +1,102 @@
> +/*
> + * QEMU System Emulator
> + * PCMCIA subsystem
> + *
> + * Copyright (c) 2003-2008 Fabrice Bellard
> + * Copyright (c) 2011 Dmitry Eremin-Solenikov
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a copy
> + * of this software and associated documentation files (the "Software"), to deal
> + * in the Software without restriction, including without limitation the rights
> + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> + * copies of the Software, and to permit persons to whom the Software is
> + * furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice shall be included in
> + * all copies or substantial portions of the Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
> + * THE SOFTWARE.
> + */
> +#include "hw.h"
> +#include "pcmcia.h"
> +#include "monitor.h"
> +
> +/***********************************************************/
> +/* PCMCIA/Cardbus */
> +
> +static struct pcmcia_socket_entry_s {
> + PCMCIASocket *socket;
> + struct pcmcia_socket_entry_s *next;
> +} *pcmcia_sockets = 0;
> +
> +static BusInfo pcmcia_bus_info = {
> + .name = "PCMCIA",
> + .size = sizeof(PCMCIASocket),
> +};
> +
> +void pcmcia_socket_register(PCMCIASocket *socket, DeviceState *parent)
> +{
> + struct pcmcia_socket_entry_s *entry;
> +
> + qbus_create_inplace(&socket->qbus, &pcmcia_bus_info,
> + parent, "pcmcia");
> +
> + entry = qemu_malloc(sizeof(struct pcmcia_socket_entry_s));
> + entry->socket = socket;
> + entry->next = pcmcia_sockets;
> + pcmcia_sockets = entry;
> +}
> +
> +void pcmcia_socket_unregister(PCMCIASocket *socket)
> +{
> + struct pcmcia_socket_entry_s *entry, **ptr;
> +
> + ptr = &pcmcia_sockets;
> + for (entry = *ptr; entry; ptr = &entry->next, entry = *ptr)
> + if (entry->socket == socket) {
> + *ptr = entry->next;
> + qemu_free(entry);
> + }
I think you need a "break" here, or something else. Otherwise you'll
be accessing entry->next incorrectly. (I notice that this error is
present in the current code too)
It would also be great if someone with understanding of qbus could ack
the rest of this patch.
Out of curiosity, In the patch 1/9 can you include pxa.h instead of
moving the declaration out of pxa.h?
I also want to remind you that (iirc) the tosa code was merged in a
rather incomplete state, like the collie, kind of on the condition
that it would be worked on for stuff like audio/video soon after ;)
Cheers
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [Qemu-devel] [RESEND][PATCH 3/9] microdrive: qdevify
2011-04-25 9:06 ` [Qemu-devel] [RESEND][PATCH 3/9] microdrive: qdevify Dmitry Eremin-Solenikov
@ 2011-05-16 2:01 ` andrzej zaborowski
2011-05-16 4:54 ` Dmitry Eremin-Solenikov
0 siblings, 1 reply; 21+ messages in thread
From: andrzej zaborowski @ 2011-05-16 2:01 UTC (permalink / raw)
To: Dmitry Eremin-Solenikov; +Cc: qemu-devel
On 25 April 2011 11:06, Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> wrote:
> Switch dscm1xxxx microdrive driver to use qdev infrastructure.
> ---
> hw/ide/microdrive.c | 49 +++++++++++++++++++++++++++++++++++++++----------
> hw/pcmcia.h | 2 +-
> hw/spitz.c | 5 ++++-
> hw/tosa.c | 5 ++++-
> 4 files changed, 48 insertions(+), 13 deletions(-)
>
> diff --git a/hw/ide/microdrive.c b/hw/ide/microdrive.c
> index 9fbbf0e..7692603 100644
> --- a/hw/ide/microdrive.c
> +++ b/hw/ide/microdrive.c
> @@ -38,8 +38,8 @@
>
> /* DSCM-1XXXX Microdrive hard disk with CF+ II / PCMCIA interface. */
> typedef struct {
> - IDEBus bus;
> PCMCIACardState card;
> + IDEBus bus;
> uint32_t attr_base;
> uint32_t io_base;
>
> @@ -529,22 +529,51 @@ static int dscm1xxxx_detach(void *opaque)
> return 0;
> }
>
> -PCMCIACardState *dscm1xxxx_init(DriveInfo *bdrv)
> +PCMCIACardState *dscm1xxxx_init(PCMCIASocket *socket, DriveInfo *bdrv)
This looks like a regression that you have to pass the socket when
creating a PCMCIA card. I consider it an advantage of the current
code that pcmcia cards are hotswappable. Can we keep that with
qdevification? Otherwise is there a gain from the qdevification?
Cheers
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [Qemu-devel] [RESEND][PATCH 3/9] microdrive: qdevify
2011-05-16 2:01 ` andrzej zaborowski
@ 2011-05-16 4:54 ` Dmitry Eremin-Solenikov
2011-05-16 12:26 ` andrzej zaborowski
0 siblings, 1 reply; 21+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-05-16 4:54 UTC (permalink / raw)
To: andrzej zaborowski; +Cc: qemu-devel
Hello,
On 5/16/11, andrzej zaborowski <balrogg@gmail.com> wrote:
> On 25 April 2011 11:06, Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
> wrote:
>> Switch dscm1xxxx microdrive driver to use qdev infrastructure.
>> ---
>> hw/ide/microdrive.c | 49
>> +++++++++++++++++++++++++++++++++++++++----------
>> hw/pcmcia.h | 2 +-
>> hw/spitz.c | 5 ++++-
>> hw/tosa.c | 5 ++++-
>> 4 files changed, 48 insertions(+), 13 deletions(-)
>>
>> diff --git a/hw/ide/microdrive.c b/hw/ide/microdrive.c
>> index 9fbbf0e..7692603 100644
>> --- a/hw/ide/microdrive.c
>> +++ b/hw/ide/microdrive.c
>> @@ -38,8 +38,8 @@
>>
>> /* DSCM-1XXXX Microdrive hard disk with CF+ II / PCMCIA interface. */
>> typedef struct {
>> - IDEBus bus;
>> PCMCIACardState card;
>> + IDEBus bus;
>> uint32_t attr_base;
>> uint32_t io_base;
>>
>> @@ -529,22 +529,51 @@ static int dscm1xxxx_detach(void *opaque)
>> return 0;
>> }
>>
>> -PCMCIACardState *dscm1xxxx_init(DriveInfo *bdrv)
>> +PCMCIACardState *dscm1xxxx_init(PCMCIASocket *socket, DriveInfo *bdrv)
>
> This looks like a regression that you have to pass the socket when
> creating a PCMCIA card. I consider it an advantage of the current
> code that pcmcia cards are hotswappable. Can we keep that with
> qdevification? Otherwise is there a gain from the qdevification?
Socket is required, as we have to know the QBus before creating the
device on it.
Reg. hotswap: my intent was to move reuse hotplug/hotswap from QDev layer.
However I could not find a way to trigger device creation/removal at run time,
so I was unable to even try to test this code path. How should I do that?
Cards won´t be hotswitchable (you won´t be able to detach a card from one socket
and then put it back to the other one, however PCMCIA code should be hotplugable
(i.e. you should be able to unplug a card from socket and then plug another one
in).
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [Qemu-devel] [RESEND][PATCH 2/9] PCMCIA: start qdev'ication
2011-05-16 1:52 ` andrzej zaborowski
@ 2011-05-16 5:10 ` Dmitry Eremin-Solenikov
0 siblings, 0 replies; 21+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-05-16 5:10 UTC (permalink / raw)
To: andrzej zaborowski; +Cc: qemu-devel
On 5/16/11, andrzej zaborowski <balrogg@gmail.com> wrote:
> Hi Dmitry,
>
> On 25 April 2011 11:06, Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
> wrote:
>> Convert PCMCIA bus handling code to use QBus internally.
>> MicroDrive code is still unaffected.
>>
>> Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
>> ---
>> Makefile.objs | 3 ++
>> hw/pcmcia.c | 102
>> ++++++++++++++++++++++++++++++++++++++++++++++++++++
>> hw/pcmcia.h | 15 +++++++-
>> hw/pxa2xx_pcmcia.c | 2 +-
>> vl.c | 43 ----------------------
>> 5 files changed, 120 insertions(+), 45 deletions(-)
>> create mode 100644 hw/pcmcia.c
>>
>> diff --git a/Makefile.objs b/Makefile.objs
>> index 44ce368..153a148 100644
>> --- a/Makefile.objs
>> +++ b/Makefile.objs
>> @@ -289,6 +289,9 @@ hw-obj-$(CONFIG_REALLY_VIRTFS) += virtio-9p-debug.o
>> hw-obj-$(CONFIG_VIRTFS) += virtio-9p-local.o virtio-9p-xattr.o
>> hw-obj-$(CONFIG_VIRTFS) += virtio-9p-xattr-user.o virtio-9p-posix-acl.o
>>
>> +# PCMCIA
>> +hw-obj-y += pcmcia.o
>> +
>> ######################################################################
>> # libdis
>> # NOTE: the disassembler code is only needed for debugging
>> diff --git a/hw/pcmcia.c b/hw/pcmcia.c
>> new file mode 100644
>> index 0000000..17a49b6
>> --- /dev/null
>> +++ b/hw/pcmcia.c
>> @@ -0,0 +1,102 @@
>> +/*
>> + * QEMU System Emulator
>> + * PCMCIA subsystem
>> + *
>> + * Copyright (c) 2003-2008 Fabrice Bellard
>> + * Copyright (c) 2011 Dmitry Eremin-Solenikov
>> + *
>> + * Permission is hereby granted, free of charge, to any person obtaining
>> a copy
>> + * of this software and associated documentation files (the "Software"),
>> to deal
>> + * in the Software without restriction, including without limitation the
>> rights
>> + * to use, copy, modify, merge, publish, distribute, sublicense, and/or
>> sell
>> + * copies of the Software, and to permit persons to whom the Software is
>> + * furnished to do so, subject to the following conditions:
>> + *
>> + * The above copyright notice and this permission notice shall be
>> included in
>> + * all copies or substantial portions of the Software.
>> + *
>> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
>> EXPRESS OR
>> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
>> MERCHANTABILITY,
>> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
>> SHALL
>> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
>> OTHER
>> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
>> ARISING FROM,
>> + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
>> IN
>> + * THE SOFTWARE.
>> + */
>> +#include "hw.h"
>> +#include "pcmcia.h"
>> +#include "monitor.h"
>> +
>> +/***********************************************************/
>> +/* PCMCIA/Cardbus */
>> +
>> +static struct pcmcia_socket_entry_s {
>> + PCMCIASocket *socket;
>> + struct pcmcia_socket_entry_s *next;
>> +} *pcmcia_sockets = 0;
>> +
>> +static BusInfo pcmcia_bus_info = {
>> + .name = "PCMCIA",
>> + .size = sizeof(PCMCIASocket),
>> +};
>> +
>> +void pcmcia_socket_register(PCMCIASocket *socket, DeviceState *parent)
>> +{
>> + struct pcmcia_socket_entry_s *entry;
>> +
>> + qbus_create_inplace(&socket->qbus, &pcmcia_bus_info,
>> + parent, "pcmcia");
>> +
>> + entry = qemu_malloc(sizeof(struct pcmcia_socket_entry_s));
>> + entry->socket = socket;
>> + entry->next = pcmcia_sockets;
>> + pcmcia_sockets = entry;
>> +}
>> +
>> +void pcmcia_socket_unregister(PCMCIASocket *socket)
>> +{
>> + struct pcmcia_socket_entry_s *entry, **ptr;
>> +
>> + ptr = &pcmcia_sockets;
>> + for (entry = *ptr; entry; ptr = &entry->next, entry = *ptr)
>> + if (entry->socket == socket) {
>> + *ptr = entry->next;
>> + qemu_free(entry);
>> + }
>
> I think you need a "break" here, or something else. Otherwise you'll
> be accessing entry->next incorrectly. (I notice that this error is
> present in the current code too)
OK, will fix it.
> It would also be great if someone with understanding of qbus could ack
> the rest of this patch.
/me is thinking about restructurisation of PCMCIA patchset, so anyway...
> Out of curiosity, In the patch 1/9 can you include pxa.h instead of
> moving the declaration out of pxa.h?
Yes and no. Yes, because it´s possible. No, because I´d like not to pollute
the StrongARM namespace. Anyway, I´m thinking about just copying this
pxa_pcmcia_init to strongarm.c to be able to customize socket naming.
> I also want to remind you that (iirc) the tosa code was merged in a
> rather incomplete state, like the collie, kind of on the condition
> that it would be worked on for stuff like audio/video soon after ;)
AC97 stuff is in progress. Current status (with the huge pile of other patches)
can be found in my repo on repo.or.cz. Would you like a cleaner branch
or whatever
for review? Current blocking points are the design of audio stream vs.
slots mapping
and PXA dma functions.
I haven´t yet looked on the MCP (for collie), will probably add LCD
and some other
stuff (like StrongARM-specific wait-for-interrupt) first.
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [Qemu-devel] [RESEND][PATCH 3/9] microdrive: qdevify
2011-05-16 4:54 ` Dmitry Eremin-Solenikov
@ 2011-05-16 12:26 ` andrzej zaborowski
2011-05-16 13:08 ` Dmitry Eremin-Solenikov
0 siblings, 1 reply; 21+ messages in thread
From: andrzej zaborowski @ 2011-05-16 12:26 UTC (permalink / raw)
To: Dmitry Eremin-Solenikov; +Cc: qemu-devel
On 16 May 2011 06:54, Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> wrote:
> Hello,
>
> On 5/16/11, andrzej zaborowski <balrogg@gmail.com> wrote:
>> On 25 April 2011 11:06, Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
>> wrote:
>>> Switch dscm1xxxx microdrive driver to use qdev infrastructure.
>>> ---
>>> hw/ide/microdrive.c | 49
>>> +++++++++++++++++++++++++++++++++++++++----------
>>> hw/pcmcia.h | 2 +-
>>> hw/spitz.c | 5 ++++-
>>> hw/tosa.c | 5 ++++-
>>> 4 files changed, 48 insertions(+), 13 deletions(-)
>>>
>>> diff --git a/hw/ide/microdrive.c b/hw/ide/microdrive.c
>>> index 9fbbf0e..7692603 100644
>>> --- a/hw/ide/microdrive.c
>>> +++ b/hw/ide/microdrive.c
>>> @@ -38,8 +38,8 @@
>>>
>>> /* DSCM-1XXXX Microdrive hard disk with CF+ II / PCMCIA interface. */
>>> typedef struct {
>>> - IDEBus bus;
>>> PCMCIACardState card;
>>> + IDEBus bus;
>>> uint32_t attr_base;
>>> uint32_t io_base;
>>>
>>> @@ -529,22 +529,51 @@ static int dscm1xxxx_detach(void *opaque)
>>> return 0;
>>> }
>>>
>>> -PCMCIACardState *dscm1xxxx_init(DriveInfo *bdrv)
>>> +PCMCIACardState *dscm1xxxx_init(PCMCIASocket *socket, DriveInfo *bdrv)
>>
>> This looks like a regression that you have to pass the socket when
>> creating a PCMCIA card. I consider it an advantage of the current
>> code that pcmcia cards are hotswappable. Can we keep that with
>> qdevification? Otherwise is there a gain from the qdevification?
>
> Socket is required, as we have to know the QBus before creating the
> device on it.
Let's skip the qbusification then. It seems that qbus is a wrong
choice for pcmcia and there are no new features or bugs fixed by the
conversion, it's code motion? I also don't see why the socket
structure should be needed at the creation time of a PCI device for
example, the BusInfo should be enough logically.
Cheers
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [Qemu-devel] [RESEND][PATCH 3/9] microdrive: qdevify
2011-05-16 12:26 ` andrzej zaborowski
@ 2011-05-16 13:08 ` Dmitry Eremin-Solenikov
2011-05-17 1:38 ` andrzej zaborowski
0 siblings, 1 reply; 21+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-05-16 13:08 UTC (permalink / raw)
To: andrzej zaborowski; +Cc: qemu-devel
On 5/16/11, andrzej zaborowski <balrogg@gmail.com> wrote:
> On 16 May 2011 06:54, Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> wrote:
>> Hello,
>>
>> On 5/16/11, andrzej zaborowski <balrogg@gmail.com> wrote:
>>> On 25 April 2011 11:06, Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
>>> wrote:
>>>> Switch dscm1xxxx microdrive driver to use qdev infrastructure.
>>>> ---
>>>> hw/ide/microdrive.c | 49
>>>> +++++++++++++++++++++++++++++++++++++++----------
>>>> hw/pcmcia.h | 2 +-
>>>> hw/spitz.c | 5 ++++-
>>>> hw/tosa.c | 5 ++++-
>>>> 4 files changed, 48 insertions(+), 13 deletions(-)
>>>>
>>>> diff --git a/hw/ide/microdrive.c b/hw/ide/microdrive.c
>>>> index 9fbbf0e..7692603 100644
>>>> --- a/hw/ide/microdrive.c
>>>> +++ b/hw/ide/microdrive.c
>>>> @@ -38,8 +38,8 @@
>>>>
>>>> /* DSCM-1XXXX Microdrive hard disk with CF+ II / PCMCIA interface. */
>>>> typedef struct {
>>>> - IDEBus bus;
>>>> PCMCIACardState card;
>>>> + IDEBus bus;
>>>> uint32_t attr_base;
>>>> uint32_t io_base;
>>>>
>>>> @@ -529,22 +529,51 @@ static int dscm1xxxx_detach(void *opaque)
>>>> return 0;
>>>> }
>>>>
>>>> -PCMCIACardState *dscm1xxxx_init(DriveInfo *bdrv)
>>>> +PCMCIACardState *dscm1xxxx_init(PCMCIASocket *socket, DriveInfo *bdrv)
>>>
>>> This looks like a regression that you have to pass the socket when
>>> creating a PCMCIA card. I consider it an advantage of the current
>>> code that pcmcia cards are hotswappable. Can we keep that with
>>> qdevification? Otherwise is there a gain from the qdevification?
>>
>> Socket is required, as we have to know the QBus before creating the
>> device on it.
>
> Let's skip the qbusification then. It seems that qbus is a wrong
> choice for pcmcia and there are no new features or bugs fixed by the
> conversion, it's code motion? I also don't see why the socket
> structure should be needed at the creation time of a PCI device for
> example, the BusInfo should be enough logically.
Major point for qbus'ification was ability to create PCMCIA devices from
command line/via other management tools. This would also allow us e.g.
to move microdrive driver to common ide parts, etc.
For creation of a DeviceState via qdev_create you need BusState (which
is a part of PCMCIASocket). Of course I can make one global QBus for
all PCMCIA devices and make some artificial hacks to attach/detach cards
to artificial sockets, but this seems like a hack.
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [Qemu-devel] [RESEND][PATCH 3/9] microdrive: qdevify
2011-05-16 13:08 ` Dmitry Eremin-Solenikov
@ 2011-05-17 1:38 ` andrzej zaborowski
2011-05-17 5:44 ` Jan Kiszka
0 siblings, 1 reply; 21+ messages in thread
From: andrzej zaborowski @ 2011-05-17 1:38 UTC (permalink / raw)
To: Dmitry Eremin-Solenikov; +Cc: qemu-devel
On 16 May 2011 15:08, Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> wrote:
> On 5/16/11, andrzej zaborowski <balrogg@gmail.com> wrote:
>> On 16 May 2011 06:54, Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> wrote:
>>> Socket is required, as we have to know the QBus before creating the
>>> device on it.
>>
>> Let's skip the qbusification then. It seems that qbus is a wrong
>> choice for pcmcia and there are no new features or bugs fixed by the
>> conversion, it's code motion? I also don't see why the socket
>> structure should be needed at the creation time of a PCI device for
>> example, the BusInfo should be enough logically.
>
> Major point for qbus'ification was ability to create PCMCIA devices from
> command line/via other management tools. This would also allow us e.g.
> to move microdrive driver to common ide parts, etc.
That would be nice but it may be better to use separate command line
switches / monitor commands for hotpluggable busses.
>
> For creation of a DeviceState via qdev_create you need BusState (which
> is a part of PCMCIASocket). Of course I can make one global QBus for
> all PCMCIA devices and make some artificial hacks to attach/detach cards
> to artificial sockets, but this seems like a hack.
I considered that for a moment too but it's uglier than current code
and doesn't achieve what you want, because the command line has no
provision for triggering attachment. A major problem with qdev I see
now is that the creation and attachment of a device are one event
instead of two, which is the case for pcmcia. So your patch tries to
merge these two events.
Cheers
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [Qemu-devel] [RESEND][PATCH 3/9] microdrive: qdevify
2011-05-17 1:38 ` andrzej zaborowski
@ 2011-05-17 5:44 ` Jan Kiszka
2011-05-17 11:08 ` andrzej zaborowski
0 siblings, 1 reply; 21+ messages in thread
From: Jan Kiszka @ 2011-05-17 5:44 UTC (permalink / raw)
To: andrzej zaborowski; +Cc: Dmitry Eremin-Solenikov, qemu-devel
[-- Attachment #1: Type: text/plain, Size: 2383 bytes --]
On 2011-05-17 03:38, andrzej zaborowski wrote:
> On 16 May 2011 15:08, Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> wrote:
>> On 5/16/11, andrzej zaborowski <balrogg@gmail.com> wrote:
>>> On 16 May 2011 06:54, Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> wrote:
>>>> Socket is required, as we have to know the QBus before creating the
>>>> device on it.
>>>
>>> Let's skip the qbusification then. It seems that qbus is a wrong
>>> choice for pcmcia and there are no new features or bugs fixed by the
>>> conversion, it's code motion? I also don't see why the socket
>>> structure should be needed at the creation time of a PCI device for
>>> example, the BusInfo should be enough logically.
>>
>> Major point for qbus'ification was ability to create PCMCIA devices from
>> command line/via other management tools. This would also allow us e.g.
>> to move microdrive driver to common ide parts, etc.
>
> That would be nice but it may be better to use separate command line
> switches / monitor commands for hotpluggable busses.
>
>>
>> For creation of a DeviceState via qdev_create you need BusState (which
>> is a part of PCMCIASocket). Of course I can make one global QBus for
>> all PCMCIA devices and make some artificial hacks to attach/detach cards
>> to artificial sockets, but this seems like a hack.
>
> I considered that for a moment too but it's uglier than current code
> and doesn't achieve what you want, because the command line has no
> provision for triggering attachment. A major problem with qdev I see
> now is that the creation and attachment of a device are one event
> instead of two, which is the case for pcmcia. So your patch tries to
> merge these two events.
What is the point of allowing the existence of unattached pcmcia
devices? I think there was similar discussion about usb to allow attach
detach without delete, but IIRC that was finally rejected as there is no
real benefit in avoiding full creation/destruction.
Keep in mind that there may be a day where we finally obsolete support
for non-qdev (or whatever it's name will be then) devices. Every device
needs to be discoverable for QEMU in a generic way, e.g. to decide if
there are devices attached that do not support save/restore or to
explore its state. Rejecting a qdev conversion looks a bit strange from
that perspective.
Jan
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 259 bytes --]
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [Qemu-devel] [RESEND][PATCH 3/9] microdrive: qdevify
2011-05-17 5:44 ` Jan Kiszka
@ 2011-05-17 11:08 ` andrzej zaborowski
2011-05-17 11:33 ` Jan Kiszka
0 siblings, 1 reply; 21+ messages in thread
From: andrzej zaborowski @ 2011-05-17 11:08 UTC (permalink / raw)
To: Jan Kiszka; +Cc: Dmitry Eremin-Solenikov, qemu-devel
On 17 May 2011 07:44, Jan Kiszka <jan.kiszka@web.de> wrote:
> On 2011-05-17 03:38, andrzej zaborowski wrote:
>> On 16 May 2011 15:08, Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> wrote:
>>> On 5/16/11, andrzej zaborowski <balrogg@gmail.com> wrote:
>>>> On 16 May 2011 06:54, Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> wrote:
>>>>> Socket is required, as we have to know the QBus before creating the
>>>>> device on it.
>>>>
>>>> Let's skip the qbusification then. It seems that qbus is a wrong
>>>> choice for pcmcia and there are no new features or bugs fixed by the
>>>> conversion, it's code motion? I also don't see why the socket
>>>> structure should be needed at the creation time of a PCI device for
>>>> example, the BusInfo should be enough logically.
>>>
>>> Major point for qbus'ification was ability to create PCMCIA devices from
>>> command line/via other management tools. This would also allow us e.g.
>>> to move microdrive driver to common ide parts, etc.
>>
>> That would be nice but it may be better to use separate command line
>> switches / monitor commands for hotpluggable busses.
>>
>>>
>>> For creation of a DeviceState via qdev_create you need BusState (which
>>> is a part of PCMCIASocket). Of course I can make one global QBus for
>>> all PCMCIA devices and make some artificial hacks to attach/detach cards
>>> to artificial sockets, but this seems like a hack.
>>
>> I considered that for a moment too but it's uglier than current code
>> and doesn't achieve what you want, because the command line has no
>> provision for triggering attachment. A major problem with qdev I see
>> now is that the creation and attachment of a device are one event
>> instead of two, which is the case for pcmcia. So your patch tries to
>> merge these two events.
>
> What is the point of allowing the existence of unattached pcmcia
> devices? I think there was similar discussion about usb to allow attach
> detach without delete, but IIRC that was finally rejected as there is no
> real benefit in avoiding full creation/destruction.
It's more about being able to detach and re-attach (in the same socket
or another), migrate, savevm/loadvm separately from the machine
although this possibility is not used now anyway. I just think it's
logical for a hotpluggable bus that this be possible and it's wrong to
require the socket structure when creating a device, although I'll
ack/push the patches if that's a general opinion.
>
> Keep in mind that there may be a day where we finally obsolete support
> for non-qdev (or whatever it's name will be then) devices.
Not allowing non-qdev devices would be difficult to do because a
"device" is just a set of memory mappings and it's a fuzzy term
altogether (in SoCs especially). What I'd like to avoid is shuffling
a piece of code into an api it does not fit just because there's a
trend to use it, you can burn cycles endlessly reordering code with no
new features/bugs fixed.
Cheers
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [Qemu-devel] [RESEND][PATCH 3/9] microdrive: qdevify
2011-05-17 11:08 ` andrzej zaborowski
@ 2011-05-17 11:33 ` Jan Kiszka
0 siblings, 0 replies; 21+ messages in thread
From: Jan Kiszka @ 2011-05-17 11:33 UTC (permalink / raw)
To: andrzej zaborowski; +Cc: Dmitry Eremin-Solenikov, qemu-devel
On 2011-05-17 13:08, andrzej zaborowski wrote:
> On 17 May 2011 07:44, Jan Kiszka <jan.kiszka@web.de> wrote:
>> On 2011-05-17 03:38, andrzej zaborowski wrote:
>>> On 16 May 2011 15:08, Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> wrote:
>>>> On 5/16/11, andrzej zaborowski <balrogg@gmail.com> wrote:
>>>>> On 16 May 2011 06:54, Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> wrote:
>>>>>> Socket is required, as we have to know the QBus before creating the
>>>>>> device on it.
>>>>>
>>>>> Let's skip the qbusification then. It seems that qbus is a wrong
>>>>> choice for pcmcia and there are no new features or bugs fixed by the
>>>>> conversion, it's code motion? I also don't see why the socket
>>>>> structure should be needed at the creation time of a PCI device for
>>>>> example, the BusInfo should be enough logically.
>>>>
>>>> Major point for qbus'ification was ability to create PCMCIA devices from
>>>> command line/via other management tools. This would also allow us e.g.
>>>> to move microdrive driver to common ide parts, etc.
>>>
>>> That would be nice but it may be better to use separate command line
>>> switches / monitor commands for hotpluggable busses.
>>>
>>>>
>>>> For creation of a DeviceState via qdev_create you need BusState (which
>>>> is a part of PCMCIASocket). Of course I can make one global QBus for
>>>> all PCMCIA devices and make some artificial hacks to attach/detach cards
>>>> to artificial sockets, but this seems like a hack.
>>>
>>> I considered that for a moment too but it's uglier than current code
>>> and doesn't achieve what you want, because the command line has no
>>> provision for triggering attachment. A major problem with qdev I see
>>> now is that the creation and attachment of a device are one event
>>> instead of two, which is the case for pcmcia. So your patch tries to
>>> merge these two events.
>>
>> What is the point of allowing the existence of unattached pcmcia
>> devices? I think there was similar discussion about usb to allow attach
>> detach without delete, but IIRC that was finally rejected as there is no
>> real benefit in avoiding full creation/destruction.
>
> It's more about being able to detach and re-attach (in the same socket
> or another)
I haven't looked at the details of this particular issue, but from 10000
meters I do not yet understand how qdev prevents this. Do we lack
addressability via qdev for these sockets? Then that would have to be fixed.
>, migrate, savevm/loadvm separately from the machine
> although this possibility is not used now anyway. I just think it's
> logical for a hotpluggable bus that this be possible and it's wrong to
> require the socket structure when creating a device, although I'll
> ack/push the patches if that's a general opinion.
>
>>
>> Keep in mind that there may be a day where we finally obsolete support
>> for non-qdev (or whatever it's name will be then) devices.
>
> Not allowing non-qdev devices would be difficult to do because a
> "device" is just a set of memory mappings and it's a fuzzy term
> altogether (in SoCs especially).
Even in the SoC domain, I did not come across any set of "memory
mappings" that could not reasonably be abstractable to a device, thus
could be wrapped by qdev. That there is usually no chip containing such
a device in reality does not mean you can't and shouldn't handle it as
an abstract one, encapsulating separate functions in a more complex chip.
> What I'd like to avoid is shuffling
> a piece of code into an api it does not fit just because there's a
> trend to use it, you can burn cycles endlessly reordering code with no
> new features/bugs fixed.
No longer having arbitrary, untraceable memory and io mappings but only
well organized devices is a feature worth such shuffling. Usually that
also offers the chance to clean up legacy code or complete half-done
device models.
We are good in inventing new APIs in QEMU, but so far we are not that
successful getting rid of old ones.
Jan
--
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
^ permalink raw reply [flat|nested] 21+ messages in thread
end of thread, other threads:[~2011-05-17 11:33 UTC | newest]
Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-25 9:06 [Qemu-devel] [RESEND][PATCH 1/9] pxa2xx_pcmcia: qdevify Dmitry Eremin-Solenikov
2011-04-25 9:06 ` [Qemu-devel] [RESEND][PATCH 2/9] PCMCIA: start qdev'ication Dmitry Eremin-Solenikov
2011-05-16 1:52 ` andrzej zaborowski
2011-05-16 5:10 ` Dmitry Eremin-Solenikov
2011-04-25 9:06 ` [Qemu-devel] [RESEND][PATCH 3/9] microdrive: qdevify Dmitry Eremin-Solenikov
2011-05-16 2:01 ` andrzej zaborowski
2011-05-16 4:54 ` Dmitry Eremin-Solenikov
2011-05-16 12:26 ` andrzej zaborowski
2011-05-16 13:08 ` Dmitry Eremin-Solenikov
2011-05-17 1:38 ` andrzej zaborowski
2011-05-17 5:44 ` Jan Kiszka
2011-05-17 11:08 ` andrzej zaborowski
2011-05-17 11:33 ` Jan Kiszka
2011-04-25 9:06 ` [Qemu-devel] [RESEND][PATCH 4/9] pcmcia: move all card callbacks to PCMCIACardInfo Dmitry Eremin-Solenikov
2011-04-25 9:06 ` [Qemu-devel] [RESEND][PATCH 5/9] pcmcia: move attach and detach socket methods to PCMCIASocket Dmitry Eremin-Solenikov
2011-04-25 9:06 ` [Qemu-devel] [RESEND][PATCH 6/9] pxa: change order of pcmcia devices instantiation, so that the socket 0 will be default Dmitry Eremin-Solenikov
2011-04-25 9:06 ` [Qemu-devel] [RESEND][PATCH 7/9] ide-core: allocate metadata storage for CFATA drives Dmitry Eremin-Solenikov
2011-04-25 9:06 ` [Qemu-devel] [RESEND][PATCH 8/9] strongarm: add PCMCIA support Dmitry Eremin-Solenikov
2011-04-25 9:06 ` [Qemu-devel] [RESEND][PATCH 9/9] collie: add support for PCMCIA bus Dmitry Eremin-Solenikov
2011-04-29 19:40 ` [Qemu-devel] [RESEND][PATCH 1/9] pxa2xx_pcmcia: qdevify Dmitry Eremin-Solenikov
2011-05-03 9:02 ` Dmitry Eremin-Solenikov
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).