Home | History | Annotate | Download | only in CLI
      1 /*******************************************************************************
      2 **+--------------------------------------------------------------------------+**
      3 **|                                                                          |**
      4 **| Copyright 1998-2008 Texas Instruments, Inc. - http://www.ti.com/         |**
      5 **|                                                                          |**
      6 **| Licensed under the Apache License, Version 2.0 (the "License");          |**
      7 **| you may not use this file except in compliance with the License.         |**
      8 **| You may obtain a copy of the License at                                  |**
      9 **|                                                                          |**
     10 **|     http://www.apache.org/licenses/LICENSE-2.0                           |**
     11 **|                                                                          |**
     12 **| Unless required by applicable law or agreed to in writing, software      |**
     13 **| distributed under the License is distributed on an "AS IS" BASIS,        |**
     14 **| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |**
     15 **| See the License for the specific language governing permissions and      |**
     16 **| limitations under the License.                                           |**
     17 **|                                                                          |**
     18 **+--------------------------------------------------------------------------+**
     19 *******************************************************************************/
     20 
     21 #ifndef IPC_H
     22 #define IPC_H
     23 
     24 #define TERMINAL_MUX_UART_ID		(28)
     25 #define LOGGER_MUX_UART_ID			(30)
     26 #define WIPP_CONTROL_MUX_UART_ID	(25)
     27 #define G_TESTER_MUX_UART_ID		(23)
     28 
     29 
     30 #define ETHERNET_UTILS_NUMBER_OF_MODULES	(4)
     31 #define ETHERNET_UTILS_TERMINAL_MODULE_ID	(0)
     32 #define ETHERNET_UTILS_LOGGER_MODULE_ID		(1)
     33 #define ETHERNET_UTILS_WIPP_MODULE_ID		(2)
     34 #define ETHERNET_UTILS_G_TESTER_MODULE_ID	(3)
     35 
     36 #define GENERAL_PROCESS_MODULE_ID			(4)
     37 
     38 #define WIPP_CONTROL_FROM_GENERAL_PROCESS_SEND_TERMINATE	(0x00)
     39 #define WIPP_CONTROL_FROM_GENERAL_PROCESS_DEACTIVATE_IPERF	(0x01)
     40 
     41 extern void *p_shared_memory;
     42 extern int ipc_semaphore_id;
     43 
     44 extern int ethernet_logger_process_pid;
     45 extern int ethernet_g_tester_process_pid;
     46 extern int ethernet_wipp_process_pid;
     47 
     48 extern int ethernet_wipp_control_pipe[2];
     49 extern int ethernet_g_tester_pipe[2];
     50 extern int ethernet_logger_pipe[2];
     51 
     52 extern int ipc_pipe[2];
     53 
     54 typedef struct t_shared_memory_rec
     55 {
     56 #define OUTPUT_PATH_SIMPLE_UART	(0)
     57 #define OUTPUT_PATH_MUX_UART	(1)
     58 #define OUTPUT_PATH_ETHERNET	(2)
     59 	unsigned char output_paths[ETHERNET_UTILS_NUMBER_OF_MODULES];
     60 	unsigned char mux_uart_id[ETHERNET_UTILS_NUMBER_OF_MODULES];
     61 	int ethernet_socket_ids[ETHERNET_UTILS_NUMBER_OF_MODULES];
     62 	int ipc_pipe[ETHERNET_UTILS_NUMBER_OF_MODULES];
     63 	unsigned char uart_mux_enabled;
     64 	int debug_module_dev_file;
     65 	int run_process_state;
     66 	int run_process_result;
     67 } shared_memory_reco;
     68 
     69 #define SHARED_MEMORY_SIZE	(sizeof(shared_memory_reco))
     70 
     71 
     72 #define SHARED_MEMORY_OUTPUT_PATH(_module_index)		(((shared_memory_reco *)(p_shared_memory))->output_paths[_module_index])
     73 #define SHARED_MEMORY_TERMINAL_OUTPUT_PATH()			(((shared_memory_reco *)(p_shared_memory))->output_paths[ETHERNET_UTILS_TERMINAL_MODULE_ID])
     74 #define SHARED_MEMORY_LOGGER_OUTPUT_PATH()				(((shared_memory_reco *)(p_shared_memory))->output_paths[ETHERNET_UTILS_LOGGER_MODULE_ID])
     75 #define SHARED_MEMORY_WIPP_OUTPUT_PATH()				(((shared_memory_reco *)(p_shared_memory))->output_paths[ETHERNET_UTILS_WIPP_MODULE_ID])
     76 
     77 #define SHARED_MEMORY_ETHERNET_SOCKET_ID(_module_index) (((shared_memory_reco *)(p_shared_memory))->ethernet_socket_ids[_module_index])
     78 #define SHARED_MEMORY_ETHERNET_TERMINAL_SOCKET_ID()		(((shared_memory_reco *)(p_shared_memory))->ethernet_socket_ids[ETHERNET_UTILS_TERMINAL_MODULE_ID])
     79 #define SHARED_MEMORY_ETHERNET_LOGGER_SOCKET_ID()		(((shared_memory_reco *)(p_shared_memory))->ethernet_socket_ids[ETHERNET_UTILS_LOGGER_MODULE_ID])
     80 #define SHARED_MEMORY_ETHERNET_WIPP_SOCKET_ID()			(((shared_memory_reco *)(p_shared_memory))->ethernet_socket_ids[ETHERNET_UTILS_WIPP_MODULE_ID])
     81 
     82 #define SHARED_MEMORY_IPC_PIPE(_module_index)			(((shared_memory_reco *)(p_shared_memory))->ipc_pipe[_module_index])
     83 #define SHARED_MEMORY_MUX_UART_ID(_module_index)		(((shared_memory_reco *)(p_shared_memory))->mux_uart_id[_module_index])
     84 
     85 #define SHARED_MEMORY_UART_MUX_ENABLED()				(((shared_memory_reco *)(p_shared_memory))->uart_mux_enabled)
     86 
     87 #define SHARED_MEMORY_RUN_PROCESS_RUNNING()				(((shared_memory_reco *)(p_shared_memory))->run_process_state)
     88 #define SHARED_MEMORY_RUN_PROCESS_RESULT()				(((shared_memory_reco *)(p_shared_memory))->run_process_result)
     89 
     90 #define SHARED_MEMORY_SWITCH_TO_UART_OUTPUT(_module_index)	(SHARED_MEMORY_OUTPUT_PATH(_module_index) = (SHARED_MEMORY_UART_MUX_ENABLED() ? OUTPUT_PATH_MUX_UART : OUTPUT_PATH_SIMPLE_UART))
     91 
     92 #define SHARED_MEMORY_DBG_DEV_FILE()				    (((shared_memory_reco *)(p_shared_memory))->debug_module_dev_file)
     93 
     94 
     95 int ipc_initialize(void);
     96 void ipc_deinitialize(void);
     97 void ipc_send_command_to_main_process(int module_index, unsigned char *commnad, int size);
     98 
     99 #endif /* IPC_H */
    100