Esempio n. 1
0
static void prop_get_fdt(Object *obj, Visitor *v, void *opaque,
                        const char *name, Error **errp)
{
    sPAPRDRConnector *drc = SPAPR_DR_CONNECTOR(obj);
    int fdt_offset_next, fdt_offset, fdt_depth;
    void *fdt;

    if (!drc->fdt) {
        return;
    }

    fdt = drc->fdt;
    fdt_offset = drc->fdt_start_offset;
    fdt_depth = 0;

    do {
        const char *name = NULL;
        const struct fdt_property *prop = NULL;
        int prop_len = 0, name_len = 0;
        uint32_t tag;

        tag = fdt_next_tag(fdt, fdt_offset, &fdt_offset_next);
        switch (tag) {
        case FDT_BEGIN_NODE:
            fdt_depth++;
            name = fdt_get_name(fdt, fdt_offset, &name_len);
            visit_start_struct(v, NULL, NULL, name, 0, NULL);
            break;
        case FDT_END_NODE:
            /* shouldn't ever see an FDT_END_NODE before FDT_BEGIN_NODE */
            g_assert(fdt_depth > 0);
            visit_end_struct(v, NULL);
            fdt_depth--;
            break;
        case FDT_PROP: {
            int i;
            prop = fdt_get_property_by_offset(fdt, fdt_offset, &prop_len);
            name = fdt_string(fdt, fdt32_to_cpu(prop->nameoff));
            visit_start_list(v, name, NULL);
            for (i = 0; i < prop_len; i++) {
                visit_type_uint8(v, (uint8_t *)&prop->data[i], NULL, NULL);

            }
            visit_end_list(v, NULL);
            break;
        }
        default:
            error_setg(&error_abort, "device FDT in unexpected state: %d", tag);
        }
        fdt_offset = fdt_offset_next;
    } while (fdt_depth != 0);
}
Esempio n. 2
0
void visit_type_PciInfoList(Visitor *m, PciInfoList ** obj, const char *name, Error **errp)
{
    GenericList *i, **head = (GenericList **)obj;

    visit_start_list(m, name, errp);

    for (*head = i = visit_next_list(m, head, errp); i; i = visit_next_list(m, &i, errp)) {
        PciInfoList *native_i = (PciInfoList *)i;
        visit_type_PciInfo(m, &native_i->value, NULL, errp);
    }

    visit_end_list(m, errp);
}
Esempio n. 3
0
void visit_type_BlockDeviceStatsList(Visitor *m, BlockDeviceStatsList ** obj, const char *name, Error **errp)
{
    GenericList *i, **head = (GenericList **)obj;

    visit_start_list(m, name, errp);

    for (*head = i = visit_next_list(m, head, errp); i; i = visit_next_list(m, &i, errp)) {
        BlockDeviceStatsList *native_i = (BlockDeviceStatsList *)i;
        visit_type_BlockDeviceStats(m, &native_i->value, NULL, errp);
    }

    visit_end_list(m, errp);
}
Esempio n. 4
0
static void visit_type_TestStructList(Visitor *m, TestStructList ** obj, const char *name, Error **errp)
{
    GenericList *i;

    visit_start_list(m, name, errp);

    for (i = visit_next_list(m, (GenericList **)obj, errp); i; i = visit_next_list(m, &i, errp)) {
        TestStructList *native_i = (TestStructList *)i;
        visit_type_TestStruct(m, &native_i->value, NULL, errp);
    }

    visit_end_list(m, errp);
}
Esempio n. 5
0
void visit_type_GuestAgentInfoList(Visitor *m, GuestAgentInfoList ** obj, const char *name, Error **errp)
{
    GenericList *i, **prev = (GenericList **)obj;
    Error *err = NULL;

    if (!error_is_set(errp)) {
        visit_start_list(m, name, &err);
        if (!err) {
            for (; (i = visit_next_list(m, prev, &err)) != NULL; prev = &i) {
                GuestAgentInfoList *native_i = (GuestAgentInfoList *)i;
                visit_type_GuestAgentInfo(m, &native_i->value, NULL, &err);
            }
            error_propagate(errp, err);
            err = NULL;

            /* Always call end_list if start_list succeeded.  */
            visit_end_list(m, &err);
        }
        error_propagate(errp, err);
    }
}