aboutsummaryrefslogtreecommitdiff
path: root/hw/scsi
diff options
context:
space:
mode:
Diffstat (limited to 'hw/scsi')
-rw-r--r--hw/scsi/esp-pci.c19
-rw-r--r--hw/scsi/esp.c6
-rw-r--r--hw/scsi/lsi53c895a.c10
-rw-r--r--hw/scsi/megasas.c19
-rw-r--r--hw/scsi/mptsas.h5
-rw-r--r--hw/scsi/scsi-disk.c20
-rw-r--r--hw/scsi/spapr_vscsi.c10
-rw-r--r--hw/scsi/vmw_pvscsi.c18
8 files changed, 56 insertions, 51 deletions
diff --git a/hw/scsi/esp-pci.c b/hw/scsi/esp-pci.c
index 90432ef107..2ce96dc56e 100644
--- a/hw/scsi/esp-pci.c
+++ b/hw/scsi/esp-pci.c
@@ -33,11 +33,13 @@
#include "qapi/error.h"
#include "qemu/log.h"
#include "qemu/module.h"
+#include "qom/object.h"
#define TYPE_AM53C974_DEVICE "am53c974"
-#define PCI_ESP(obj) \
- OBJECT_CHECK(PCIESPState, (obj), TYPE_AM53C974_DEVICE)
+typedef struct PCIESPState PCIESPState;
+DECLARE_INSTANCE_CHECKER(PCIESPState, PCI_ESP,
+ TYPE_AM53C974_DEVICE)
#define DMA_CMD 0x0
#define DMA_STC 0x1
@@ -64,7 +66,7 @@
#define SBAC_STATUS (1 << 24)
-typedef struct PCIESPState {
+struct PCIESPState {
/*< private >*/
PCIDevice parent_obj;
/*< public >*/
@@ -73,7 +75,7 @@ typedef struct PCIESPState {
uint32_t dma_regs[8];
uint32_t sbac;
ESPState esp;
-} PCIESPState;
+};
static void esp_pci_handle_idle(PCIESPState *pci, uint32_t val)
{
@@ -408,14 +410,15 @@ static const TypeInfo esp_pci_info = {
},
};
-typedef struct {
+struct DC390State {
PCIESPState pci;
eeprom_t *eeprom;
-} DC390State;
+};
+typedef struct DC390State DC390State;
#define TYPE_DC390_DEVICE "dc390"
-#define DC390(obj) \
- OBJECT_CHECK(DC390State, obj, TYPE_DC390_DEVICE)
+DECLARE_INSTANCE_CHECKER(DC390State, DC390,
+ TYPE_DC390_DEVICE)
#define EE_ADAPT_SCSI_ID 64
#define EE_MODE2 65
diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c
index 405f8b7cbc..b84e0fe33e 100644
--- a/hw/scsi/esp.c
+++ b/hw/scsi/esp.c
@@ -929,7 +929,7 @@ static const struct SCSIBusInfo esp_scsi_info = {
static void sysbus_esp_gpio_demux(void *opaque, int irq, int level)
{
- SysBusESPState *sysbus = ESP_STATE(opaque);
+ SysBusESPState *sysbus = ESP(opaque);
ESPState *s = &sysbus->esp;
switch (irq) {
@@ -945,7 +945,7 @@ static void sysbus_esp_gpio_demux(void *opaque, int irq, int level)
static void sysbus_esp_realize(DeviceState *dev, Error **errp)
{
SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
- SysBusESPState *sysbus = ESP_STATE(dev);
+ SysBusESPState *sysbus = ESP(dev);
ESPState *s = &sysbus->esp;
sysbus_init_irq(sbd, &s->irq);
@@ -967,7 +967,7 @@ static void sysbus_esp_realize(DeviceState *dev, Error **errp)
static void sysbus_esp_hard_reset(DeviceState *dev)
{
- SysBusESPState *sysbus = ESP_STATE(dev);
+ SysBusESPState *sysbus = ESP(dev);
esp_hard_reset(&sysbus->esp);
}
diff --git a/hw/scsi/lsi53c895a.c b/hw/scsi/lsi53c895a.c
index 63ff4181de..e8354a47da 100644
--- a/hw/scsi/lsi53c895a.c
+++ b/hw/scsi/lsi53c895a.c
@@ -23,6 +23,7 @@
#include "qemu/log.h"
#include "qemu/module.h"
#include "trace.h"
+#include "qom/object.h"
static const char *names[] = {
"SCNTL0", "SCNTL1", "SCNTL2", "SCNTL3", "SCID", "SXFER", "SDID", "GPREG",
@@ -213,7 +214,7 @@ enum {
LSI_MSG_ACTION_DIN = 3,
};
-typedef struct {
+struct LSIState {
/*< private >*/
PCIDevice parent_obj;
/*< public >*/
@@ -303,13 +304,14 @@ typedef struct {
uint32_t adder;
uint8_t script_ram[2048 * sizeof(uint32_t)];
-} LSIState;
+};
+typedef struct LSIState LSIState;
#define TYPE_LSI53C810 "lsi53c810"
#define TYPE_LSI53C895A "lsi53c895a"
-#define LSI53C895A(obj) \
- OBJECT_CHECK(LSIState, (obj), TYPE_LSI53C895A)
+DECLARE_INSTANCE_CHECKER(LSIState, LSI53C895A,
+ TYPE_LSI53C895A)
static const char *scsi_phases[] = {
"DOUT",
diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c
index 390c2f2edb..e90c00823a 100644
--- a/hw/scsi/megasas.c
+++ b/hw/scsi/megasas.c
@@ -34,6 +34,7 @@
#include "qapi/error.h"
#include "mfi.h"
#include "migration/vmstate.h"
+#include "qom/object.h"
#define MEGASAS_VERSION_GEN1 "1.70"
#define MEGASAS_VERSION_GEN2 "1.80"
@@ -72,7 +73,7 @@ typedef struct MegasasCmd {
struct MegasasState *state;
} MegasasCmd;
-typedef struct MegasasState {
+struct MegasasState {
/*< private >*/
PCIDevice parent_obj;
/*< public >*/
@@ -116,28 +117,26 @@ typedef struct MegasasState {
MegasasCmd frames[MEGASAS_MAX_FRAMES];
DECLARE_BITMAP(frame_map, MEGASAS_MAX_FRAMES);
SCSIBus bus;
-} MegasasState;
+};
+typedef struct MegasasState MegasasState;
-typedef struct MegasasBaseClass {
+struct MegasasBaseClass {
PCIDeviceClass parent_class;
const char *product_name;
const char *product_version;
int mmio_bar;
int ioport_bar;
int osts;
-} MegasasBaseClass;
+};
+typedef struct MegasasBaseClass MegasasBaseClass;
#define TYPE_MEGASAS_BASE "megasas-base"
#define TYPE_MEGASAS_GEN1 "megasas"
#define TYPE_MEGASAS_GEN2 "megasas-gen2"
-#define MEGASAS(obj) \
- OBJECT_CHECK(MegasasState, (obj), TYPE_MEGASAS_BASE)
+DECLARE_OBJ_CHECKERS(MegasasState, MegasasBaseClass,
+ MEGASAS, TYPE_MEGASAS_BASE)
-#define MEGASAS_CLASS(oc) \
- OBJECT_CLASS_CHECK(MegasasBaseClass, (oc), TYPE_MEGASAS_BASE)
-#define MEGASAS_GET_CLASS(oc) \
- OBJECT_GET_CLASS(MegasasBaseClass, (oc), TYPE_MEGASAS_BASE)
#define MEGASAS_INTR_DISABLED_MASK 0xFFFFFFFF
diff --git a/hw/scsi/mptsas.h b/hw/scsi/mptsas.h
index 9ac98fc20e..b85ac1a5fc 100644
--- a/hw/scsi/mptsas.h
+++ b/hw/scsi/mptsas.h
@@ -2,6 +2,7 @@
#define MPTSAS_H
#include "mpi.h"
+#include "qom/object.h"
#define MPTSAS_NUM_PORTS 8
#define MPTSAS_MAX_FRAMES 2048 /* Firmware limit at 65535 */
@@ -15,8 +16,8 @@ typedef struct MPTSASRequest MPTSASRequest;
#define TYPE_MPTSAS1068 "mptsas1068"
typedef struct MPTSASState MPTSASState;
-#define MPT_SAS(obj) \
- OBJECT_CHECK(MPTSASState, (obj), TYPE_MPTSAS1068)
+DECLARE_INSTANCE_CHECKER(MPTSASState, MPT_SAS,
+ TYPE_MPTSAS1068)
enum {
DOORBELL_NONE,
diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
index 7612035a4e..1f0388a755 100644
--- a/hw/scsi/scsi-disk.c
+++ b/hw/scsi/scsi-disk.c
@@ -38,6 +38,7 @@
#include "sysemu/sysemu.h"
#include "qemu/cutils.h"
#include "trace.h"
+#include "qom/object.h"
#ifdef __linux
#include <scsi/sg.h>
@@ -54,20 +55,18 @@
#define TYPE_SCSI_DISK_BASE "scsi-disk-base"
-#define SCSI_DISK_BASE(obj) \
- OBJECT_CHECK(SCSIDiskState, (obj), TYPE_SCSI_DISK_BASE)
-#define SCSI_DISK_BASE_CLASS(klass) \
- OBJECT_CLASS_CHECK(SCSIDiskClass, (klass), TYPE_SCSI_DISK_BASE)
-#define SCSI_DISK_BASE_GET_CLASS(obj) \
- OBJECT_GET_CLASS(SCSIDiskClass, (obj), TYPE_SCSI_DISK_BASE)
+typedef struct SCSIDiskClass SCSIDiskClass;
+typedef struct SCSIDiskState SCSIDiskState;
+DECLARE_OBJ_CHECKERS(SCSIDiskState, SCSIDiskClass,
+ SCSI_DISK_BASE, TYPE_SCSI_DISK_BASE)
-typedef struct SCSIDiskClass {
+struct SCSIDiskClass {
SCSIDeviceClass parent_class;
DMAIOFunc *dma_readv;
DMAIOFunc *dma_writev;
bool (*need_fua_emulation)(SCSICommand *cmd);
void (*update_sense)(SCSIRequest *r);
-} SCSIDiskClass;
+};
typedef struct SCSIDiskReq {
SCSIRequest req;
@@ -87,8 +86,7 @@ typedef struct SCSIDiskReq {
#define SCSI_DISK_F_DPOFUA 1
#define SCSI_DISK_F_NO_REMOVABLE_DEVOPS 2
-typedef struct SCSIDiskState
-{
+struct SCSIDiskState {
SCSIDevice qdev;
uint32_t features;
bool media_changed;
@@ -113,7 +111,7 @@ typedef struct SCSIDiskState
* 0xffff - reserved
*/
uint16_t rotation_rate;
-} SCSIDiskState;
+};
static bool scsi_handle_rw_error(SCSIDiskReq *r, int error, bool acct_failed);
diff --git a/hw/scsi/spapr_vscsi.c b/hw/scsi/spapr_vscsi.c
index 57f0a1336f..c3e6d1ecef 100644
--- a/hw/scsi/spapr_vscsi.c
+++ b/hw/scsi/spapr_vscsi.c
@@ -46,6 +46,7 @@
#include "trace.h"
#include <libfdt.h>
+#include "qom/object.h"
/*
* Virtual SCSI device
@@ -90,14 +91,15 @@ typedef struct vscsi_req {
} vscsi_req;
#define TYPE_VIO_SPAPR_VSCSI_DEVICE "spapr-vscsi"
-#define VIO_SPAPR_VSCSI_DEVICE(obj) \
- OBJECT_CHECK(VSCSIState, (obj), TYPE_VIO_SPAPR_VSCSI_DEVICE)
+typedef struct VSCSIState VSCSIState;
+DECLARE_INSTANCE_CHECKER(VSCSIState, VIO_SPAPR_VSCSI_DEVICE,
+ TYPE_VIO_SPAPR_VSCSI_DEVICE)
-typedef struct {
+struct VSCSIState {
SpaprVioDevice vdev;
SCSIBus bus;
vscsi_req reqs[VSCSI_REQ_LIMIT];
-} VSCSIState;
+};
static union viosrp_iu *req_iu(vscsi_req *req)
{
diff --git a/hw/scsi/vmw_pvscsi.c b/hw/scsi/vmw_pvscsi.c
index c071e0c7aa..40095bed09 100644
--- a/hw/scsi/vmw_pvscsi.c
+++ b/hw/scsi/vmw_pvscsi.c
@@ -36,6 +36,7 @@
#include "hw/qdev-properties.h"
#include "vmw_pvscsi.h"
#include "trace.h"
+#include "qom/object.h"
#define PVSCSI_USE_64BIT (true)
@@ -56,18 +57,17 @@
(stl_le_pci_dma(&container_of(m, PVSCSIState, rings)->parent_obj, \
(m)->rs_pa + offsetof(struct PVSCSIRingsState, field), val))
-typedef struct PVSCSIClass {
+struct PVSCSIClass {
PCIDeviceClass parent_class;
DeviceRealize parent_dc_realize;
-} PVSCSIClass;
+};
+typedef struct PVSCSIClass PVSCSIClass;
#define TYPE_PVSCSI "pvscsi"
-#define PVSCSI(obj) OBJECT_CHECK(PVSCSIState, (obj), TYPE_PVSCSI)
+typedef struct PVSCSIState PVSCSIState;
+DECLARE_OBJ_CHECKERS(PVSCSIState, PVSCSIClass,
+ PVSCSI, TYPE_PVSCSI)
-#define PVSCSI_CLASS(klass) \
- OBJECT_CLASS_CHECK(PVSCSIClass, (klass), TYPE_PVSCSI)
-#define PVSCSI_GET_CLASS(obj) \
- OBJECT_GET_CLASS(PVSCSIClass, (obj), TYPE_PVSCSI)
/* Compatibility flags for migration */
#define PVSCSI_COMPAT_OLD_PCI_CONFIGURATION_BIT 0
@@ -104,7 +104,7 @@ typedef struct PVSCSISGState {
typedef QTAILQ_HEAD(, PVSCSIRequest) PVSCSIRequestList;
-typedef struct {
+struct PVSCSIState {
PCIDevice parent_obj;
MemoryRegion io_space;
SCSIBus bus;
@@ -132,7 +132,7 @@ typedef struct {
uint32_t resetting; /* Reset in progress */
uint32_t compat_flags;
-} PVSCSIState;
+};
typedef struct PVSCSIRequest {
SCSIRequest *sreq;