The new hal.get_realtime_type() is not necessarily initialized when HAL is loaded.
In the uspace case, if the HAL memory segment is initiated by a user-space program, then init_hal_data() will simply set it to uninitialized. In uspace, will hal_lib's rtapi_app_main() ever be called? Not to my knowledge because it is not a kernel module or loaded module, but simply a linked library. In uspace, the shared memory segment is mapped/created when hal_init() is called (i.e. create a component) and that does the call to init_hal_data(). However, it never sets the hal_data->realtime_type member to the actual RT type.
This path was discovered when taking out the mapping of the HAL memory from hal_init() into a hal_lib_init() function. The reason for this is that many halmodule functions, like getting and setting named pins, parameter and signals, do not need a component. They only need a mapping of the HAL segment. Therefore, you can call hal_lib_init() when the module is imported and skip a lot of suddenly needless memory existence tests in all the functions.
@hdiethelm @grandixximo any comments on this?
The new
hal.get_realtime_type()is not necessarily initialized when HAL is loaded.In the uspace case, if the HAL memory segment is initiated by a user-space program, then
init_hal_data()will simply set it to uninitialized. In uspace, will hal_lib's rtapi_app_main() ever be called? Not to my knowledge because it is not a kernel module or loaded module, but simply a linked library. In uspace, the shared memory segment is mapped/created when hal_init() is called (i.e. create a component) and that does the call toinit_hal_data(). However, it never sets thehal_data->realtime_typemember to the actual RT type.This path was discovered when taking out the mapping of the HAL memory from
hal_init()into ahal_lib_init()function. The reason for this is that many halmodule functions, like getting and setting named pins, parameter and signals, do not need a component. They only need a mapping of the HAL segment. Therefore, you can call hal_lib_init() when the module is imported and skip a lot of suddenly needless memory existence tests in all the functions.@hdiethelm @grandixximo any comments on this?