static ICSState *spapr_ics_create(sPAPRMachineState *spapr, const char *type_ics, int nr_irqs, Error **errp) { Error *local_err = NULL; Object *obj; obj = object_new(type_ics); object_property_add_child(OBJECT(spapr), "ics", obj, &error_abort); object_property_add_const_link(obj, ICS_PROP_XICS, OBJECT(spapr), &error_abort); object_property_set_int(obj, nr_irqs, "nr-irqs", &local_err); if (local_err) { goto error; } object_property_set_bool(obj, true, "realized", &local_err); if (local_err) { goto error; } return ICS_BASE(obj); error: error_propagate(errp, local_err); return NULL; }
static void ics_simple_reset(DeviceState *dev) { ICSStateClass *icsc = ICS_BASE_GET_CLASS(dev); icsc->parent_reset(dev); if (kvm_irqchip_in_kernel()) { ics_set_kvm_state(ICS_BASE(dev)); } }
static void ics_base_reset(DeviceState *dev) { ICSState *ics = ICS_BASE(dev); int i; uint8_t flags[ics->nr_irqs]; for (i = 0; i < ics->nr_irqs; i++) { flags[i] = ics->irqs[i].flags; } memset(ics->irqs, 0, sizeof(ICSIRQState) * ics->nr_irqs); for (i = 0; i < ics->nr_irqs; i++) { ics->irqs[i].priority = 0xff; ics->irqs[i].saved_priority = 0xff; ics->irqs[i].flags = flags[i]; } }
static void ics_base_realize(DeviceState *dev, Error **errp) { ICSStateClass *icsc = ICS_BASE_GET_CLASS(dev); ICSState *ics = ICS_BASE(dev); Object *obj; Error *err = NULL; obj = object_property_get_link(OBJECT(dev), "xics", &err); if (!obj) { error_setg(errp, "%s: required link 'xics' not found: %s", __func__, error_get_pretty(err)); return; } ics->xics = XICS_FABRIC(obj); if (icsc->realize) { icsc->realize(dev, errp); } }
static void ics_base_realize(DeviceState *dev, Error **errp) { ICSState *ics = ICS_BASE(dev); Object *obj; Error *err = NULL; obj = object_property_get_link(OBJECT(dev), ICS_PROP_XICS, &err); if (!obj) { error_propagate_prepend(errp, err, "required link '" ICS_PROP_XICS "' not found: "); return; } ics->xics = XICS_FABRIC(obj); if (!ics->nr_irqs) { error_setg(errp, "Number of interrupts needs to be greater 0"); return; } ics->irqs = g_malloc0(ics->nr_irqs * sizeof(ICSIRQState)); }
static void ics_base_instance_init(Object *obj) { ICSState *ics = ICS_BASE(obj); ics->offset = XICS_IRQ_BASE; }