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 "sysemu/sysemu.h"
16 #include "hw/s390x/sclp.h"
17 #include "hw/s390x/event-facility.h"
19 #include "sysemu/cpus.h"
20 #include "sysemu/kvm.h"
22 typedef struct ConfigMgtData
{
23 EventBufferHeader ebh
;
25 uint8_t event_qualifier
;
26 } QEMU_PACKED ConfigMgtData
;
28 #define EVENT_QUAL_CPU_CHANGE 1
30 void raise_irq_cpu_hotplug(void)
32 Object
*obj
= object_resolve_path_type("", TYPE_SCLP_CPU_HOTPLUG
, NULL
);
34 SCLP_EVENT(obj
)->event_pending
= true;
36 /* Trigger SCLP read operation */
37 sclp_service_interrupt(0);
40 static unsigned int send_mask(void)
42 return SCLP_EVENT_MASK_CONFIG_MGT_DATA
;
45 static unsigned int receive_mask(void)
50 static int read_event_data(SCLPEvent
*event
, EventBufferHeader
*evt_buf_hdr
,
53 ConfigMgtData
*cdata
= (ConfigMgtData
*) evt_buf_hdr
;
54 if (*slen
< sizeof(ConfigMgtData
)) {
58 /* Event is no longer pending */
59 if (!event
->event_pending
) {
62 event
->event_pending
= false;
64 /* Event header data */
65 cdata
->ebh
.length
= cpu_to_be16(sizeof(ConfigMgtData
));
66 cdata
->ebh
.type
= SCLP_EVENT_CONFIG_MGT_DATA
;
67 cdata
->ebh
.flags
|= SCLP_EVENT_BUFFER_ACCEPTED
;
69 /* Trigger a rescan of CPUs by setting event qualifier */
70 cdata
->event_qualifier
= EVENT_QUAL_CPU_CHANGE
;
71 *slen
-= sizeof(ConfigMgtData
);
76 static void cpu_class_init(ObjectClass
*oc
, void *data
)
78 SCLPEventClass
*k
= SCLP_EVENT_CLASS(oc
);
79 DeviceClass
*dc
= DEVICE_CLASS(oc
);
81 k
->get_send_mask
= send_mask
;
82 k
->get_receive_mask
= receive_mask
;
83 k
->read_event_data
= read_event_data
;
84 set_bit(DEVICE_CATEGORY_MISC
, dc
->categories
);
87 static const TypeInfo sclp_cpu_info
= {
88 .name
= TYPE_SCLP_CPU_HOTPLUG
,
89 .parent
= TYPE_SCLP_EVENT
,
90 .instance_size
= sizeof(SCLPEvent
),
91 .class_init
= cpu_class_init
,
92 .class_size
= sizeof(SCLPEventClass
),
95 static void sclp_cpu_register_types(void)
97 type_register_static(&sclp_cpu_info
);
100 type_init(sclp_cpu_register_types
)