User manual

94
To perform the operation, the initiator invokes a routine identified by the add_config_option
field of the chapi_in descriptor. The initiator provides in the opt_name parameter the name
of configuration option to create, in the opt_type parameter the type of configuration option
to create (option_type_integer, option_type_boolean and option_type_string types are
supported), in the opt_vals_count the number of values in the option, in the opt_buffer
parameter the pointer to address where option value should be stored, and in opt_size
parameter the size of single option value. The size of whole storage, supplied in opt_buffer
is calculated as opt_vals_count * opt_size. The procedure is invoked as follows:
// Define option storage somewhere in loadable component implementation
int my_int_opt;
bool my_bool_opt[3];
char my_str_opt[256];
const chapi_in * ci = …;
if (ci->add_config_option) {
// Add scalar integer option
ci->add_config_option(ci, “int_opt”, option_type_integer, 1, &my_int_opt,
sizeof(my_int_opt));
// Add boolean option with three values
ci->add_config_option(ci, “bool_opt”, option_type_boolean, 3,
&my_bool_opt, sizeof(my_bool_opt));
// Add scalar string option
ci->add_config_option(ci, “str_opt”, option_type_string, 1,
&my_str_opt[0], sizeof(my_str_opt));
}
The example above shows that the CHARON core is not obliged to support the indicated
operation. It indicates why the device instance must remember the chapi_in descriptor. The
valid place to call described operation is loadable device initialization routine. Created
configuration options become available in configuration file (see 4.20.2 for example).
4.19.2 Setting option value
Setting option value belongs to the “A request to process loadable component defined
configuration options” class of operations. Such an operation is initiated by the device
instance. The CHARON core is defined as a target of the operation.
To perform the operation, the initiator invokes a routine identified by the set_option_value
field of the chapi_in descriptor. The initiator provides in the opt_name parameter the name
of configuration option to set, in the opt_val_idx the index of option value to set (from 0 to
opt_vals_count - 1) and in the val parameter the address of buffer where the option value to
set is located. The procedure is invoked as follows assuming that described in the
previous chapter options are added during the loadable module initialization:
// Define option storage somewhere in loadable component implementation
int my_int_opt;
bool my_bool_opt[3];
char my_str_opt[256];