static void ts_register(conf_class_t *ts_class) { SIM_register_typed_attribute( ts_class, "next-cache-line-size", get_nc_line_size, 0, set_nc_line_size, 0, Sim_Attr_Required, "i", NULL, "Cache line size used for splitting " "transactions."); SIM_register_typed_attribute( ts_class, "cache", get_cache, 0, set_cache, 0, Sim_Attr_Required, "o|n", NULL, "Cache to which the splitter is connected"); SIM_register_typed_attribute( ts_class, "transactions", get_transactions, 0, set_transactions, 0, Sim_Attr_Optional, "i", NULL, "Total number of transactions processed."); SIM_register_typed_attribute( ts_class, "split-transactions", get_split_transactions, 0, set_split_transactions, 0, Sim_Attr_Optional, "i", NULL, "Number of transactions split."); SIM_register_typed_attribute( ts_class, "timing-model", get_timing_model, 0, set_timing_model, 0, Sim_Attr_Required, "o|n", NULL, "Object listening on transactions coming from " "the splitter."); }
/* * init_local() is called once when the device module is loaded into Simics. */ void init_local(void) { class_data_t funcs; conf_class_t *sample_class; sample_interface_t *sample_interface; io_memory_interface_t *memory_interface; /* * Register the sample device class. The 'sample_new_instance' * function serve as a constructor, and is called every time * a new instance is created. */ memset(&funcs, 0, sizeof(class_data_t)); funcs.new_instance = sample_new_instance; funcs.description = "The sample-device device is a dummy device that compiles and " "that can be loaded into Simics. Using it as a starting point " "when writing own devices for Simics is encouraged. Several " "device specific functions are included. The source is " "included in <tt>simics/src/devices/sample-device</tt>."; sample_class = SIM_register_class(DEVICE_NAME, &funcs); /* * Register the 'sample-interface', which is an example * of a unique, customized interface that we've implemented * for this device. */ sample_interface = MM_ZALLOC(1, sample_interface_t); sample_interface->simple_function = simple_function; SIM_register_interface(sample_class, "sample_interface", sample_interface); /* * Register the 'io-memory' interface, which is an example * of a generic interface that is implemented by a large * number of devices. */ memory_interface = MM_ZALLOC(1, io_memory_interface_t); memory_interface->operation = sample_operation; SIM_register_interface(sample_class, IO_MEMORY_INTERFACE, memory_interface); /* * Register attributes (device specific data) together with * functions for getting and setting these attributes. * The 'Sim_Attr_Optional' attribute will be saved with a configuration */ SIM_register_typed_attribute( sample_class, "value", get_value_attribute, NULL, set_value_attribute, NULL, Sim_Attr_Optional, "i", NULL, "The <i>value</i> field."); /* Pseudo attribute, not saved in configuration */ SIM_register_typed_attribute( sample_class, "add_log", 0, NULL, set_add_log_attribute, NULL, Sim_Attr_Pseudo, "s", NULL, "<i>Write-only</i>. Strings written to this " "attribute will end up in the device's log file."); /* Example of attribute using indexing */ SIM_register_typed_attribute( sample_class, "range_sum", get_range_sum_attribute, NULL, 0, NULL, (attr_attr_t)(Sim_Attr_Pseudo | Sim_Attr_List_Indexed), "i", "i", "<i>Read-only</i>. When read from index <tt>[<i>i0</i>, " "<i>i1</i>]</tt>, the sum of the integers between " "<tt><i>i0</i></tt> and <tt><i>i1</i></tt> will " "be returned."); }