Commit 5a99d777 authored by Jean-Claude BAU's avatar Jean-Claude BAU

Manage the field 'shmemState' in HAL

parent 6c4378f9
......@@ -310,6 +310,12 @@ int main(int argc, char *argv[])
// Check main timers and call callback if timeout expires
timer_scan(_timerParameters,MAIN_TIMER_COUNT);
if ( hal_shmem->shmemState== HAL_SHMEM_STATE_INITITALIZING) {
// Check if all ports have been initialized
if ( hal_port_all_ports_initialized())
hal_shmem->shmemState= HAL_SHMEM_STATE_INITITALIZED;
}
}
hal_shutdown();
......
......@@ -244,7 +244,9 @@ int hal_port_shmem_init(char *logfilename)
return -1;
}
hal_shmem = wrs_shm_alloc(hal_shmem_hdr, sizeof(*hal_shmem));
halPorts.ports = wrs_shm_alloc(hal_shmem_hdr,
hal_shmem->shmemState= HAL_SHMEM_STATE_NOT_INITITALIZED;
halPorts.ports = wrs_shm_alloc(hal_shmem_hdr,
sizeof(struct hal_port_state)
* HAL_MAX_PORTS);
if (!hal_shmem || !halPorts.ports) {
......@@ -276,6 +278,9 @@ int hal_port_shmem_init(char *logfilename)
} else
hal_shmem->read_sfp_diag = READ_SFP_DIAG_DISABLE;
hal_shmem->shmemState= HAL_SHMEM_STATE_INITITALIZING;
hal_shmem_hdr->version = HAL_SHMEM_VERSION;
/* Release processes waiting for HAL's to fill shm with correct data
When shm is opened successfully data in shm is still not populated!
......@@ -704,6 +709,21 @@ int hal_port_reset(const char *port_name)
return 0;
}
// Check if all ports are initialized
int hal_port_all_ports_initialized(void) {
struct hal_port_state *ps=halPorts.ports;
int i;
for (i = 0; i < HAL_MAX_PORTS; i++) {
if ( ps->in_use && ps->portStates.state==HAL_PORT_STATE_INIT ) {
// This port has not finished its initialization state
return 0;
}
ps++;
}
return 1;
}
void hal_port_update_info(char *iface_name, int mode, int synchronized){
int i;
......
......@@ -43,6 +43,7 @@ extern int hal_port_start_lock(const char *port_name, int priority);
extern int hal_port_enable_tracking(const char *port_name);
extern int hal_port_check_lock(const struct hal_port_state *ps);
extern int hal_port_check_lock_by_name(const char *port_name);
extern int hal_port_all_ports_initialized(void);
extern int hal_port_reset(const char *port_name);
extern int hal_port_pshifter_busy(void);
extern void hal_port_update_info(char *iface_name, int mode, int synchronized);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment