2014-01-20 23:51:50 +04:00
|
|
|
/*
|
|
|
|
* SCLP event type
|
|
|
|
* Signal CPU - Trigger SCLP interrupt for system CPU configure or
|
|
|
|
* de-configure
|
|
|
|
*
|
|
|
|
* Copyright IBM, Corp. 2013
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Thang Pham <thang.pham@us.ibm.com>
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
*/
|
2016-01-26 21:17:00 +03:00
|
|
|
#include "qemu/osdep.h"
|
2014-01-20 23:51:50 +04:00
|
|
|
#include "sysemu/sysemu.h"
|
|
|
|
#include "hw/s390x/sclp.h"
|
|
|
|
#include "hw/s390x/event-facility.h"
|
|
|
|
#include "cpu.h"
|
|
|
|
#include "sysemu/cpus.h"
|
|
|
|
|
|
|
|
typedef struct ConfigMgtData {
|
|
|
|
EventBufferHeader ebh;
|
|
|
|
uint8_t reserved;
|
|
|
|
uint8_t event_qualifier;
|
|
|
|
} QEMU_PACKED ConfigMgtData;
|
|
|
|
|
|
|
|
#define EVENT_QUAL_CPU_CHANGE 1
|
|
|
|
|
|
|
|
void raise_irq_cpu_hotplug(void)
|
|
|
|
{
|
2015-05-11 16:30:43 +03:00
|
|
|
Object *obj = object_resolve_path_type("", TYPE_SCLP_CPU_HOTPLUG, NULL);
|
|
|
|
|
|
|
|
SCLP_EVENT(obj)->event_pending = true;
|
|
|
|
|
|
|
|
/* Trigger SCLP read operation */
|
|
|
|
sclp_service_interrupt(0);
|
2014-01-20 23:51:50 +04:00
|
|
|
}
|
|
|
|
|
2018-02-23 20:42:57 +03:00
|
|
|
static sccb_mask_t send_mask(void)
|
2014-01-20 23:51:50 +04:00
|
|
|
{
|
|
|
|
return SCLP_EVENT_MASK_CONFIG_MGT_DATA;
|
|
|
|
}
|
|
|
|
|
2018-02-23 20:42:57 +03:00
|
|
|
static sccb_mask_t receive_mask(void)
|
2014-01-20 23:51:50 +04:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int read_event_data(SCLPEvent *event, EventBufferHeader *evt_buf_hdr,
|
|
|
|
int *slen)
|
|
|
|
{
|
|
|
|
ConfigMgtData *cdata = (ConfigMgtData *) evt_buf_hdr;
|
|
|
|
if (*slen < sizeof(ConfigMgtData)) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Event is no longer pending */
|
|
|
|
if (!event->event_pending) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
event->event_pending = false;
|
|
|
|
|
|
|
|
/* Event header data */
|
|
|
|
cdata->ebh.length = cpu_to_be16(sizeof(ConfigMgtData));
|
|
|
|
cdata->ebh.type = SCLP_EVENT_CONFIG_MGT_DATA;
|
|
|
|
cdata->ebh.flags |= SCLP_EVENT_BUFFER_ACCEPTED;
|
|
|
|
|
|
|
|
/* Trigger a rescan of CPUs by setting event qualifier */
|
|
|
|
cdata->event_qualifier = EVENT_QUAL_CPU_CHANGE;
|
|
|
|
*slen -= sizeof(ConfigMgtData);
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void cpu_class_init(ObjectClass *oc, void *data)
|
|
|
|
{
|
|
|
|
SCLPEventClass *k = SCLP_EVENT_CLASS(oc);
|
2015-03-17 15:44:39 +03:00
|
|
|
DeviceClass *dc = DEVICE_CLASS(oc);
|
2014-01-20 23:51:50 +04:00
|
|
|
|
|
|
|
k->get_send_mask = send_mask;
|
|
|
|
k->get_receive_mask = receive_mask;
|
|
|
|
k->read_event_data = read_event_data;
|
2015-03-17 15:44:39 +03:00
|
|
|
set_bit(DEVICE_CATEGORY_MISC, dc->categories);
|
2017-10-04 18:34:23 +03:00
|
|
|
/*
|
|
|
|
* Reason: raise_irq_cpu_hotplug() depends on an unique
|
|
|
|
* TYPE_SCLP_CPU_HOTPLUG device, which is already created
|
|
|
|
* by the sclp event facility
|
|
|
|
*/
|
|
|
|
dc->user_creatable = false;
|
2014-01-20 23:51:50 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static const TypeInfo sclp_cpu_info = {
|
2015-05-11 16:31:47 +03:00
|
|
|
.name = TYPE_SCLP_CPU_HOTPLUG,
|
2014-01-20 23:51:50 +04:00
|
|
|
.parent = TYPE_SCLP_EVENT,
|
|
|
|
.instance_size = sizeof(SCLPEvent),
|
|
|
|
.class_init = cpu_class_init,
|
|
|
|
.class_size = sizeof(SCLPEventClass),
|
|
|
|
};
|
|
|
|
|
|
|
|
static void sclp_cpu_register_types(void)
|
|
|
|
{
|
|
|
|
type_register_static(&sclp_cpu_info);
|
|
|
|
}
|
|
|
|
|
|
|
|
type_init(sclp_cpu_register_types)
|