pxa2xx_pcmcia: qdevify
PATCH RESEND 1/9 pxa2xx_pcmcia: qdevify
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).
--- 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(-)
hw/mainstone.c +8 -6
@@ -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 ));
hw/pcmcia.h +3 -0
@@ -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);
hw/pxa.h +1 -4
@@ -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;
hw/pxa2xx.c +5 -4
@@ -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 ));
hw/pxa2xx_pcmcia.c +56 -21
120 lines not on this page · raw message
hw/spitz.c +12 -8
@@ -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. */
hw/tosa.c +6 -6
@@ -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 ]);
Signature · 1 line
1.7.4.1
PATCH RESEND 2/9 PCMCIA: start qdev'ication
Convert PCMCIA bus handling code to use QBus internally. MicroDrive code is still unaffected.
--- 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
Makefile.objs +3 -0
@@ -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
hw/pcmcia.c new file +102 -0
102 lines not on this page · raw message
hw/pcmcia.h +14 -1
@@ -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 */
hw/pxa2xx_pcmcia.c +1 -1
@@ -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 ; }
vl.c +0 -43
49 lines not on this page · raw message
Signature · 1 line
1.7.4.1
PATCH RESEND 3/9 microdrive: qdevify
In reply to Dmitry Eremin-SolenikovSwitch 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(-)
hw/ide/microdrive.c +39 -10
@@ -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);
hw/pcmcia.h +1 -1
@@ -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);
hw/spitz.c +4 -1
@@ -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); } }
hw/tosa.c +4 -1
@@ -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); } }
Signature · 1 line
1.7.4.1
PATCH RESEND 4/9 pcmcia: move all card callbacks to PCMCIACardInfo
In reply to Dmitry Eremin-Solenikovlast commit fixup
Revert "microdrive fixup"
This reverts commit 6a9f969b0626e218ff910d84ed1c9eec285cbcd5.
--- hw/ide/microdrive.c | 41 ++++++++++++++++++++--------------------- hw/pcmcia.h | 29 +++++++++++++++-------------- hw/pxa2xx_pcmcia.c | 16 ++++++++-------- 3 files changed, 43 insertions(+), 43 deletions(-)
hw/ide/microdrive.c +20 -21
@@ -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 )
hw/pcmcia.h +15 -14
@@ -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);
hw/pxa2xx_pcmcia.c +8 -8
@@ -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 ;
Signature · 1 line
1.7.4.1
PATCH RESEND 5/9 pcmcia: move attach and detach socket methods to PCMCIASocket
In reply to Dmitry Eremin-SolenikovMake attach and detach calls to be automatically called by PCMCIA card instantiation code, rather than calling them by hand from the board code.
--- 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(-)
hw/pcmcia.c +44 -1
@@ -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);
hw/pcmcia.h +2 -0
@@ -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);
hw/pxa.h +0 -4
@@ -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;
hw/pxa2xx_pcmcia.c +33 -40
87 lines not on this page · raw message
hw/spitz.c +0 -1
@@ -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); } }
hw/tosa.c +0 -1
@@ -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); } }
Signature · 1 line
1.7.4.1
PATCH RESEND 6/9 pxa: change order of pcmcia devices instantiation, so that the socket 0 will be default
In reply to Dmitry Eremin-Solenikov--- hw/pxa2xx.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
hw/pxa2xx.c +2 -2
@@ -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 ));
Signature · 1 line
1.7.4.1
PATCH RESEND 7/9 ide-core: allocate metadata storage for CFATA drives
In reply to Dmitry Eremin-SolenikovCurrently it's done by hw/ide/microdrive.c To simplify that part, move this initialization to ide core.
--- hw/ide/core.c | 4 ++++ hw/ide/internal.h | 2 ++ hw/ide/microdrive.c | 6 +----- 3 files changed, 7 insertions(+), 5 deletions(-)
hw/ide/core.c +4 -0
@@ -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 {
hw/ide/internal.h +2 -0
@@ -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 *);
hw/ide/microdrive.c +1 -5
@@ -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 ; }
Signature · 1 line
1.7.4.1
PATCH RESEND 9/9 collie: add support for PCMCIA bus
In reply to Dmitry Eremin-Solenikov--- hw/collie.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-)
hw/collie.c +7 -0
@@ -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;
Signature · 1 line
1.7.4.1
PATCH RESEND 8/9 strongarm: add PCMCIA support
In reply to Dmitry Eremin-SolenikovAdd PCMCIA support to StrongARM SoCs reusing PXA devices.
--- hw/strongarm.c | 5 ++++- hw/strongarm.h | 1 + 2 files changed, 5 insertions(+), 1 deletions(-)
hw/strongarm.c +4 -1
@@ -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; }
hw/strongarm.h +1 -0
@@ -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);
Signature · 1 line
1.7.4.1
Hello,
Any chance to get any response for this patches serie?
Quoted 6 lines · Dmitry Eremin-Solenikov
Use qdev insfrastructure for managing PXA PCMCIA devices. PCMCIA bus itself isn't converted to QBus (yet).
pxa2xx_pcmcia_init()function is moved topcmcia.has it will be used by other cores/devices (like StrongARM).Signed-off-by Dmitry Eremin-Solenikov <[email protected]>
Signature · 2 lines
With best wishes Dmitry
Hello, colleagues,
Quoted 3 lines · Dmitry Eremin-Solenikov
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?
Quoted 12 lines · Dmitry Eremin-Solenikov
Quoted 6 lines
Use qdev insfrastructure for managing PXA PCMCIA devices. PCMCIA bus itself isn't converted to QBus (yet).
pxa2xx_pcmcia_init()function is moved topcmcia.has it will be used by other cores/devices (like StrongARM).Signed-off-by Dmitry Eremin-Solenikov <[email protected]>--
With best wishes
Dmitry
Signature · 2 lines
With best wishes Dmitry
Re: [Qemu-devel] [RESEND][PATCH 2/9] PCMCIA: start qdev'ication
In reply to Dmitry Eremin-SolenikovHi Dmitry,
Quoted 88 lines · Dmitry Eremin-Solenikov
Convert PCMCIA bus handling code to use QBus internally. MicroDrive code is still unaffected.
Signed-off-by Dmitry Eremin-Solenikov <[email protected]>---
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.cMakefile.objs +0
-0@@ -289,6 +289,9 @@ hw-obj-$(CONFIG_REALLY_VIRTFS) += virtio-9p-debug.ohw-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
Makefile.objs +3
-0+# PCMCIA +hw-obj-y += pcmcia.o +######################################################################
# libdis # NOTE: the disassembler code is only needed for debugginghw/pcmcia.c new file +55
-0@@ -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; +} +
hw/pcmcia.c line 65
Quoted 10 lines
hw/pcmcia.c new file +10
-0+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
Re: [Qemu-devel] [RESEND][PATCH 3/9] microdrive: qdevify
In reply to Dmitry Eremin-SolenikovQuoted 23 lines · Dmitry Eremin-Solenikov
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(-)hw/ide/microdrive.c +1
-1@@ -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;
hw/ide/microdrive.c static int dscm1xxxx_detach(void *opaque) · line 532
Quoted 5 lines
hw/ide/microdrive.c +1
-1@@ -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
Re: [Qemu-devel] [RESEND][PATCH 3/9] microdrive: qdevify
Hello,
Quoted 29 lines · andrzej zaborowski
Quoted 27 lines · Dmitry Eremin-Solenikov
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(-)hw/ide/microdrive.c +1
-1@@ -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 ; }
Quoted 7 lines
hw/ide/microdrive.c static int dscm1xxxx_detach(void *opaque) · line 532
Quoted 2 lines
hw/ide/microdrive.c +1
-1-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).
Signature · 2 lines
With best wishes Dmitry
Re: [Qemu-devel] [RESEND][PATCH 2/9] PCMCIA: start qdev'ication
In reply to andrzej zaborowskiQuoted 110 lines · andrzej zaborowski
Hi Dmitry,
Quoted 106 lines · Dmitry Eremin-Solenikov
Convert PCMCIA bus handling code to use QBus internally. MicroDrive code is still unaffected.
Signed-off-by Dmitry Eremin-Solenikov <[email protected]>--- 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.cMakefile.objs +3
-0@@ -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 debugginghw/pcmcia.c new file +8
-0@@ -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.
+ */hw/pcmcia.c new file +36
-0+#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)
Quoted 8 lines
hw/pcmcia.c line 65
Quoted 4 lines
hw/pcmcia.c new file +4
-0+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->nextincorrectly. (I notice that this error is present in the current code too)
OK, will fix it.
Quoted 2 lines
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...
Quoted 2 lines
Out of curiosity, In the patch 1/9 can you include
pxa.hinstead of moving the declaration out ofpxa.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.
Quoted 3 lines
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.
Signature · 2 lines
With best wishes Dmitry
Re: [Qemu-devel] [RESEND][PATCH 3/9] microdrive: qdevify
In reply to Dmitry Eremin-SolenikovQuoted 40 lines · Dmitry Eremin-Solenikov
Hello,
Quoted 29 lines · andrzej zaborowski
Quoted 27 lines · Dmitry Eremin-Solenikov
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(-)hw/ide/microdrive.c +1
-1@@ -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; }Quoted 7 lines
hw/ide/microdrive.c static int dscm1xxxx_detach(void *opaque) · line 532
Quoted 2 lines
hw/ide/microdrive.c +1
-1-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?
Quoted 2 lines
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
Re: [Qemu-devel] [RESEND][PATCH 3/9] microdrive: qdevify
Quoted 41 lines · andrzej zaborowski
Quoted 40 lines · Dmitry Eremin-Solenikov
Hello,
Quoted 36 lines · andrzej zaborowski
Quoted 24 lines · Dmitry Eremin-Solenikov
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(-)hw/ide/microdrive.c +1
-1@@ -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;hw/ide/microdrive.c static int dscm1xxxx_detach(void *opaque) · line 532
Quoted 5 lines
hw/ide/microdrive.c +1
-1@@ -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?
Quoted 8 lines
Quoted 2 lines
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.
Signature · 2 lines
With best wishes Dmitry
Re: [Qemu-devel] [RESEND][PATCH 3/9] microdrive: qdevify
Quoted 11 lines · Dmitry Eremin-Solenikov
Quoted 9 lines · andrzej zaborowski
Quoted 2 lines · Dmitry Eremin-Solenikov
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.
Quoted 3 lines
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.
Quoted 5 lines
For creation of a DeviceState via
qdev_createyou 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
Re: [Qemu-devel] [RESEND][PATCH 3/9] microdrive: qdevify
Quoted 25 lines · andrzej zaborowski
Quoted 11 lines · Dmitry Eremin-Solenikov
Quoted 9 lines · andrzej zaborowski
Quoted 2 lines · Dmitry Eremin-Solenikov
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.
Quoted 3 lines
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.
Quoted 5 lines
For creation of a DeviceState via
qdev_createyou 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.
Quoted 6 lines
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
Re: [Qemu-devel] [RESEND][PATCH 3/9] microdrive: qdevify
Quoted 33 lines · Jan Kiszka
Quoted 25 lines · andrzej zaborowski
Quoted 11 lines · Dmitry Eremin-Solenikov
Quoted 9 lines · andrzej zaborowski
Quoted 2 lines · Dmitry Eremin-Solenikov
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.
Quoted 3 lines
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.
Quoted 5 lines
For creation of a DeviceState via
qdev_createyou 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.Quoted 6 lines
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.
Quoted 4 lines
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.
Quoted 3 lines
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
Re: [Qemu-devel] [RESEND][PATCH 3/9] microdrive: qdevify
Quoted 34 lines · andrzej zaborowski
Quoted 33 lines · Jan Kiszka
Quoted 31 lines · andrzej zaborowski
Quoted 11 lines · Dmitry Eremin-Solenikov
Quoted 9 lines · andrzej zaborowski
Quoted 2 lines · Dmitry Eremin-Solenikov
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.
Quoted 3 lines
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.
Quoted 5 lines
For creation of a DeviceState via
qdev_createyou 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.
Quoted 7 lines
Quoted 4 lines
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.
Quoted 7 lines
, 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.
Quoted 1 line
Quoted 6 lines
Quoted 2 lines
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.
Quoted 4 lines
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
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux