diff --git a/userspace/wrsw_hal/hal_main.c b/userspace/wrsw_hal/hal_main.c index cfe7c851f91031bdff682a71b7e327a2c6b2ef76..157b725a3bc8728dd072779b048dda7f40b5c710 100644 --- a/userspace/wrsw_hal/hal_main.c +++ b/userspace/wrsw_hal/hal_main.c @@ -110,10 +110,16 @@ static int hal_init(void) /* Low-level hw init, init non-kernel drivers */ assert_init(shw_init()); + /* read timing mode from dot-config */ + assert_init(hal_init_timing_mode()); + + /* Initialize HAL's shmem - see hal_ports.c */ + assert_init(hal_port_init_shmem(logfilename)); + assert_init(hal_init_timing(logfilename)); - /* Initialize port FSMs and IPC/RPC - see hal_ports.c */ - assert_init(hal_port_init_all(logfilename)); + /* Initialize IPC/RPC - see hal_ports.c */ + assert_init(hal_port_init_wripc(logfilename)); //everything is fine up to here, we can blink green LED shw_io_write(shw_io_led_state_o, 0); diff --git a/userspace/wrsw_hal/hal_ports.c b/userspace/wrsw_hal/hal_ports.c index 0de74efc0c06b49cff39ff102d43f17fb44597cd..b729d7ca3d84e7112fc7d2c0fd840dd405e02d2b 100644 --- a/userspace/wrsw_hal/hal_ports.c +++ b/userspace/wrsw_hal/hal_ports.c @@ -198,7 +198,7 @@ static int hal_port_init(int index) /* Interates via all the ports defined in the config file and * intializes them one after another. */ -int hal_port_init_all(char *logfilename) +int hal_port_init_shmem(char *logfilename) { int index; struct wrs_shm_head *hal_shmem_hdr; @@ -253,10 +253,13 @@ int hal_port_init_all(char *logfilename) Especially for nports it is important */ wrs_shm_write(hal_shmem_hdr, WRS_SHM_WRITE_END); + return 0; +} + +int hal_port_init_wripc(char *logfilename) +{ /* Create a WRIPC server for HAL public API */ return hal_init_wripc(ports, logfilename); - - return 0; } /* Checks if the link is up on inteface (if_name). Returns non-zero if yes. */ diff --git a/userspace/wrsw_hal/hal_timing.c b/userspace/wrsw_hal/hal_timing.c index ee56507223a737badb8bff13ba701f9e1fc5fef6..07396c4c4fafe0b29dc91880513e0562bf6b128f 100644 --- a/userspace/wrsw_hal/hal_timing.c +++ b/userspace/wrsw_hal/hal_timing.c @@ -20,9 +20,8 @@ static int timing_mode; #define LOCK_TIMEOUT_EXT 60000 #define LOCK_TIMEOUT_INT 10000 -int hal_init_timing(char *filename) +int hal_init_timing_mode(void) { - timeout_t lock_tmo; static struct { char *cfgname; int modevalue; @@ -39,6 +38,7 @@ int hal_init_timing(char *filename) return -1; } + /* Read the mode from dot-config */ for (m = modes; m->cfgname; m++) if (libwr_cfg_get(m->cfgname)) break; @@ -47,7 +47,12 @@ int hal_init_timing(char *filename) if (!m->cfgname) pr_error("%s: no config variable set, defaults used\n", __func__); + return 0; +} +int hal_init_timing(char *filename) +{ + timeout_t lock_tmo; /* initialize the RT Subsys */ switch (timing_mode) { case HAL_TIMING_MODE_GRAND_MASTER: diff --git a/userspace/wrsw_hal/wrsw_hal.h b/userspace/wrsw_hal/wrsw_hal.h index 105da2a958b4d05955a226d2962f4a470898fcb2..b9a84c7ec2f63545a884255cb2f78fdd535b1d79 100644 --- a/userspace/wrsw_hal/wrsw_hal.h +++ b/userspace/wrsw_hal/wrsw_hal.h @@ -16,7 +16,8 @@ int hal_config_get_string(const char *name, char *value, int max_len); int hal_config_iterate(const char *section, int index, char *subsection, int max_len); -int hal_port_init_all(char *logfilename); +int hal_port_init_shmem(char *logfilename); +int hal_port_init_wripc(char *logfilename); void hal_port_update_all(void); struct hexp_port_state; struct hal_port_state; @@ -30,6 +31,7 @@ int hal_port_start_lock(const char *port_name, int priority); int hal_port_check_lock(const char *port_name); int hal_port_enable_tracking(const char *port_name); +int hal_init_timing_mode(void); int hal_init_timing(char *filename); int hal_get_timing_mode(void); int hal_port_pshifter_busy(void);