| 
									
										
										
										
											2011-10-16 14:38:45 +02:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * QEMU 8259 - common bits of emulated and KVM kernel model | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Copyright (c) 2003-2004 Fabrice Bellard | 
					
						
							|  |  |  |  * Copyright (c) 2011      Jan Kiszka, Siemens AG | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Permission is hereby granted, free of charge, to any person obtaining a copy | 
					
						
							|  |  |  |  * of this software and associated documentation files (the "Software"), to deal | 
					
						
							|  |  |  |  * in the Software without restriction, including without limitation the rights | 
					
						
							|  |  |  |  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | 
					
						
							|  |  |  |  * copies of the Software, and to permit persons to whom the Software is | 
					
						
							|  |  |  |  * furnished to do so, subject to the following conditions: | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * The above copyright notice and this permission notice shall be included in | 
					
						
							|  |  |  |  * all copies or substantial portions of the Software. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | 
					
						
							|  |  |  |  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | 
					
						
							|  |  |  |  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | 
					
						
							|  |  |  |  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | 
					
						
							|  |  |  |  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | 
					
						
							|  |  |  |  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | 
					
						
							|  |  |  |  * THE SOFTWARE. | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2019-08-12 07:23:45 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-26 18:17:19 +00:00
										 |  |  | #include "qemu/osdep.h"
 | 
					
						
							| 
									
										
										
										
											2019-12-12 17:15:43 +01:00
										 |  |  | #include "hw/intc/i8259.h"
 | 
					
						
							| 
									
										
										
										
											2013-02-05 17:06:20 +01:00
										 |  |  | #include "hw/isa/i8259_internal.h"
 | 
					
						
							| 
									
										
										
										
											2019-08-12 07:23:51 +02:00
										 |  |  | #include "hw/qdev-properties.h"
 | 
					
						
							| 
									
										
										
										
											2019-08-12 07:23:45 +02:00
										 |  |  | #include "migration/vmstate.h"
 | 
					
						
							| 
									
										
											  
											
												isa: Convert uses of isa_create() with Coccinelle
Replace
    dev = isa_create(bus, type_name);
    ...
    qdev_init_nofail(dev);
by
    dev = isa_new(type_name);
    ...
    isa_realize_and_unref(dev, bus, &error_fatal);
Recent commit "qdev: New qdev_new(), qdev_realize(), etc." explains
why.
Coccinelle script:
    @@
    expression dev, bus, expr;
    expression list args;
    expression d;
    @@
    -    dev = isa_create(bus, args);
    +    dev = isa_new(args);
    (
         d = &dev->qdev;
    |
         d = DEVICE(dev);
    )
         ... when != dev = expr
    -    qdev_init_nofail(d);
    +    isa_realize_and_unref(dev, bus, &error_fatal);
    @@
    expression dev, bus, expr;
    expression list args;
    @@
    -    dev = isa_create(bus, args);
    +    dev = isa_new(args);
         ... when != dev = expr
    -    qdev_init_nofail(DEVICE(dev));
    +    isa_realize_and_unref(dev, bus, &error_fatal);
    @@
    expression dev, bus, expr;
    expression list args;
    @@
    -    dev = DEVICE(isa_create(bus, args));
    +    ISADevice *isa_dev; // TODO move
    +    isa_dev = isa_new(args);
    +    dev = DEVICE(isa_dev);
         ... when != dev = expr
    -    qdev_init_nofail(dev);
    +    isa_realize_and_unref(isa_dev, bus, &error_fatal);
Missing #include "qapi/error.h" added manually, whitespace changes
minimized manually.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200610053247.1583243-20-armbru@redhat.com>
											
										 
											2020-06-10 07:32:08 +02:00
										 |  |  | #include "qapi/error.h"
 | 
					
						
							| 
									
										
										
										
											2017-12-10 14:38:17 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | static int irq_level[16]; | 
					
						
							|  |  |  | static uint64_t irq_count[16]; | 
					
						
							| 
									
										
										
										
											2011-10-16 14:38:45 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | void pic_reset_common(PICCommonState *s) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     s->last_irr = 0; | 
					
						
							| 
									
										
										
										
											2012-01-24 16:29:29 +01:00
										 |  |  |     s->irr &= s->elcr; | 
					
						
							| 
									
										
										
										
											2011-10-16 14:38:45 +02:00
										 |  |  |     s->imr = 0; | 
					
						
							|  |  |  |     s->isr = 0; | 
					
						
							|  |  |  |     s->priority_add = 0; | 
					
						
							|  |  |  |     s->irq_base = 0; | 
					
						
							|  |  |  |     s->read_reg_select = 0; | 
					
						
							|  |  |  |     s->poll = 0; | 
					
						
							|  |  |  |     s->special_mask = 0; | 
					
						
							|  |  |  |     s->init_state = 0; | 
					
						
							|  |  |  |     s->auto_eoi = 0; | 
					
						
							|  |  |  |     s->rotate_on_auto_eoi = 0; | 
					
						
							|  |  |  |     s->special_fully_nested_mode = 0; | 
					
						
							|  |  |  |     s->init4 = 0; | 
					
						
							|  |  |  |     s->single_mode = 0; | 
					
						
							| 
									
										
										
										
											2023-03-02 10:06:26 +01:00
										 |  |  |     /* Note: ELCR and LTIM are not reset */ | 
					
						
							| 
									
										
										
										
											2011-10-16 14:38:45 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-25 12:29:12 +01:00
										 |  |  | static int pic_dispatch_pre_save(void *opaque) | 
					
						
							| 
									
										
										
										
											2011-10-16 14:38:45 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     PICCommonState *s = opaque; | 
					
						
							| 
									
										
										
										
											2011-12-04 11:52:49 -06:00
										 |  |  |     PICCommonClass *info = PIC_COMMON_GET_CLASS(s); | 
					
						
							| 
									
										
										
										
											2011-10-16 14:38:45 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (info->pre_save) { | 
					
						
							|  |  |  |         info->pre_save(s); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-09-25 12:29:12 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     return 0; | 
					
						
							| 
									
										
										
										
											2011-10-16 14:38:45 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int pic_dispatch_post_load(void *opaque, int version_id) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     PICCommonState *s = opaque; | 
					
						
							| 
									
										
										
										
											2011-12-04 11:52:49 -06:00
										 |  |  |     PICCommonClass *info = PIC_COMMON_GET_CLASS(s); | 
					
						
							| 
									
										
										
										
											2011-10-16 14:38:45 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (info->post_load) { | 
					
						
							|  |  |  |         info->post_load(s); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-11-25 02:37:14 +01:00
										 |  |  | static void pic_common_realize(DeviceState *dev, Error **errp) | 
					
						
							| 
									
										
										
										
											2011-10-16 14:38:45 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2013-04-27 22:18:40 +02:00
										 |  |  |     PICCommonState *s = PIC_COMMON(dev); | 
					
						
							| 
									
										
										
										
											2016-10-02 21:44:27 +02:00
										 |  |  |     ISADevice *isa = ISA_DEVICE(dev); | 
					
						
							| 
									
										
										
										
											2011-10-16 14:38:45 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-02 21:44:27 +02:00
										 |  |  |     isa_register_ioport(isa, &s->base_io, s->iobase); | 
					
						
							| 
									
										
										
										
											2011-10-16 14:38:45 +02:00
										 |  |  |     if (s->elcr_addr != -1) { | 
					
						
							| 
									
										
										
										
											2016-10-02 21:44:27 +02:00
										 |  |  |         isa_register_ioport(isa, &s->elcr_io, s->elcr_addr); | 
					
						
							| 
									
										
										
										
											2011-10-16 14:38:45 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-11-25 02:37:14 +01:00
										 |  |  |     qdev_set_legacy_instance_id(dev, s->iobase, 1); | 
					
						
							| 
									
										
										
										
											2011-10-16 14:38:45 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ISADevice *i8259_init_chip(const char *name, ISABus *bus, bool master) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2013-06-07 13:49:13 +02:00
										 |  |  |     DeviceState *dev; | 
					
						
							|  |  |  |     ISADevice *isadev; | 
					
						
							| 
									
										
										
										
											2011-10-16 14:38:45 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												isa: Convert uses of isa_create() with Coccinelle
Replace
    dev = isa_create(bus, type_name);
    ...
    qdev_init_nofail(dev);
by
    dev = isa_new(type_name);
    ...
    isa_realize_and_unref(dev, bus, &error_fatal);
Recent commit "qdev: New qdev_new(), qdev_realize(), etc." explains
why.
Coccinelle script:
    @@
    expression dev, bus, expr;
    expression list args;
    expression d;
    @@
    -    dev = isa_create(bus, args);
    +    dev = isa_new(args);
    (
         d = &dev->qdev;
    |
         d = DEVICE(dev);
    )
         ... when != dev = expr
    -    qdev_init_nofail(d);
    +    isa_realize_and_unref(dev, bus, &error_fatal);
    @@
    expression dev, bus, expr;
    expression list args;
    @@
    -    dev = isa_create(bus, args);
    +    dev = isa_new(args);
         ... when != dev = expr
    -    qdev_init_nofail(DEVICE(dev));
    +    isa_realize_and_unref(dev, bus, &error_fatal);
    @@
    expression dev, bus, expr;
    expression list args;
    @@
    -    dev = DEVICE(isa_create(bus, args));
    +    ISADevice *isa_dev; // TODO move
    +    isa_dev = isa_new(args);
    +    dev = DEVICE(isa_dev);
         ... when != dev = expr
    -    qdev_init_nofail(dev);
    +    isa_realize_and_unref(isa_dev, bus, &error_fatal);
Missing #include "qapi/error.h" added manually, whitespace changes
minimized manually.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200610053247.1583243-20-armbru@redhat.com>
											
										 
											2020-06-10 07:32:08 +02:00
										 |  |  |     isadev = isa_new(name); | 
					
						
							| 
									
										
										
										
											2013-06-07 13:49:13 +02:00
										 |  |  |     dev = DEVICE(isadev); | 
					
						
							|  |  |  |     qdev_prop_set_uint32(dev, "iobase", master ? 0x20 : 0xa0); | 
					
						
							|  |  |  |     qdev_prop_set_uint32(dev, "elcr_addr", master ? 0x4d0 : 0x4d1); | 
					
						
							|  |  |  |     qdev_prop_set_uint8(dev, "elcr_mask", master ? 0xf8 : 0xde); | 
					
						
							|  |  |  |     qdev_prop_set_bit(dev, "master", master); | 
					
						
							| 
									
										
											  
											
												isa: Convert uses of isa_create() with Coccinelle
Replace
    dev = isa_create(bus, type_name);
    ...
    qdev_init_nofail(dev);
by
    dev = isa_new(type_name);
    ...
    isa_realize_and_unref(dev, bus, &error_fatal);
Recent commit "qdev: New qdev_new(), qdev_realize(), etc." explains
why.
Coccinelle script:
    @@
    expression dev, bus, expr;
    expression list args;
    expression d;
    @@
    -    dev = isa_create(bus, args);
    +    dev = isa_new(args);
    (
         d = &dev->qdev;
    |
         d = DEVICE(dev);
    )
         ... when != dev = expr
    -    qdev_init_nofail(d);
    +    isa_realize_and_unref(dev, bus, &error_fatal);
    @@
    expression dev, bus, expr;
    expression list args;
    @@
    -    dev = isa_create(bus, args);
    +    dev = isa_new(args);
         ... when != dev = expr
    -    qdev_init_nofail(DEVICE(dev));
    +    isa_realize_and_unref(dev, bus, &error_fatal);
    @@
    expression dev, bus, expr;
    expression list args;
    @@
    -    dev = DEVICE(isa_create(bus, args));
    +    ISADevice *isa_dev; // TODO move
    +    isa_dev = isa_new(args);
    +    dev = DEVICE(isa_dev);
         ... when != dev = expr
    -    qdev_init_nofail(dev);
    +    isa_realize_and_unref(isa_dev, bus, &error_fatal);
Missing #include "qapi/error.h" added manually, whitespace changes
minimized manually.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200610053247.1583243-20-armbru@redhat.com>
											
										 
											2020-06-10 07:32:08 +02:00
										 |  |  |     isa_realize_and_unref(isadev, bus, &error_fatal); | 
					
						
							| 
									
										
										
										
											2011-10-16 14:38:45 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-06-07 13:49:13 +02:00
										 |  |  |     return isadev; | 
					
						
							| 
									
										
										
										
											2011-10-16 14:38:45 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-10 14:38:17 +08:00
										 |  |  | void pic_stat_update_irq(int irq, int level) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (level != irq_level[irq]) { | 
					
						
							|  |  |  |         irq_level[irq] = level; | 
					
						
							|  |  |  |         if (level == 1) { | 
					
						
							|  |  |  |             irq_count[irq]++; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-16 13:23:26 +01:00
										 |  |  | static bool pic_get_statistics(InterruptStatsProvider *obj, | 
					
						
							|  |  |  |                                uint64_t **irq_counts, unsigned int *nb_irqs) | 
					
						
							| 
									
										
										
										
											2017-12-10 14:38:17 +08:00
										 |  |  | { | 
					
						
							|  |  |  |     PICCommonState *s = PIC_COMMON(obj); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (s->master) { | 
					
						
							|  |  |  |         *irq_counts = irq_count; | 
					
						
							|  |  |  |         *nb_irqs = ARRAY_SIZE(irq_count); | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         *irq_counts = NULL; | 
					
						
							|  |  |  |         *nb_irqs = 0; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return true; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-06-07 12:47:04 +02:00
										 |  |  | static void pic_print_info(InterruptStatsProvider *obj, GString *buf) | 
					
						
							| 
									
										
										
										
											2017-12-10 14:38:17 +08:00
										 |  |  | { | 
					
						
							|  |  |  |     PICCommonState *s = PIC_COMMON(obj); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-10 14:38:18 +08:00
										 |  |  |     pic_dispatch_pre_save(s); | 
					
						
							| 
									
										
										
										
											2024-06-07 12:47:04 +02:00
										 |  |  |     g_string_append_printf(buf, "pic%d: irr=%02x imr=%02x isr=%02x hprio=%d " | 
					
						
							|  |  |  |                            "irq_base=%02x rr_sel=%d elcr=%02x fnm=%d\n", | 
					
						
							|  |  |  |                            s->master ? 0 : 1, s->irr, s->imr, s->isr, | 
					
						
							|  |  |  |                            s->priority_add, | 
					
						
							|  |  |  |                            s->irq_base, s->read_reg_select, s->elcr, | 
					
						
							|  |  |  |                            s->special_fully_nested_mode); | 
					
						
							| 
									
										
										
										
											2017-12-10 14:38:17 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-02 10:06:26 +01:00
										 |  |  | static bool ltim_state_needed(void *opaque) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     PICCommonState *s = PIC_COMMON(opaque); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return !!s->ltim; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static const VMStateDescription vmstate_pic_ltim = { | 
					
						
							|  |  |  |     .name = "i8259/ltim", | 
					
						
							|  |  |  |     .version_id = 1, | 
					
						
							|  |  |  |     .minimum_version_id = 1, | 
					
						
							|  |  |  |     .needed = ltim_state_needed, | 
					
						
							| 
									
										
										
										
											2023-12-21 14:16:15 +11:00
										 |  |  |     .fields = (const VMStateField[]) { | 
					
						
							| 
									
										
										
										
											2023-03-02 10:06:26 +01:00
										 |  |  |         VMSTATE_UINT8(ltim, PICCommonState), | 
					
						
							|  |  |  |         VMSTATE_END_OF_LIST() | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-16 14:38:45 +02:00
										 |  |  | static const VMStateDescription vmstate_pic_common = { | 
					
						
							|  |  |  |     .name = "i8259", | 
					
						
							|  |  |  |     .version_id = 1, | 
					
						
							|  |  |  |     .minimum_version_id = 1, | 
					
						
							|  |  |  |     .pre_save = pic_dispatch_pre_save, | 
					
						
							|  |  |  |     .post_load = pic_dispatch_post_load, | 
					
						
							| 
									
										
										
										
											2023-12-21 14:16:15 +11:00
										 |  |  |     .fields = (const VMStateField[]) { | 
					
						
							| 
									
										
										
										
											2011-10-16 14:38:45 +02:00
										 |  |  |         VMSTATE_UINT8(last_irr, PICCommonState), | 
					
						
							|  |  |  |         VMSTATE_UINT8(irr, PICCommonState), | 
					
						
							|  |  |  |         VMSTATE_UINT8(imr, PICCommonState), | 
					
						
							|  |  |  |         VMSTATE_UINT8(isr, PICCommonState), | 
					
						
							|  |  |  |         VMSTATE_UINT8(priority_add, PICCommonState), | 
					
						
							|  |  |  |         VMSTATE_UINT8(irq_base, PICCommonState), | 
					
						
							|  |  |  |         VMSTATE_UINT8(read_reg_select, PICCommonState), | 
					
						
							|  |  |  |         VMSTATE_UINT8(poll, PICCommonState), | 
					
						
							|  |  |  |         VMSTATE_UINT8(special_mask, PICCommonState), | 
					
						
							|  |  |  |         VMSTATE_UINT8(init_state, PICCommonState), | 
					
						
							|  |  |  |         VMSTATE_UINT8(auto_eoi, PICCommonState), | 
					
						
							|  |  |  |         VMSTATE_UINT8(rotate_on_auto_eoi, PICCommonState), | 
					
						
							|  |  |  |         VMSTATE_UINT8(special_fully_nested_mode, PICCommonState), | 
					
						
							|  |  |  |         VMSTATE_UINT8(init4, PICCommonState), | 
					
						
							|  |  |  |         VMSTATE_UINT8(single_mode, PICCommonState), | 
					
						
							|  |  |  |         VMSTATE_UINT8(elcr, PICCommonState), | 
					
						
							|  |  |  |         VMSTATE_END_OF_LIST() | 
					
						
							| 
									
										
										
										
											2023-03-02 10:06:26 +01:00
										 |  |  |     }, | 
					
						
							| 
									
										
										
										
											2023-12-21 14:16:15 +11:00
										 |  |  |     .subsections = (const VMStateDescription * const []) { | 
					
						
							| 
									
										
										
										
											2023-03-02 10:06:26 +01:00
										 |  |  |         &vmstate_pic_ltim, | 
					
						
							|  |  |  |         NULL | 
					
						
							| 
									
										
										
										
											2011-10-16 14:38:45 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static Property pic_properties_common[] = { | 
					
						
							| 
									
										
										
										
											2014-02-08 11:01:53 +01:00
										 |  |  |     DEFINE_PROP_UINT32("iobase", PICCommonState, iobase,  -1), | 
					
						
							|  |  |  |     DEFINE_PROP_UINT32("elcr_addr", PICCommonState, elcr_addr,  -1), | 
					
						
							|  |  |  |     DEFINE_PROP_UINT8("elcr_mask", PICCommonState, elcr_mask,  -1), | 
					
						
							| 
									
										
										
										
											2011-10-16 14:38:45 +02:00
										 |  |  |     DEFINE_PROP_BIT("master", PICCommonState, master,  0, false), | 
					
						
							|  |  |  |     DEFINE_PROP_END_OF_LIST(), | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-12-04 11:52:49 -06:00
										 |  |  | static void pic_common_class_init(ObjectClass *klass, void *data) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2011-12-07 21:34:16 -06:00
										 |  |  |     DeviceClass *dc = DEVICE_CLASS(klass); | 
					
						
							| 
									
										
										
										
											2017-12-10 14:38:19 +08:00
										 |  |  |     InterruptStatsProviderClass *ic = INTERRUPT_STATS_PROVIDER_CLASS(klass); | 
					
						
							| 
									
										
										
										
											2011-12-04 11:52:49 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-12-07 21:34:16 -06:00
										 |  |  |     dc->vmsd = &vmstate_pic_common; | 
					
						
							| 
									
										
										
										
											2020-01-10 19:30:32 +04:00
										 |  |  |     device_class_set_props(dc, pic_properties_common); | 
					
						
							| 
									
										
										
										
											2012-11-25 02:37:14 +01:00
										 |  |  |     dc->realize = pic_common_realize; | 
					
						
							| 
									
										
										
										
											2013-11-28 17:27:02 +01:00
										 |  |  |     /*
 | 
					
						
							|  |  |  |      * Reason: unlike ordinary ISA devices, the PICs need additional | 
					
						
							|  |  |  |      * wiring: its IRQ input lines are set up by board code, and the | 
					
						
							|  |  |  |      * wiring of the slave to the master is hard-coded in device model | 
					
						
							|  |  |  |      * code. | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2017-05-03 17:35:44 -03:00
										 |  |  |     dc->user_creatable = false; | 
					
						
							| 
									
										
										
										
											2017-12-10 14:38:19 +08:00
										 |  |  |     ic->get_statistics = pic_get_statistics; | 
					
						
							|  |  |  |     ic->print_info = pic_print_info; | 
					
						
							| 
									
										
										
										
											2011-12-04 11:52:49 -06:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-01-10 16:19:07 +01:00
										 |  |  | static const TypeInfo pic_common_type = { | 
					
						
							| 
									
										
										
										
											2011-12-04 11:52:49 -06:00
										 |  |  |     .name = TYPE_PIC_COMMON, | 
					
						
							|  |  |  |     .parent = TYPE_ISA_DEVICE, | 
					
						
							|  |  |  |     .instance_size = sizeof(PICCommonState), | 
					
						
							|  |  |  |     .class_size = sizeof(PICCommonClass), | 
					
						
							|  |  |  |     .class_init = pic_common_class_init, | 
					
						
							|  |  |  |     .abstract = true, | 
					
						
							| 
									
										
										
										
											2017-12-10 14:38:19 +08:00
										 |  |  |     .interfaces = (InterfaceInfo[]) { | 
					
						
							|  |  |  |         { TYPE_INTERRUPT_STATS_PROVIDER }, | 
					
						
							|  |  |  |         { } | 
					
						
							|  |  |  |     }, | 
					
						
							| 
									
										
										
										
											2011-12-04 11:52:49 -06:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-27 22:18:40 +02:00
										 |  |  | static void pic_common_register_types(void) | 
					
						
							| 
									
										
										
										
											2011-12-04 11:52:49 -06:00
										 |  |  | { | 
					
						
							|  |  |  |     type_register_static(&pic_common_type); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-27 22:18:40 +02:00
										 |  |  | type_init(pic_common_register_types) |