sclp related fixes and sclp line mode console
cover sclp related fixes and sclp line mode console
Alex,
here is a bunch of fixes/changes for sclp/eventfacility followed by a move of the ebcdic conversion into a stand-alone header file and the sclp line mode console.
Christian Borntraeger (3):
s390/eventfacility: Fix receive/send masks s390/eventfacility: remove unused event_type variable s390/eventfacility: allow childs to handle more than 1 event type
Heinz Graalfs (7):
s390/sclpconsole: modify definition of input buffer s390/sclpconsole: Add code to support live migration for sclpconsole s390/sclpquiesce: Add code to support live migration s390/event-facility: Add code to support live migration s390/sclp: add reset() functions
s390/ebcdic: Move conversion tables to header file s390/sclplmconsole: Add support for SCLP line-mode console
Ralf Hoppe (1):
s390/eventfacility: fix multiple Read Event Data sources
hw/char/Makefile.objs | 2 +- hw/char/sclpconsole-lm.c | 393 ++++++++++++++++++++++++++++++++++++++ hw/char/sclpconsole.c | 89 ++++----- hw/s390x/event-facility.c | 30 ++- hw/s390x/sclpquiesce.c | 30 ++- include/hw/s390x/ebcdic.h | 107 +++++++++++ include/hw/s390x/event-facility.h | 86 ++++++++- target-s390x/misc_helper.c | 81 +------- 8 files changed, 678 insertions(+), 140 deletions(-) create mode 100644 hw/char/sclpconsole-lm.c create mode 100644 include/hw/s390x/ebcdic.h
Signature · 1 line
1.8.3.1
PATCH 1/11 s390/sclpconsole: modify definition of input buffer
From: Heinz Graalfs <[email protected]>
To use VMState for migration, we need to adapt some sclp code:
- allocate console buffer as part of the console
- change semantic of sclpconsole offset fields
--- hw/char/sclpconsole.c | 54 +++++++++++++++------------------------------------ 1 file changed, 16 insertions(+), 38 deletions(-)
hw/char/sclpconsole.c +16 -38
@@ -31,12 +31,11 @@ typedef struct ASCIIConsoleData {typedef struct SCLPConsole {SCLPEvent event;CharDriverState *chr; -/* io vector */ -uint8_t *iov;/* iov buffer pointer */ -uint8_t *iov_sclp;/* pointer to SCLP read offset */ -uint8_t *iov_bs;/* pointer byte stream read offset */ -uint32_t iov_data_len;/* length of byte stream in buffer */ -uint32_t iov_sclp_rest;/* length of byte stream not read via SCLP */ +uint8_t iov[SIZE_BUFFER_VT220 ]; +uint32_t iov_sclp;/* offset in buf for SCLP read operation */ +uint32_t iov_bs;/* offset in buf for char layer read operation */ +uint32_t iov_data_len;/* length of byte stream in buffer */ +uint32_t iov_sclp_rest;/* length of byte stream not read via SCLP */ qemu_irq irq_read_vt220; }SCLPConsole ;
@@ -47,7 +46,7 @@ static int chr_can_read(void *opaque) {SCLPConsole *scon = opaque; -return scon->iov ?SIZE_BUFFER_VT220 - scon->iov_data_len :0 ; +return SIZE_BUFFER_VT220 - scon->iov_data_len; }/* Receive n bytes from character layer, save in iov buffer,
@@ -55,13 +54,11 @@ static int chr_can_read(void *opaque)static void receive_from_chr_layer (SCLPConsole *scon,const uint8_t *buf,int size) { -assert (scon->iov); -/* read data must fit into current buffer */ assert (size <=SIZE_BUFFER_VT220 - scon->iov_data_len);/* put byte-stream from character layer into buffer */ -memcpy (scon->iov_bs, buf, size); +memcpy (&scon->iov[scon->iov_bs], buf, size); scon->iov_data_len += size; scon->iov_sclp_rest += size; scon->iov_bs += size;
@@ -80,29 +77,6 @@ static void chr_read(void *opaque, const uint8_t *buf, int size)qemu_irq_raise (scon->irq_read_vt220); } -static void chr_event (void *opaque,int event) -{ -SCLPConsole *scon = opaque; - -switch (event) { -case CHR_EVENT_OPENED : -if (!scon->iov) { - scon->iov =g_malloc0 (SIZE_BUFFER_VT220 ); - scon->iov_sclp = scon->iov; - scon->iov_bs = scon->iov; - scon->iov_data_len =0 ; - scon->iov_sclp_rest =0 ; - } -break ; -case CHR_EVENT_CLOSED : -if (scon->iov) { -g_free (scon->iov); - scon->iov =NULL ; - } -break ; - } -} -/* functions to be called by event facility */ static int event_type (void )
@@ -134,17 +108,17 @@ static void get_console_data(SCLPEvent *event, uint8_t *buf, size_t *size,/* if all data fit into provided SCLP buffer */ if (avail >= cons->iov_sclp_rest) {/* copy character byte-stream to SCLP buffer */ -memcpy (buf, cons->iov_sclp, cons->iov_sclp_rest); +memcpy (buf, &cons->iov[cons->iov_sclp], cons->iov_sclp_rest); *size = cons->iov_sclp_rest +1 ; - cons->iov_sclp = cons->iov; - cons->iov_bs = cons->iov; + cons->iov_sclp =0 ; + cons->iov_bs =0 ; cons->iov_data_len =0 ; cons->iov_sclp_rest =0 ; event->event_pending = false;/* data provided and no more data pending */ }else {/* if provided buffer is too small, just copy part */ -memcpy (buf, cons->iov_sclp, avail); +memcpy (buf, &cons->iov[cons->iov_sclp], avail); *size = avail +1 ; cons->iov_sclp_rest -= avail; cons->iov_sclp += avail;
@@ -237,10 +211,14 @@ static int console_init(SCLPEvent *event)return -1 ; } console_available = true; + scon->iov_sclp =0 ; + scon->iov_bs =0 ; + scon->iov_data_len =0 ; + scon->iov_sclp_rest =0 ; event->event_type =SCLP_EVENT_ASCII_CONSOLE_DATA ;if (scon->chr) {qemu_chr_add_handlers (scon->chr, chr_can_read, - chr_read, chr_event, scon); + chr_read,NULL , scon); } scon->irq_read_vt220 = *qemu_allocate_irqs (trigger_ascii_console_data,NULL ,1 );
Signature · 1 line
1.8.3.1
PATCH 2/11 s390/sclpconsole: Add code to support live migration for sclpconsole
In reply to Christian BorntraegerFrom: Heinz Graalfs <[email protected]>
This patch adds the necessary life migration pieces to the sclp code by using vmstate_register.
--- hw/char/sclpconsole.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)
hw/char/sclpconsole.c +18 -1
@@ -197,9 +197,26 @@ static void trigger_ascii_console_data(void *opaque, int n, int level)sclp_service_interrupt (0 ); } +static const VMStateDescription vmstate_sclpconsole = { + .name ="sclpconsole" , + .version_id =0 , + .minimum_version_id =0 , + .minimum_version_id_old =0 , + .fields = (VMStateField []) { +VMSTATE_BOOL (event.event_pending, SCLPConsole), +VMSTATE_UINT8_ARRAY (iov, SCLPConsole,SIZE_BUFFER_VT220 ), +VMSTATE_UINT32 (iov_sclp, SCLPConsole), +VMSTATE_UINT32 (iov_bs, SCLPConsole), +VMSTATE_UINT32 (iov_data_len, SCLPConsole), +VMSTATE_UINT32 (iov_sclp_rest, SCLPConsole), +VMSTATE_END_OF_LIST () + } +}; +/* qemu object creation and initialization functions */ /* tell character layer our call-back functions */ +static int console_init (SCLPEvent *event) {static bool console_available;
@@ -223,7 +240,7 @@ static int console_init(SCLPEvent *event) scon->irq_read_vt220 = *qemu_allocate_irqs (trigger_ascii_console_data,NULL ,1 ); -return 0 ; +return vmstate_register (NULL ,0 , &vmstate_sclpconsole, scon); }static int console_exit (SCLPEvent *event)
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 02/11] s390/sclpconsole: Add code to support live migration for sclpconsole
Quoted 43 lines · Christian Borntraeger
From: Heinz Graalfs <[email protected]>
This patch adds the necessary life migration pieces to the sclp code by using
vmstate_register.Signed-off-by Heinz Graalfs <[email protected]>Signed-off-by Christian Borntraeger <[email protected]>---
hw/char/sclpconsole.c| 19 ++++++++++++++++++-1 file changed, 18 insertions(+), 1 deletion(-)hw/char/sclpconsole.c +17
-0@@ -197,9 +197,26 @@ static void trigger_ascii_console_data(void *opaque, int n, int level)sclp_service_interrupt (0 ); } +static const VMStateDescription vmstate_sclpconsole = { + .name ="sclpconsole" , + .version_id =0 , + .minimum_version_id =0 , + .minimum_version_id_old =0 , + .fields = (VMStateField []) { +VMSTATE_BOOL (event.event_pending, SCLPConsole), +VMSTATE_UINT8_ARRAY (iov, SCLPConsole,SIZE_BUFFER_VT220 ), +VMSTATE_UINT32 (iov_sclp, SCLPConsole), +VMSTATE_UINT32 (iov_bs, SCLPConsole), +VMSTATE_UINT32 (iov_data_len, SCLPConsole), +VMSTATE_UINT32 (iov_sclp_rest, SCLPConsole), +VMSTATE_END_OF_LIST () + } +}; +/* qemu object creation and initialization functions */ /* tell character layer our call-back functions */ +static int console_init (SCLPEvent *event) {static bool console_available;
hw/char/sclpconsole.c static int console_init(SCLPEvent *event) · line 243
Quoted 5 lines
hw/char/sclpconsole.c +1
-1@@ -223,7 +240,7 @@ static int console_init(SCLPEvent *event) scon->irq_read_vt220 = *qemu_allocate_irqs (trigger_ascii_console_data,NULL ,1 ); -return 0 ; +return vmstate_register (NULL ,0 , &vmstate_sclpconsole, scon);
If I understand Anthony correctly a vmstate_register() call means you didn't convert something to QOM correctly :).
Alex
Re: [Qemu-devel] [PATCH 02/11] s390/sclpconsole: Add code to support live migration for sclpconsole
Quoted 49 lines · Alexander Graf
Quoted 46 lines · Christian Borntraeger
From: Heinz Graalfs <[email protected]>
This patch adds the necessary life migration pieces to the sclp code by using
vmstate_register.Signed-off-by Heinz Graalfs <[email protected]>Signed-off-by Christian Borntraeger <[email protected]>---
hw/char/sclpconsole.c| 19 ++++++++++++++++++-1 file changed, 18 insertions(+), 1 deletion(-)hw/char/sclpconsole.c +17
-0@@ -197,9 +197,26 @@ static void trigger_ascii_console_data(void *opaque, int n, int level)sclp_service_interrupt (0 ); } +static const VMStateDescription vmstate_sclpconsole = { + .name ="sclpconsole" , + .version_id =0 , + .minimum_version_id =0 , + .minimum_version_id_old =0 , + .fields = (VMStateField []) { +VMSTATE_BOOL (event.event_pending, SCLPConsole), +VMSTATE_UINT8_ARRAY (iov, SCLPConsole,SIZE_BUFFER_VT220 ), +VMSTATE_UINT32 (iov_sclp, SCLPConsole), +VMSTATE_UINT32 (iov_bs, SCLPConsole), +VMSTATE_UINT32 (iov_data_len, SCLPConsole), +VMSTATE_UINT32 (iov_sclp_rest, SCLPConsole), +VMSTATE_END_OF_LIST () + } +}; +/* qemu object creation and initialization functions */ /* tell character layer our call-back functions */ +static int console_init (SCLPEvent *event) {static bool console_available;@@ -223,7 +240,7 @@ static int console_init(SCLPEvent *event) scon->irq_read_vt220 = *qemu_allocate_irqs (trigger_ascii_console_data,NULL ,1 );
Quoted 4 lines
hw/char/sclpconsole.c static int console_init(SCLPEvent *event) · line 243
Quoted 2 lines
hw/char/sclpconsole.c +1
-1-return 0 ; +return vmstate_register (NULL ,0 , &vmstate_sclpconsole, scon);If I understand Anthony correctly a
vmstate_register()call means you didn't convert something to QOM correctly :).
In this case, the line is just wrong. In console_class_init, you should assign dc->vmsd = &vmstate_slcpconsole.
Regards,
Anthony Liguori
Quoted 4 lines
Alex
PATCH 3/11 s390/sclpquiesce: Add code to support live migration
In reply to Christian BorntraegerFrom: Heinz Graalfs <[email protected]>
This patch adds the necessary life migration pieces to sclpquiesce by using the vmstate_register.
--- hw/s390x/sclpquiesce.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
hw/s390x/sclpquiesce.c +12 -1
@@ -65,6 +65,17 @@ static int read_event_data(SCLPEvent *event, EventBufferHeader *evt_buf_hdr,return 1 ; } +static const VMStateDescription vmstate_sclpquiesce = { + .name ="sclpquiesce" , + .version_id =0 , + .minimum_version_id =0 , + .minimum_version_id_old =0 , + .fields = (VMStateField []) { +VMSTATE_BOOL (event_pending, SCLPEvent), +VMSTATE_END_OF_LIST () + } +}; +typedef struct QuiesceNotifier QuiesceNotifier ; static struct QuiesceNotifier {
@@ -91,7 +102,7 @@ static int quiesce_init(SCLPEvent *event)qemu_register_powerdown_notifier (&qn.notifier); -return 0 ; +return vmstate_register (NULL ,0 , &vmstate_sclpquiesce, event); }static void quiesce_class_init (ObjectClass *klass,void *data)
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 03/11] s390/sclpquiesce: Add code to support live migration
Quoted 34 lines · Christian Borntraeger
From: Heinz Graalfs <[email protected]>
This patch adds the necessary life migration pieces to sclpquiesce by using the
vmstate_register.Signed-off-by Heinz Graalfs <[email protected]>Signed-off-by Christian Borntraeger <[email protected]>---
hw/s390x/sclpquiesce.c| 13 ++++++++++++-1 file changed, 12 insertions(+), 1 deletion(-)hw/s390x/sclpquiesce.c +11
-0@@ -65,6 +65,17 @@ static int read_event_data(SCLPEvent *event, EventBufferHeader *evt_buf_hdr,return 1 ; } +static const VMStateDescription vmstate_sclpquiesce = { + .name ="sclpquiesce" , + .version_id =0 , + .minimum_version_id =0 , + .minimum_version_id_old =0 , + .fields = (VMStateField []) { +VMSTATE_BOOL (event_pending, SCLPEvent), +VMSTATE_END_OF_LIST () + } +}; +typedef struct QuiesceNotifier QuiesceNotifier ; static struct QuiesceNotifier {
hw/s390x/sclpquiesce.c static int quiesce_init(SCLPEvent *event) · line 105
Quoted 5 lines
hw/s390x/sclpquiesce.c +1
-1@@ -91,7 +102,7 @@ static int quiesce_init(SCLPEvent *event)qemu_register_powerdown_notifier (&qn.notifier); -return 0 ; +return vmstate_register (NULL ,0 , &vmstate_sclpquiesce, event);
Same thing here. Maybe this should be a device?
Alex
Quoted 6 lines
hw/s390x/sclpquiesce.c +0
-0}static void quiesce_class_init (ObjectClass *klass,void *data)Signature · 1 line
1.8.3.1
PATCH 4/11 s390/event-facility: Add code to support live migration
In reply to Christian BorntraegerFrom: Heinz Graalfs <[email protected]>
This patch adds the necessary life migration pieces to the event facility by using the vmstate_register.
--- hw/s390x/event-facility.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
hw/s390x/event-facility.c +12 -1
@@ -313,6 +313,17 @@ static void command_handler(SCLPEventFacility *ef, SCCB *sccb, uint64_t code) } } +static const VMStateDescription vmstate_eventfacility = { + .name ="sclpeventfacility" , + .version_id =0 , + .minimum_version_id =0 , + .minimum_version_id_old =0 , + .fields = (VMStateField []) { +VMSTATE_UINT32 (receive_mask, SCLPEventFacility), +VMSTATE_END_OF_LIST () + } +}; +static int init_event_facility (S390SCLPDevice *sdev) {SCLPEventFacility *event_facility;
@@ -335,7 +346,7 @@ static int init_event_facility(S390SCLPDevice *sdev) }qdev_init_nofail (quiesce); -return 0 ; +return vmstate_register (NULL ,0 , &vmstate_eventfacility, sdev->ef); }static void init_event_facility_class (ObjectClass *klass,void *data)
Signature · 1 line
1.8.3.1
PATCH 5/11 s390/sclp: add reset() functions
In reply to Christian BorntraegerFrom: Heinz Graalfs <[email protected]>
Add reset() functions for event-facility, sclpconsole, and sclpquiesce. The reset() functions perform variable initialization
at IPL and e.g. when monitor system_reset is called.
--- hw/char/sclpconsole.c | 17 +++++++++++++---- hw/s390x/event-facility.c | 9 +++++++++ hw/s390x/sclpquiesce.c | 9 +++++++++ 3 files changed, 31 insertions(+), 4 deletions(-)
hw/char/sclpconsole.c +13 -4
@@ -228,10 +228,6 @@ static int console_init(SCLPEvent *event)return -1 ; } console_available = true; - scon->iov_sclp =0 ; - scon->iov_bs =0 ; - scon->iov_data_len =0 ; - scon->iov_sclp_rest =0 ; event->event_type =SCLP_EVENT_ASCII_CONSOLE_DATA ;if (scon->chr) { qemu_chr_add_handlers(scon->chr, chr_can_read,
@@ -243,6 +239,18 @@ static int console_init(SCLPEvent *event)return vmstate_register (NULL ,0 , &vmstate_sclpconsole, scon); } +static void console_reset (DeviceState *dev) +{ +SCLPEvent *event =SCLP_EVENT (dev); +SCLPConsole *scon =DO_UPCAST (SCLPConsole, event, event); + + event->event_pending = false; + scon->iov_sclp =0 ; + scon->iov_bs =0 ; + scon->iov_data_len =0 ; + scon->iov_sclp_rest =0 ; +} +static int console_exit (SCLPEvent *event) {return 0 ;
@@ -259,6 +267,7 @@ static void console_class_init(ObjectClass *klass, void *data)SCLPEventClass *ec =SCLP_EVENT_CLASS (klass); dc->props = console_properties; + dc->reset = console_reset; ec->init = console_init; ec->exit = console_exit; ec->get_send_mask = send_mask;
hw/s390x/event-facility.c +9 -0
@@ -349,10 +349,19 @@ static int init_event_facility(S390SCLPDevice *sdev)return vmstate_register (NULL ,0 , &vmstate_eventfacility, sdev->ef); } +static void reset_event_facility (DeviceState *dev) +{ +S390SCLPDevice *sdev =SCLP_S390_DEVICE (dev); + + sdev->ef->receive_mask =0 ; +} +static void init_event_facility_class (ObjectClass *klass,void *data) { +DeviceClass *dc =DEVICE_CLASS (klass);S390SCLPDeviceClass *k =SCLP_S390_DEVICE_CLASS (klass); + dc->reset = reset_event_facility; k->init = init_event_facility; }
hw/s390x/sclpquiesce.c +9 -0
@@ -105,10 +105,19 @@ static int quiesce_init(SCLPEvent *event)return vmstate_register (NULL ,0 , &vmstate_sclpquiesce, event); } +static void quiesce_reset (DeviceState *dev) +{ +SCLPEvent *event =SCLP_EVENT (dev); + + event->event_pending = false; +} +static void quiesce_class_init (ObjectClass *klass,void *data) { +DeviceClass *dc =DEVICE_CLASS (klass);SCLPEventClass *k =SCLP_EVENT_CLASS (klass); + dc->reset = quiesce_reset; k->init = quiesce_init; k->get_send_mask = send_mask;
Signature · 1 line
1.8.3.1
PATCH 6/11 s390/eventfacility: fix multiple Read Event Data sources
In reply to Christian BorntraegerFrom: Ralf Hoppe <[email protected]>
Make the handler for SCLP Read Event Data deal with notifications for multiple sources correctly.
--- hw/s390x/event-facility.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
hw/s390x/event-facility.c +3 -3
@@ -183,7 +183,7 @@ static uint16_t handle_sccb_read_events(SCLPEventFacility *ef, SCCB *sccb, {uint16_t rc;int slen; -unsigned elen =0 ; +unsigned elen;BusChild *kid;SCLPEvent *event;SCLPEventClass *ec;
@@ -203,11 +203,11 @@ static uint16_t handle_sccb_read_events(SCLPEventFacility *ef, SCCB *sccb,if (mask & ec->get_send_mask ()) {if (ec->read_event_data (event, event_buf, &slen)) { + elen =be16_to_cpu (event_buf->length); + event_buf = (EventBufferHeader *) ((char *)event_buf + elen); rc =SCLP_RC_NORMAL_COMPLETION ; } } - elen =be16_to_cpu (event_buf->length); - event_buf = (void *) event_buf + elen; }if (sccb->h.control_mask[2 ] &SCLP_VARIABLE_LENGTH_RESPONSE ) {
Signature · 1 line
1.8.3.1
PATCH 7/11 s390/eventfacility: Fix receive/send masks
In reply to Christian BorntraegerCurrently we announce interchanged receive/send masks. This did not trigger a bug, since the sclp console has the same masks for send/receive and the Linux guest does not check the sclp mask for simple events like quiesce. With other event users like the sclp line mode console, we will have different send/receive bits. Fix it.
--- include/hw/s390x/event-facility.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/hw/s390x/event-facility.h +1 -1
@@ -43,8 +43,8 @@ typedef struct WriteEventMask {uint16_t mask_length;uint32_t cp_receive_mask;uint32_t cp_send_mask; -uint32_t send_mask;uint32_t receive_mask; +uint32_t send_mask; }QEMU_PACKED WriteEventMask; typedef struct EventBufferHeader {
Signature · 1 line
1.8.3.1
PATCH 8/11 s390/eventfacility: remove unused event_type variable
In reply to Christian BorntraegerThe event_type variable is never used. Get rid of it.
--- hw/char/sclpconsole.c | 1 - hw/s390x/sclpquiesce.c | 2 -- include/hw/s390x/event-facility.h | 1 - 3 files changed, 4 deletions(-)
hw/char/sclpconsole.c +0 -1
@@ -228,7 +228,6 @@ static int console_init(SCLPEvent *event)return -1 ; } console_available = true; - event->event_type =SCLP_EVENT_ASCII_CONSOLE_DATA ;if (scon->chr) {qemu_chr_add_handlers (scon->chr, chr_can_read, chr_read,NULL , scon);
hw/s390x/sclpquiesce.c +0 -2
@@ -95,8 +95,6 @@ static void quiesce_powerdown_req(Notifier *n, void *opaque)static int quiesce_init (SCLPEvent *event) { - event->event_type =SCLP_EVENT_SIGNAL_QUIESCE ; - qn.notifier.notify = quiesce_powerdown_req; qn.event = event;
include/hw/s390x/event-facility.h +0 -1
@@ -68,7 +68,6 @@ typedef struct ReadEventData {typedef struct SCLPEvent {DeviceState qdev;bool event_pending; -uint32_t event_type;char *name; }SCLPEvent ;
Signature · 1 line
1.8.3.1
PATCH 9/11 s390/eventfacility: allow childs to handle more than 1 event type
In reply to Christian BorntraegerCurrently all handlers (quiesce, console) only handle one event type. Some drivers will handle multiple (compatible) event types. Rework the code accordingly.
--- hw/char/sclpconsole.c | 6 +++--- hw/s390x/event-facility.c | 2 +- hw/s390x/sclpquiesce.c | 6 +++--- include/hw/s390x/event-facility.h | 5 ++--- 4 files changed, 9 insertions(+), 10 deletions(-)
hw/char/sclpconsole.c +3 -3
@@ -79,9 +79,9 @@ static void chr_read(void *opaque, const uint8_t *buf, int size)/* functions to be called by event facility */ -static int event_type (void ) +static bool can_handle_event (uint8_t type) { -return SCLP_EVENT_ASCII_CONSOLE_DATA ; +return type ==SCLP_EVENT_ASCII_CONSOLE_DATA ; }static unsigned int send_mask (void )
@@ -271,7 +271,7 @@ static void console_class_init(ObjectClass *klass, void *data) ec->exit = console_exit; ec->get_send_mask = send_mask; ec->get_receive_mask = receive_mask; - ec->event_type = event_type; + ec->can_handle_event = can_handle_event; ec->read_event_data = read_event_data; ec->write_event_data = write_event_data; }
hw/s390x/event-facility.c +1 -1
@@ -120,7 +120,7 @@ static uint16_t handle_write_event_buf(SCLPEventFacility *ef, ec =SCLP_EVENT_GET_CLASS (event);if (ec->write_event_data && - ec->event_type () == event_buf->type) { + ec->can_handle_event (event_buf->type)) { rc = ec->write_event_data (event, event_buf);break ; }
hw/s390x/sclpquiesce.c +3 -3
@@ -22,9 +22,9 @@ typedef struct SignalQuiesce {uint8_t unit; }QEMU_PACKED SignalQuiesce; -static int event_type (void ) +static bool can_handle_event (uint8_t type) { -return SCLP_EVENT_SIGNAL_QUIESCE ; +return type ==SCLP_EVENT_SIGNAL_QUIESCE ; }static unsigned int send_mask (void )
@@ -120,7 +120,7 @@ static void quiesce_class_init(ObjectClass *klass, void *data) k->get_send_mask = send_mask; k->get_receive_mask = receive_mask; - k->event_type = event_type; + k->can_handle_event = can_handle_event; k->read_event_data = read_event_data; k->write_event_data =NULL ; }
include/hw/s390x/event-facility.h +2 -3
@@ -87,9 +87,8 @@ typedef struct SCLPEventClass {int (*write_event_data)(SCLPEvent *event,EventBufferHeader *evt_buf_hdr); -/* returns the supported event type */ - int (*event_type)(void); - +/* can we handle this event type? */ + bool (*can_handle_event)(uint8_t type); } SCLPEventClass;#endif
Signature · 1 line
1.8.3.1
PATCH 10/11 s390/ebcdic: Move conversion tables to header file
In reply to Christian BorntraegerFrom: Heinz Graalfs <[email protected]>
Move conversion tables to header file.
- In SCLP line mode processing EBCDIC/ASCII conversion is needed.
- An additional EBCDIC to ASCII conversion function is added.
--- include/hw/s390x/ebcdic.h | 107 +++++++++++++++++++++++++++++++++++++++++++++ target-s390x/misc_helper.c | 81 +--------------------------------- 2 files changed, 108 insertions(+), 80 deletions(-) create mode 100644 include/hw/s390x/ebcdic.h
include/hw/s390x/ebcdic.h new file +107 -0
@@ -0,0 +1,107 @@ +/* +* EBCDIC/ASCII conversion Support +* +* Copyright (c) 2011 Alexander Graf +* Copyright IBM, Corp. 2013 +* +* This work is licensed under the terms of the GNU GPL, version 2 or (at your +* option) any later version. See the COPYING file in the top-level directory. +* +*/ + +#ifndef EBCDIC_H_ +#define EBCDIC_H_ + +#ifndef CONFIG_USER_ONLY + +/* EBCDIC handling */ +static const uint8_t ebcdic2ascii[] = { +0x00 ,0x01 ,0x02 ,0x03 ,0x07 ,0x09 ,0x07 ,0x7F , +0x07 ,0x07 ,0x07 ,0x0B ,0x0C ,0x0D ,0x0E ,0x0F , +0x10 ,0x11 ,0x12 ,0x13 ,0x07 ,0x0A ,0x08 ,0x07 , +0x18 ,0x19 ,0x07 ,0x07 ,0x07 ,0x07 ,0x07 ,0x07 , +0x07 ,0x07 ,0x1C ,0x07 ,0x07 ,0x0A ,0x17 ,0x1B , +0x07 ,0x07 ,0x07 ,0x07 ,0x07 ,0x05 ,0x06 ,0x07 , +0x07 ,0x07 ,0x16 ,0x07 ,0x07 ,0x07 ,0x07 ,0x04 , +0x07 ,0x07 ,0x07 ,0x07 ,0x14 ,0x15 ,0x07 ,0x1A , +0x20 ,0xFF ,0x83 ,0x84 ,0x85 ,0xA0 ,0x07 ,0x86 , +0x87 ,0xA4 ,0x5B ,0x2E ,0x3C ,0x28 ,0x2B ,0x21 , +0x26 ,0x82 ,0x88 ,0x89 ,0x8A ,0xA1 ,0x8C ,0x07 , +0x8D ,0xE1 ,0x5D ,0x24 ,0x2A ,0x29 ,0x3B ,0x5E , +0x2D ,0x2F ,0x07 ,0x8E ,0x07 ,0x07 ,0x07 ,0x8F , +0x80 ,0xA5 ,0x07 ,0x2C ,0x25 ,0x5F ,0x3E ,0x3F , +0x07 ,0x90 ,0x07 ,0x07 ,0x07 ,0x07 ,0x07 ,0x07 , +0x70 ,0x60 ,0x3A ,0x23 ,0x40 ,0x27 ,0x3D ,0x22 , +0x07 ,0x61 ,0x62 ,0x63 ,0x64 ,0x65 ,0x66 ,0x67 , +0x68 ,0x69 ,0xAE ,0xAF ,0x07 ,0x07 ,0x07 ,0xF1 , +0xF8 ,0x6A ,0x6B ,0x6C ,0x6D ,0x6E ,0x6F ,0x70 , +0x71 ,0x72 ,0xA6 ,0xA7 ,0x91 ,0x07 ,0x92 ,0x07 , +0xE6 ,0x7E ,0x73 ,0x74 ,0x75 ,0x76 ,0x77 ,0x78 , +0x79 ,0x7A ,0xAD ,0xAB ,0x07 ,0x07 ,0x07 ,0x07 , +0x9B ,0x9C ,0x9D ,0xFA ,0x07 ,0x07 ,0x07 ,0xAC , +0xAB ,0x07 ,0xAA ,0x7C ,0x07 ,0x07 ,0x07 ,0x07 , +0x7B ,0x41 ,0x42 ,0x43 ,0x44 ,0x45 ,0x46 ,0x47 , +0x48 ,0x49 ,0x07 ,0x93 ,0x94 ,0x95 ,0xA2 ,0x07 , +0x7D ,0x4A ,0x4B ,0x4C ,0x4D ,0x4E ,0x4F ,0x50 , +0x51 ,0x52 ,0x07 ,0x96 ,0x81 ,0x97 ,0xA3 ,0x98 , +0x5C ,0xF6 ,0x53 ,0x54 ,0x55 ,0x56 ,0x57 ,0x58 , +0x59 ,0x5A ,0xFD ,0x07 ,0x99 ,0x07 ,0x07 ,0x07 , +0x30 ,0x31 ,0x32 ,0x33 ,0x34 ,0x35 ,0x36 ,0x37 , +0x38 ,0x39 ,0x07 ,0x07 ,0x9A ,0x07 ,0x07 ,0x07 , +}; + +static const uint8_t ascii2ebcdic[] = { +0x00 ,0x01 ,0x02 ,0x03 ,0x37 ,0x2D ,0x2E ,0x2F , +0x16 ,0x05 ,0x15 ,0x0B ,0x0C ,0x0D ,0x0E ,0x0F , +0x10 ,0x11 ,0x12 ,0x13 ,0x3C ,0x3D ,0x32 ,0x26 , +0x18 ,0x19 ,0x3F ,0x27 ,0x22 ,0x1D ,0x1E ,0x1F , +0x40 ,0x5A ,0x7F ,0x7B ,0x5B ,0x6C ,0x50 ,0x7D , +0x4D ,0x5D ,0x5C ,0x4E ,0x6B ,0x60 ,0x4B ,0x61 , +0xF0 ,0xF1 ,0xF2 ,0xF3 ,0xF4 ,0xF5 ,0xF6 ,0xF7 , +0xF8 ,0xF9 ,0x7A ,0x5E ,0x4C ,0x7E ,0x6E ,0x6F , +0x7C ,0xC1 ,0xC2 ,0xC3 ,0xC4 ,0xC5 ,0xC6 ,0xC7 , +0xC8 ,0xC9 ,0xD1 ,0xD2 ,0xD3 ,0xD4 ,0xD5 ,0xD6 , +0xD7 ,0xD8 ,0xD9 ,0xE2 ,0xE3 ,0xE4 ,0xE5 ,0xE6 , +0xE7 ,0xE8 ,0xE9 ,0xBA ,0xE0 ,0xBB ,0xB0 ,0x6D , +0x79 ,0x81 ,0x82 ,0x83 ,0x84 ,0x85 ,0x86 ,0x87 , +0x88 ,0x89 ,0x91 ,0x92 ,0x93 ,0x94 ,0x95 ,0x96 , +0x97 ,0x98 ,0x99 ,0xA2 ,0xA3 ,0xA4 ,0xA5 ,0xA6 , +0xA7 ,0xA8 ,0xA9 ,0xC0 ,0x4F ,0xD0 ,0xA1 ,0x07 , +0x3F ,0x3F ,0x3F ,0x3F ,0x3F ,0x3F ,0x3F ,0x3F , +0x3F ,0x3F ,0x3F ,0x3F ,0x3F ,0x3F ,0x3F ,0x3F , +0x3F ,0x3F ,0x3F ,0x3F ,0x3F ,0x3F ,0x3F ,0x3F , +0x3F ,0x3F ,0x3F ,0x3F ,0x3F ,0x3F ,0x3F ,0x3F , +0x3F ,0x3F ,0x3F ,0x3F ,0x3F ,0x3F ,0x3F ,0x3F , +0x3F ,0x3F ,0x3F ,0x3F ,0x3F ,0x3F ,0x3F ,0x3F , +0x3F ,0x3F ,0x3F ,0x3F ,0x3F ,0x3F ,0x3F ,0x3F , +0x3F ,0x3F ,0x3F ,0x3F ,0x3F ,0x3F ,0x3F ,0x3F , +0x3F ,0x3F ,0x3F ,0x3F ,0x3F ,0x3F ,0x3F ,0x3F , +0x3F ,0x3F ,0x3F ,0x3F ,0x3F ,0x3F ,0x3F ,0x3F , +0x3F ,0x3F ,0x3F ,0x3F ,0x3F ,0x3F ,0x3F ,0x3F , +0x3F ,0x3F ,0x3F ,0x3F ,0x3F ,0x3F ,0x3F ,0x3F , +0x3F ,0x59 ,0x3F ,0x3F ,0x3F ,0x3F ,0x3F ,0x3F , +0x3F ,0x3F ,0x3F ,0x3F ,0x3F ,0x3F ,0x3F ,0x3F , +0x3F ,0x3F ,0x3F ,0x3F ,0x3F ,0x3F ,0x3F ,0x3F , +0x90 ,0x3F ,0x3F ,0x3F ,0x3F ,0xEA ,0x3F ,0xFF +}; + +static inline void ebcdic_put (uint8_t *p,const char *ascii,int len) +{ +int i; + +for (i =0 ; i < len; i++) { + p[i] = ascii2ebcdic[(uint8_t )ascii[i]]; + } +} + +static inline void ascii_put (uint8_t *p,const char *ebcdic,int len) +{ +int i; + +for (i =0 ; i < len; i++) { + p[i] = ebcdic2ascii[(uint8_t )ebcdic[i]]; + } +} +#endif + +#endif /* EBCDIC_H_ */
target-s390x/misc_helper.c +1 -80
93 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 10/11] s390/ebcdic: Move conversion tables to header file
Quoted 25 lines · Christian Borntraeger
From: Heinz Graalfs <[email protected]>
Move conversion tables to header file.
- In SCLP line mode processing EBCDIC/ASCII conversion is needed.
- An additional EBCDIC to ASCII conversion function is added.Signed-off-by Heinz Graalfs <[email protected]>Signed-off-by Christian Borntraeger <[email protected]>---
include/hw/s390x/ebcdic.h| 107 +++++++++++++++++++++++++++++++++++++++++++++target-s390x/misc_helper.c| 81 +---------------------------------2 files changed, 108 insertions(+), 80 deletions(-)create mode 100644
include/hw/s390x/ebcdic.hinclude/hw/s390x/ebcdic.h new file +5
-0@@ -0,0 +1,107 @@ +/* +* EBCDIC/ASCII conversion Support +* +* Copyright (c) 2011 Alexander Graf +* Copyright IBM, Corp. 2013
include/hw/s390x/ebcdic.h line 15
Quoted 10 lines
include/hw/s390x/ebcdic.h new file +10
-0+* +* This work is licensed under the terms of the GNU GPL, version 2 or (at your +* option) any later version. See the COPYING file in the top-level directory. +* +*/ + +#ifndef EBCDIC_H_ +#define EBCDIC_H_ + +#ifndef CONFIG_USER_ONLY
No need for the #ifndef. You're already in hw/ :).
Alex
PATCH 11/11 s390/sclplmconsole: Add support for SCLP line-mode console
In reply to Christian BorntraegerFrom: Heinz Graalfs <[email protected]>
Add simple support for SCLP line-mode also known as operating system messages. This can be added in addition to or instead of the SCLP full screen console with -device sclplmconsole.
--- hw/char/Makefile.objs | 2 +- hw/char/sclpconsole-lm.c | 393 ++++++++++++++++++++++++++++++++++++++ include/hw/s390x/event-facility.h | 78 ++++++++ 3 files changed, 472 insertions(+), 1 deletion(-) create mode 100644 hw/char/sclpconsole-lm.c
hw/char/Makefile.objs +1 -1
@@ -22,6 +22,6 @@ common-obj-$(CONFIG_IMX) += imx_serial.o common-obj-$(CONFIG_LM32) += lm32_juart.o common-obj-$(CONFIG_LM32) += lm32_uart.o common-obj-$(CONFIG_MILKYMIST) += milkymist-uart.o -common-obj-$(CONFIG_SCLPCONSOLE) += sclpconsole.o +common-obj-$(CONFIG_SCLPCONSOLE) += sclpconsole.o sclpconsole-lm.o obj-$(CONFIG_VIRTIO) += virtio-serial-bus.o
hw/char/sclpconsole-lm.c new file +393 -0
393 lines not on this page · raw message
include/hw/s390x/event-facility.h +78 -0
96 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 11/11] s390/sclplmconsole: Add support for SCLP line-mode console
Quoted 100 lines · Christian Borntraeger
From: Heinz Graalfs <[email protected]>
Add simple support for SCLP line-mode also known as operating system messages. This can be added in addition to or instead of the SCLP full screen console with -device sclplmconsole.
Signed-off-by Heinz Graalfs <[email protected]>Signed-off-by Christian Borntraeger <[email protected]>---
hw/char/Makefile.objs | 2 +- hw/char/sclpconsole-lm.c | 393 ++++++++++++++++++++++++++++++++++++++ include/hw/s390x/event-facility.h | 78 ++++++++ 3 files changed, 472 insertions(+), 1 deletion(-)create mode 100644
hw/char/sclpconsole-lm.chw/char/Makefile.objs +0
-0@@ -22,6 +22,6 @@ common-obj-$(CONFIG_IMX) += imx_serial.ocommon-obj-$(CONFIG_LM32) += lm32_juart.o common-obj-$(CONFIG_LM32) += lm32_uart.o common-obj-$(CONFIG_MILKYMIST) += milkymist-uart.o
hw/char/Makefile.objs +1
-1-common-obj-$(CONFIG_SCLPCONSOLE) += sclpconsole.o +common-obj-$(CONFIG_SCLPCONSOLE) += sclpconsole.o sclpconsole-lm.oobj-$(CONFIG_VIRTIO) += virtio-serial-bus.o
hw/char/sclpconsole-lm.c new file +67
-0@@ -0,0 +1,393 @@ +/* +* SCLP event types +* Operations Command - Line Mode input +* Message - Line Mode output +* +* Copyright IBM, Corp. 2013 +* +* Authors: +* Heinz Graalfs <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or (at your +* option) any later version. See the COPYING file in the top-level directory. +* +*/ + +#include "hw/qdev.h" +#include "qemu/thread.h" +#include "qemu/error-report.h" +#include "sysemu/char.h" + +#include "hw/s390x/sclp.h" +#include "hw/s390x/event-facility.h" +#include "hw/s390x/ebcdic.h" + +typedef struct OprtnsCommand { +EventBufferHeader header; +MDMSU message_unit; +char data[0 ]; +} QEMU_PACKED OprtnsCommand; + +/* max size for line-mode data in 4K SCCB page */ +#define SIZE_CONSOLE_BUFFER (SCCB_DATA_LEN - sizeof(OprtnsCommand)) + +typedef struct SCLPConsoleLM { +SCLPEvent event; +CharDriverState *chr; +bool echo;/* immediate echo of input if true */ +uint32_t write_errors;/* errors writing to char layer */ +uint32_t length;/* length of byte stream in buffer */ +uint8_t buf[SIZE_CONSOLE_BUFFER ]; +qemu_irq irq_console_read; +}SCLPConsoleLM ; + +/* +* Character layer call-back functions +* +* Allow 1 character at a time +* +* Accumulate bytes from character layer in console buffer, +* event_pending is set when a newline character is encountered +* +* The maximum command line length is limited by the maximum +* space available in an SCCB +*/ + +static int chr_can_read (void *opaque) +{ +SCLPConsoleLM *scon = opaque; + +if (scon->event.event_pending) { +return 0 ; + }else if (SIZE_CONSOLE_BUFFER - scon->length) { +return 1 ; + } +return 0 ; +} +
hw/char/sclpconsole-lm.c line 77
Quoted 10 lines
hw/char/sclpconsole-lm.c new file +10
-0+static void receive_from_chr_layer (SCLPConsoleLM *scon,const uint8_t *buf, +int size) +{ +assert (size ==1 ); + +if (*buf =='\r' || *buf =='\n' ) { + scon->event.event_pending = true; +return ; + } +memcpy (&scon->buf[scon->length], buf,1 );
Why use memcpy here?
Quoted 136 lines
hw/char/sclpconsole-lm.c new file +136
-0+ scon->length +=1 ; +if (scon->echo) { +qemu_chr_fe_write (scon->chr, buf, size); + } +} + +/* +* Send data from a char device over to the guest +*/ +static void chr_read (void *opaque,const uint8_t *buf,int size) +{ +SCLPConsoleLM *scon = opaque; + +receive_from_chr_layer (scon, buf, size); +if (scon->event.event_pending) { +/* trigger SCLP read operation */ +qemu_irq_raise (scon->irq_console_read); + } +} + +/* functions to be called by event facility */ + +static bool can_handle_event (uint8_t type) +{ +return type ==SCLP_EVENT_MESSAGE || type ==SCLP_EVENT_PMSGCMD ; +} + +static unsigned int send_mask (void ) +{ +return SCLP_EVENT_MASK_OP_CMD |SCLP_EVENT_MASK_PMSGCMD ; +} + +static unsigned int receive_mask (void ) +{ +return SCLP_EVENT_MASK_MSG |SCLP_EVENT_MASK_PMSGCMD ; +} + +/* +* Triggered by SCLP's read_event_data +* - convert ASCII byte stream to EBCDIC and +* - copy converted data into provided (SCLP) buffer +*/ +static int get_console_data (SCLPEvent *event,uint8_t *buf,size_t *size, +int avail) +{ +int len; + +SCLPConsoleLM *cons =DO_UPCAST (SCLPConsoleLM, event, event); + + len = cons->length; +/* data need to fit into provided SCLP buffer */ +if (len > avail) { +return 1 ; + } + +ebcdic_put (buf, (char *)&cons->buf, len); + *size = len; + cons->length =0 ; +/* data provided and no more data pending */ + event->event_pending = false; +return 0 ; +} + +static int read_event_data (SCLPEvent *event,EventBufferHeader *evt_buf_hdr, +int *slen) +{ +int avail, rc; +size_t src_len; +uint8_t *to; +OprtnsCommand *oc = (OprtnsCommand *) evt_buf_hdr; + +if (!event->event_pending) { +/* no data pending */ +return 0 ; + } + + to = (uint8_t *)&oc->data; + avail = *slen -sizeof (OprtnsCommand); + rc =get_console_data (event, to, &src_len, avail); +if (rc) { +/* data didn't fit, try next SCCB */ +return 1 ; + } + + oc->message_unit.mdmsu.gds_id =GDS_ID_MDSMU ; + oc->message_unit.mdmsu.length =cpu_to_be16 (sizeof (struct MDMSU )); + + oc->message_unit.cpmsu.gds_id =GDS_ID_CPMSU ; + oc->message_unit.cpmsu.length = +cpu_to_be16 (sizeof (struct MDMSU ) -sizeof (GdsVector)); + + oc->message_unit.text_command.gds_id =GDS_ID_TEXTCMD ; + oc->message_unit.text_command.length = +cpu_to_be16 (sizeof (struct MDMSU ) - (2 *sizeof (GdsVector))); + + oc->message_unit.self_def_text_message.key =GDS_KEY_SELFDEFTEXTMSG ; + oc->message_unit.self_def_text_message.length = +cpu_to_be16 (sizeof (struct MDMSU ) - (3 *sizeof (GdsVector))); + + oc->message_unit.text_message.key =GDS_KEY_TEXTMSG ; + oc->message_unit.text_message.length = +cpu_to_be16 (sizeof (GdsSubvector) + src_len); + + oc->header.length =cpu_to_be16 (sizeof (OprtnsCommand) + src_len); + oc->header.type =SCLP_EVENT_OPRTNS_COMMAND ; + *slen = avail - src_len; + +return 1 ; +} + +/* +* Triggered by SCLP's write_event_data +* - write console data to character layer +* returns < 0 if an error occurred +*/ +static int write_console_data (SCLPEvent *event,const uint8_t *buf,int len) +{ +int ret =0 ; +const uint8_t *buf_offset; + +SCLPConsoleLM *scon =DO_UPCAST (SCLPConsoleLM, event, event); + +if (!scon->chr) { +/* If there's no backend, we can just say we consumed all data. */ +return len; + } + + buf_offset = buf; +while (len >0 ) { + ret =qemu_chr_fe_write (scon->chr, buf, len); +if (ret ==0 ) { +/* a pty doesn't seem to be connected - no error */ + len =0 ; + }else if (ret == -EAGAIN || (ret >0 && ret < len)) { + len -= ret; + buf_offset += ret;
hw/char/sclpconsole-lm.c line 223
Quoted 10 lines
hw/char/sclpconsole-lm.c new file +10
-0+ }else { + len =0 ; + } + } + +return ret; +} + +#define SIZE_BUFFER 4096 +#define NEWLINE "\n"
Why are these in the middle of the file?
Quoted 38 lines
hw/char/sclpconsole-lm.c new file +38
-0+ +static int process_mdb (SCLPEvent *event,MDBO *mdbo) +{ +int rc; +int len; +uint8_t buffer[SIZE_BUFFER ]; + + len =be16_to_cpu (mdbo->length); + len -=sizeof (mdbo->length) +sizeof (mdbo->type) + +sizeof (mdbo->mto.line_type_flags) + +sizeof (mdbo->mto.alarm_control) + +sizeof (mdbo->mto._reserved); + +assert (len <=SIZE_BUFFER ); + +/* convert EBCDIC SCLP contents to ASCII console message */ +ascii_put (buffer, mdbo->mto.message, len); + rc =write_console_data (event, (uint8_t *)NEWLINE ,1 ); +if (rc <0 ) { +return rc; + } +return write_console_data (event, buffer, len); +} + +static int write_event_data (SCLPEvent *event,EventBufferHeader *ebh) +{ +int len; +int written; +int errors =0 ; +MDBO *mdbo; +SclpMsg *data = (SclpMsg *) ebh; +SCLPConsoleLM *scon =DO_UPCAST (SCLPConsoleLM, event, event); + + len =be16_to_cpu (data->mdb.header.length) -sizeof (data->mdb.header); + +/* first check message buffers */ + mdbo = data->mdb.mdbo; +while (len >0 ) {
hw/char/sclpconsole-lm.c line 271
Quoted 10 lines
hw/char/sclpconsole-lm.c new file +10
-0+if (be16_to_cpu (mdbo->length) > len + ||be16_to_cpu (mdbo->length) ==0 ) { +return SCLP_RC_INCONSISTENT_LENGTHS ; + } + len -=be16_to_cpu (mdbo->length); + mdbo = (void *) mdbo +be16_to_cpu (mdbo->length); + } + +/* then execute */ + len =be16_to_cpu (data->mdb.header.length) -sizeof (data->mdb.header);
Can this overflow?
hw/char/sclpconsole-lm.c line 275
Quoted 4 lines
hw/char/sclpconsole-lm.c new file +4
-0+ mdbo = data->mdb.mdbo; +while (len >0 ) { +switch (be16_to_cpu (mdbo->type)) { +case 4 :
What is 4? This wants to be a #define.
Quoted 54 lines
hw/char/sclpconsole-lm.c new file +54
-0+/* message text object */ + written =process_mdb (event, mdbo); +if (written <0 ) { +/* character layer error */ + errors++; + } +break ; +default :/* ignore */ +break ; + } + len -=be16_to_cpu (mdbo->length); + mdbo = (void *) mdbo +be16_to_cpu (mdbo->length); + } +if (errors) { + scon->write_errors += errors; + } + data->header.flags =SCLP_EVENT_BUFFER_ACCEPTED ; + +return SCLP_RC_NORMAL_COMPLETION ; +} + +static void trigger_console_data (void *opaque,int n,int level) +{ +sclp_service_interrupt (0 ); +} + +/* functions for live migration */ + +static const VMStateDescription vmstate_sclplmconsole = { + .name ="sclplmconsole" , + .version_id =0 , + .minimum_version_id =0 , + .minimum_version_id_old =0 , + .fields = (VMStateField []) { +VMSTATE_BOOL (event.event_pending, SCLPConsoleLM), +VMSTATE_UINT32 (write_errors, SCLPConsoleLM), +VMSTATE_UINT32 (length, SCLPConsoleLM), +VMSTATE_UINT8_ARRAY (buf, SCLPConsoleLM,SIZE_CONSOLE_BUFFER ), +VMSTATE_END_OF_LIST () + } +}; + +/* qemu object creation and initialization functions */ + +/* tell character layer our call-back functions */ + +static int console_init (SCLPEvent *event) +{ +static bool console_available; + +SCLPConsoleLM *scon =DO_UPCAST (SCLPConsoleLM, event, event); + +if (console_available) { +error_report ("Multiple line-mode operator consoles are not supported" );
hw/char/sclpconsole-lm.c line 339
Quoted 10 lines
hw/char/sclpconsole-lm.c new file +10
-0+return -1 ; + } + console_available = true; + +if (scon->chr) { +qemu_chr_add_handlers (scon->chr, chr_can_read, chr_read,NULL , scon); + } + scon->irq_console_read = *qemu_allocate_irqs (trigger_console_data,NULL ,1 ); + +return vmstate_register (NULL ,0 , &vmstate_sclplmconsole, scon);
This should go into your QOM class.
Alex
Quoted 5 lines · Christian Borntraeger
Alex,
here is a bunch of fixes/changes for sclp/eventfacility followed by a move of the ebcdic conversion into a stand-alone header file and the sclp line mode console.
Alex