On Wed, 13 Sep 2017 13:50:26 +0200 Halil Pasic <pa...@linux.vnet.ibm.com> wrote:
> This is a preparation for introducing handling for indirect data > addressing and modified indirect data addressing (CCW). Here we introduce > an interface which should make the addressing scheme transparent for the > client code. Here we implement only the basic scheme (no IDA or MIDA). > > Signed-off-by: Halil Pasic <pa...@linux.vnet.ibm.com> > --- > hw/s390x/css.c | 55 +++++++++++++++++++++++++++++++++++++++++ > include/hw/s390x/css.h | 67 > ++++++++++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 122 insertions(+) > > +void ccw_dstream_init(CcwDataStream *cds, CCW1 const *ccw, ORB const *orb) > +{ > + /* > + * We don't support MIDA (an optional facility) yet and we > + * catch this earlier. Just for expressing the precondition. > + */ > + g_assert(!(orb->ctrl1 & ORB_CTRL1_MASK_MIDAW)); > + cds->flags = (orb->ctrl0 & ORB_CTRL0_MASK_I2K ? CDS_F_I2K : 0) | > + (orb->ctrl0 & ORB_CTRL0_MASK_C64 ? CDS_F_C64 : 0) | > + (ccw->flags & CCW_FLAG_IDA ? CDS_F_IDA : 0); > + cds->count = ccw->count; > + cds->cda_orig = ccw->cda; > + ccw_dstream_rewind(cds); > + if (!(cds->flags & CDS_F_IDA)) { > + cds->op_handler = ccw_dstream_rw_noflags; > + } else { > + assert(false); g_assert_not_reached() might have been better; but as this is removed anyway in patch 4, it does not matter. > + } > +} > > static int css_interpret_ccw(SubchDev *sch, hwaddr ccw_addr, > bool suspend_allowed) > diff --git a/include/hw/s390x/css.h b/include/hw/s390x/css.h > index 0653d3c9be..79acaf99b7 100644 > --- a/include/hw/s390x/css.h > +++ b/include/hw/s390x/css.h > @@ -75,6 +75,29 @@ typedef struct CMBE { > uint32_t reserved[7]; > } QEMU_PACKED CMBE; > > +typedef enum CcwDataStreamOp { > + CDS_OP_R = 0, > + CDS_OP_W = 1, > + CDS_OP_A = 2 > +} CcwDataStreamOp; > + > +/** normal usage is via SuchchDev.cds instead of instantiating */ /* instead of /**? Can change while applying. > +typedef struct CcwDataStream { > +#define CDS_F_IDA 0x01 > +#define CDS_F_MIDA 0x02 > +#define CDS_F_I2K 0x04 > +#define CDS_F_C64 0x08 > +#define CDS_F_STREAM_BROKEN 0x80 > + uint8_t flags; > + uint8_t at_idaw; > + uint16_t at_byte; > + uint16_t count; > + uint32_t cda_orig; > + int (*op_handler)(struct CcwDataStream *cds, void *buff, int len, > + CcwDataStreamOp op); > + hwaddr cda; > +} CcwDataStream; > + > typedef struct SubchDev SubchDev; > struct SubchDev { > /* channel-subsystem related things: */