3 * Signal CPU - Trigger SCLP interrupt for system CPU configure or
6 * Copyright IBM, Corp. 2013
9 * Thang Pham <thang.pham@us.ibm.com>
11 * This work is licensed under the terms of the GNU GPL, version 2 or (at your
12 * option) any later version. See the COPYING file in the top-level directory.
15 #include "qemu/osdep.h"
16 #include "sysemu/sysemu.h"
17 #include "hw/s390x/sclp.h"
18 #include "hw/s390x/event-facility.h"
20 #include "sysemu/cpus.h"
21 #include "sysemu/kvm.h"
23 typedef struct ConfigMgtData
{
24 EventBufferHeader ebh
;
26 uint8_t event_qualifier
;
27 } QEMU_PACKED ConfigMgtData
;
29 #define EVENT_QUAL_CPU_CHANGE 1
31 void raise_irq_cpu_hotplug(void)
33 Object
*obj
= object_resolve_path_type("", TYPE_SCLP_CPU_HOTPLUG
, NULL
);
35 SCLP_EVENT(obj
)->event_pending
= true;
37 /* Trigger SCLP read operation */
38 sclp_service_interrupt(0);
41 static unsigned int send_mask(void)
43 return SCLP_EVENT_MASK_CONFIG_MGT_DATA
;
46 static unsigned int receive_mask(void)
51 static int read_event_data(SCLPEvent
*event
, EventBufferHeader
*evt_buf_hdr
,
54 ConfigMgtData
*cdata
= (ConfigMgtData
*) evt_buf_hdr
;
55 if (*slen
< sizeof(ConfigMgtData
)) {
59 /* Event is no longer pending */
60 if (!event
->event_pending
) {
63 event
->event_pending
= false;
65 /* Event header data */
66 cdata
->ebh
.length
= cpu_to_be16(sizeof(ConfigMgtData
));
67 cdata
->ebh
.type
= SCLP_EVENT_CONFIG_MGT_DATA
;
68 cdata
->ebh
.flags
|= SCLP_EVENT_BUFFER_ACCEPTED
;
70 /* Trigger a rescan of CPUs by setting event qualifier */
71 cdata
->event_qualifier
= EVENT_QUAL_CPU_CHANGE
;
72 *slen
-= sizeof(ConfigMgtData
);
77 static void cpu_class_init(ObjectClass
*oc
, void *data
)
79 SCLPEventClass
*k
= SCLP_EVENT_CLASS(oc
);
80 DeviceClass
*dc
= DEVICE_CLASS(oc
);
82 k
->get_send_mask
= send_mask
;
83 k
->get_receive_mask
= receive_mask
;
84 k
->read_event_data
= read_event_data
;
85 set_bit(DEVICE_CATEGORY_MISC
, dc
->categories
);
88 static const TypeInfo sclp_cpu_info
= {
89 .name
= TYPE_SCLP_CPU_HOTPLUG
,
90 .parent
= TYPE_SCLP_EVENT
,
91 .instance_size
= sizeof(SCLPEvent
),
92 .class_init
= cpu_class_init
,
93 .class_size
= sizeof(SCLPEventClass
),
96 static void sclp_cpu_register_types(void)
98 type_register_static(&sclp_cpu_info
);
101 type_init(sclp_cpu_register_types
)