]>
Commit | Line | Data |
---|---|---|
49204458 JH |
1 | /* |
2 | * SCLP event type | |
3 | * Signal CPU - Trigger SCLP interrupt for system CPU configure or | |
4 | * de-configure | |
5 | * | |
6 | * Copyright IBM, Corp. 2013 | |
7 | * | |
8 | * Authors: | |
9 | * Thang Pham <thang.pham@us.ibm.com> | |
10 | * | |
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. | |
13 | * | |
14 | */ | |
0b8fa32f | 15 | |
9615495a | 16 | #include "qemu/osdep.h" |
49204458 | 17 | #include "hw/s390x/sclp.h" |
0b8fa32f | 18 | #include "qemu/module.h" |
49204458 JH |
19 | #include "hw/s390x/event-facility.h" |
20 | #include "cpu.h" | |
21 | #include "sysemu/cpus.h" | |
49204458 JH |
22 | |
23 | typedef struct ConfigMgtData { | |
24 | EventBufferHeader ebh; | |
25 | uint8_t reserved; | |
26 | uint8_t event_qualifier; | |
27 | } QEMU_PACKED ConfigMgtData; | |
28 | ||
49204458 JH |
29 | #define EVENT_QUAL_CPU_CHANGE 1 |
30 | ||
31 | void raise_irq_cpu_hotplug(void) | |
32 | { | |
073f57ae DH |
33 | Object *obj = object_resolve_path_type("", TYPE_SCLP_CPU_HOTPLUG, NULL); |
34 | ||
35 | SCLP_EVENT(obj)->event_pending = true; | |
36 | ||
37 | /* Trigger SCLP read operation */ | |
38 | sclp_service_interrupt(0); | |
49204458 JH |
39 | } |
40 | ||
1ffed98f | 41 | static sccb_mask_t send_mask(void) |
49204458 JH |
42 | { |
43 | return SCLP_EVENT_MASK_CONFIG_MGT_DATA; | |
44 | } | |
45 | ||
1ffed98f | 46 | static sccb_mask_t receive_mask(void) |
49204458 JH |
47 | { |
48 | return 0; | |
49 | } | |
50 | ||
51 | static int read_event_data(SCLPEvent *event, EventBufferHeader *evt_buf_hdr, | |
52 | int *slen) | |
53 | { | |
54 | ConfigMgtData *cdata = (ConfigMgtData *) evt_buf_hdr; | |
55 | if (*slen < sizeof(ConfigMgtData)) { | |
56 | return 0; | |
57 | } | |
58 | ||
59 | /* Event is no longer pending */ | |
60 | if (!event->event_pending) { | |
61 | return 0; | |
62 | } | |
63 | event->event_pending = false; | |
64 | ||
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; | |
69 | ||
70 | /* Trigger a rescan of CPUs by setting event qualifier */ | |
71 | cdata->event_qualifier = EVENT_QUAL_CPU_CHANGE; | |
72 | *slen -= sizeof(ConfigMgtData); | |
73 | ||
74 | return 1; | |
75 | } | |
76 | ||
49204458 JH |
77 | static void cpu_class_init(ObjectClass *oc, void *data) |
78 | { | |
79 | SCLPEventClass *k = SCLP_EVENT_CLASS(oc); | |
183f6b8d | 80 | DeviceClass *dc = DEVICE_CLASS(oc); |
49204458 | 81 | |
49204458 JH |
82 | k->get_send_mask = send_mask; |
83 | k->get_receive_mask = receive_mask; | |
84 | k->read_event_data = read_event_data; | |
183f6b8d | 85 | set_bit(DEVICE_CATEGORY_MISC, dc->categories); |
7aa4d85d CH |
86 | /* |
87 | * Reason: raise_irq_cpu_hotplug() depends on an unique | |
88 | * TYPE_SCLP_CPU_HOTPLUG device, which is already created | |
89 | * by the sclp event facility | |
90 | */ | |
91 | dc->user_creatable = false; | |
49204458 JH |
92 | } |
93 | ||
94 | static const TypeInfo sclp_cpu_info = { | |
35925a7a | 95 | .name = TYPE_SCLP_CPU_HOTPLUG, |
49204458 JH |
96 | .parent = TYPE_SCLP_EVENT, |
97 | .instance_size = sizeof(SCLPEvent), | |
98 | .class_init = cpu_class_init, | |
99 | .class_size = sizeof(SCLPEventClass), | |
100 | }; | |
101 | ||
102 | static void sclp_cpu_register_types(void) | |
103 | { | |
104 | type_register_static(&sclp_cpu_info); | |
105 | } | |
106 | ||
107 | type_init(sclp_cpu_register_types) |