void hw_init_runtime_properties (SIM_DESC sd, struct hw *me, void *data) { struct hw_property_data *property; for (property = me->properties_of_hw; property != NULL; property = property->next) { switch (property->property->disposition) { case permenant_object: switch (property->property->type) { #if 0 case ihandle_property: { struct hw_instance *ihandle; ihandle_runtime_property_spec spec; ASSERT (property->init_array != NULL); ASSERT (property->property->array == NULL); hw_find_ihandle_runtime_property (me, property->property->name, &spec); ihandle = tree_instance (me, spec.full_path); hw_set_ihandle_property (me, property->property->name, ihandle); break; } #endif case array_property: case boolean_property: case range_array_property: case integer_property: case reg_array_property: case string_property: case string_array_property: ASSERT (property->init_array != NULL); ASSERT (property->property->array != NULL); break; } break; case temporary_object: ASSERT (property->init_array == NULL); ASSERT (property->property->array != NULL); break; } } }
static void hw_data_init_data_callback(device *me) { unsigned_word addr = device_find_integer_property(me, "real-address"); const device_property *data = device_find_property(me, "data"); const char *instance_spec = (device_find_property(me, "instance") != NULL ? device_find_string_property(me, "instance") : NULL); device_instance *instance = NULL; if (data == NULL) device_error(me, "missing property <data>\n"); if (instance_spec != NULL) instance = tree_instance(me, instance_spec); switch (data->type) { case integer_property: { unsigned_cell buf = device_find_integer_property(me, "data"); H2T(buf); if (instance == NULL) { if (device_dma_write_buffer(device_parent(me), &buf, 0 /*address-space*/, addr, sizeof(buf), /*nr-bytes*/ 1 /*violate ro*/) != sizeof(buf)) device_error(me, "Problem storing integer 0x%x at 0x%lx\n", (unsigned)buf, (unsigned long)addr); } else { if (device_instance_seek(instance, 0, addr) < 0 || device_instance_write(instance, &buf, sizeof(buf)) != sizeof(buf)) device_error(me, "Problem storing integer 0x%x at 0x%lx of instance %s\n", (unsigned)buf, (unsigned long)addr, instance_spec); } } break; default: device_error(me, "Write of this data is not yet implemented\n"); break; } if (instance != NULL) device_instance_delete(instance); }