├── bin ├── linux │ ├── athrill_extfunc.sh │ ├── variable_conflict_check.sh │ ├── athrill_terminal │ ├── geany.sh │ ├── athrill-run │ ├── athrill-run-remote │ └── variable_conflict_check.groovy └── windows │ ├── sakura.sh │ └── athrill_scenario_cmd.sh ├── src ├── device │ ├── peripheral │ │ ├── mros-dev │ │ │ ├── mros-athrill │ │ │ │ ├── target │ │ │ │ │ ├── lwip │ │ │ │ │ │ ├── init.h │ │ │ │ │ │ ├── netdb.h │ │ │ │ │ │ └── sockets.h │ │ │ │ │ └── os │ │ │ │ │ │ ├── kernel_cfg.h │ │ │ │ │ │ ├── t_syslog.h │ │ │ │ │ │ ├── mros_exclusive_ops_linux.c │ │ │ │ │ │ └── kernel.h │ │ │ │ ├── config │ │ │ │ │ ├── mros_usr_config.c │ │ │ │ │ ├── mros_sys_config.c │ │ │ │ │ ├── mros_sys_config.h │ │ │ │ │ ├── os │ │ │ │ │ │ └── target │ │ │ │ │ │ │ └── os_asp │ │ │ │ │ │ │ └── mros_os_config.h │ │ │ │ │ └── mros_usr_config.h │ │ │ │ ├── device │ │ │ │ │ └── athrill_mros_device.h │ │ │ │ └── api │ │ │ │ │ └── ros_cimpl.h │ │ │ └── mros-src │ │ │ │ ├── inc │ │ │ │ ├── mros_name.h │ │ │ │ ├── mros_os.h │ │ │ │ ├── mros_exclusive_area.h │ │ │ │ ├── mros_exclusive_ops.h │ │ │ │ ├── mros_array_container.h │ │ │ │ ├── mros_wait_queue.h │ │ │ │ ├── mros_types.h │ │ │ │ └── mros_memory.h │ │ │ │ ├── transfer │ │ │ │ └── cimpl │ │ │ │ │ ├── mros_topic_data_publisher_cimpl.h │ │ │ │ │ ├── mros_topic_data_subscriber_cimpl.h │ │ │ │ │ ├── mros_topic_data_subscriber_cimpl.c │ │ │ │ │ └── mros_topic_data_publisher_cimpl.c │ │ │ │ ├── topic │ │ │ │ └── cimpl │ │ │ │ │ ├── mros_topic_runner_cimpl.h │ │ │ │ │ ├── mros_topic_connector_factory_cimpl.h │ │ │ │ │ ├── mros_topic_cimpl.h │ │ │ │ │ └── mros_topic_connector_factory_cimpl.c │ │ │ │ ├── api │ │ │ │ └── mros_topic_callback.h │ │ │ │ ├── os │ │ │ │ ├── target │ │ │ │ │ └── os_asp │ │ │ │ │ │ ├── mros_test.h │ │ │ │ │ │ ├── mros_log.h │ │ │ │ │ │ ├── mros_os.c │ │ │ │ │ │ └── mros_os_target.h │ │ │ │ ├── mros_exclusive_ops.c │ │ │ │ └── mros_exclusive_area.c │ │ │ │ ├── protocol │ │ │ │ └── cimpl │ │ │ │ │ ├── mros_protocol_slave_cimpl.h │ │ │ │ │ ├── mros_protocol_publish_cimpl.h │ │ │ │ │ ├── mros_protocol_subscribe_cimpl.h │ │ │ │ │ ├── mros_protocol_operation_cimpl.h │ │ │ │ │ ├── mros_protocol_master_cimpl.h │ │ │ │ │ ├── mros_protocol_server_proc_cimpl.h │ │ │ │ │ ├── mros_protocol_client_rpc_cimpl.h │ │ │ │ │ ├── mros_protocol_publish_cimpl.c │ │ │ │ │ ├── mros_protocol_operation_cimpl.c │ │ │ │ │ └── mros_protocol_slave_cimpl.c │ │ │ │ ├── lib │ │ │ │ ├── mros_name.c │ │ │ │ ├── mros_memory.c │ │ │ │ └── mros_wait_queue.c │ │ │ │ ├── packet │ │ │ │ ├── template │ │ │ │ │ └── version │ │ │ │ │ │ └── kinetic │ │ │ │ │ │ ├── mros_packet_fmt_http.h │ │ │ │ │ │ ├── mros_packet_fmt_tcpros.h │ │ │ │ │ │ └── mros_packet_fmt_xml.h │ │ │ │ └── cimpl │ │ │ │ │ ├── mros_packet_cimpl.h │ │ │ │ │ ├── version │ │ │ │ │ └── kinetic │ │ │ │ │ │ └── mros_packet_config.h │ │ │ │ │ └── mros_packet_encoder_cimpl.h │ │ │ │ ├── node │ │ │ │ └── cimpl │ │ │ │ │ └── mros_node_cimpl.h │ │ │ │ └── comm │ │ │ │ └── cimpl │ │ │ │ ├── mros_comm_tcp_server_cimpl.h │ │ │ │ ├── target │ │ │ │ └── lwip │ │ │ │ │ └── mros_comm_target.h │ │ │ │ ├── mros_comm_socket_cimpl.h │ │ │ │ ├── mros_comm_tcp_client_factory_cimpl.c │ │ │ │ ├── mros_comm_tcp_client_cimpl.h │ │ │ │ └── mros_comm_tcp_client_factory_cimpl.h │ │ └── target │ │ │ └── device_ex_serial_ops.h │ └── mpu │ │ ├── loader │ │ └── loader.h │ │ ├── mpu_malloc.h │ │ ├── mpu.h │ │ ├── mpu_ops.h │ │ └── mpu_types.h ├── lib │ ├── cui │ │ ├── tcp │ │ │ ├── cui_ops_tcp.h │ │ │ └── cui_ops_tcp.c │ │ ├── stdio │ │ │ ├── cui_ops_stdio.h │ │ │ └── cui_ops_stdio.c │ │ ├── udp │ │ │ ├── cui_ops_udp.h │ │ │ └── cui_ops_udp.c │ │ ├── cui_ops.c │ │ └── cui_ops.h │ ├── winsock_wrapper │ │ ├── winsock_wrapper.h │ │ └── winsock_wrapper.c │ ├── dwarf │ │ ├── data_type │ │ │ ├── elf_dwarf_base_type.h │ │ │ ├── elf_dwarf_enum_type.h │ │ │ ├── elf_dwarf_array_type.h │ │ │ ├── elf_dwarf_struct_type.h │ │ │ ├── elf_dwarf_pointer_type.h │ │ │ ├── elf_dwarf_typedef_type.h │ │ │ ├── elf_dwarf_variable_type.h │ │ │ ├── elf_dwarf_subprogram_type.h │ │ │ ├── elf_dwarf_base_type.c │ │ │ ├── elf_dwarf_enum_type.c │ │ │ ├── elf_dwarf_typedef_type.c │ │ │ ├── elf_dwarf_pointer_type.c │ │ │ └── elf_dwarf_variable_type.c │ │ ├── elf_dwarf_loc.h │ │ ├── file_address_mapping.h │ │ ├── elf_dwarf_util.h │ │ ├── elf_section.h │ │ ├── elf_dwarf_info_ops.c │ │ ├── elf_dwarf_info.h │ │ └── elf_dwarf_util.c │ ├── assert.h │ ├── udp │ │ ├── udp_common.h │ │ ├── udp_comm.h │ │ └── udp_comm.c │ ├── tcp │ │ ├── tcp_socket.h │ │ ├── tcp_client.h │ │ ├── tcp_server.h │ │ ├── tcp_connection.h │ │ ├── tcp_socket.c │ │ ├── tcp_client.c │ │ ├── tcp_server.c │ │ └── tcp_connection.c │ ├── hash.h │ ├── file.h │ ├── comm_buffer.h │ ├── symbol_ops.h │ ├── dbg_log.c │ ├── token.h │ ├── athrill_memory.h │ ├── target │ │ └── target_os_api.h │ ├── dbg_log.h │ ├── hash.c │ ├── comm_buffer.c │ └── list.h ├── inc │ ├── cpu_config_ops.h │ ├── std_errno.h │ ├── athrill_exdev_header.h │ ├── std_cpu_ops.h │ ├── athrill_device.h │ ├── athrill_mpthread.h │ ├── std_types.h │ └── cpuemu_ops.h ├── debugger │ ├── executor │ │ ├── concrete_executor │ │ │ ├── target │ │ │ │ ├── dbg_target_cpu.h │ │ │ │ └── dbg_target_serial.h │ │ │ ├── util │ │ │ │ └── dbg_print_data_type.h │ │ │ └── dbg_std_executor.h │ │ ├── dbg_executor.h │ │ └── cpu_control │ │ │ ├── dbg_cpu_thread_control.h │ │ │ ├── dbg_cpu_callback.h │ │ │ └── dbg_cpu_thread_control.c │ └── interaction │ │ ├── front │ │ └── parser │ │ │ ├── dbg_parser.h │ │ │ ├── dbg_parser_config.h │ │ │ ├── dbg_parser_config.c │ │ │ └── dbg_parser.c │ │ └── inc │ │ ├── target │ │ ├── rh850 │ │ │ └── dbg_interaction_target_ids.h │ │ ├── v850e2m │ │ │ └── dbg_interaction_target_ids.h │ │ └── v850esfk3 │ │ │ └── dbg_interaction_target_ids.h │ │ └── dbg_interaction_std_ids.h ├── main │ └── option │ │ └── option.h └── bus │ ├── bus.c │ └── bus.h ├── .gitignore ├── apl └── src │ └── athrill-syscall.c ├── command └── remote │ └── remote_cui_client │ ├── cpuemu_config.h │ └── Makefile ├── README.ja.md ├── README.md └── .github └── workflows └── packagebuild.yml /bin/linux/athrill_extfunc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo $* 4 | -------------------------------------------------------------------------------- /src/device/peripheral/mros-dev/mros-athrill/target/lwip/init.h: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/device/peripheral/mros-dev/mros-athrill/target/lwip/netdb.h: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.a 3 | athrill2 4 | athrill_remote 5 | RELEASE/ -------------------------------------------------------------------------------- /src/device/peripheral/mros-dev/mros-athrill/config/mros_usr_config.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /bin/windows/sakura.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | SAKURA_FILE="./arg_sakura.txt" 4 | 5 | sakura -R `cat ${SAKURA_FILE}` & 6 | -------------------------------------------------------------------------------- /bin/linux/variable_conflict_check.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | GROOVY_PATH=$(dirname $(which $0)) 4 | groovy ${GROOVY_PATH}/variable_conflict_check.groovy $* 5 | -------------------------------------------------------------------------------- /src/lib/cui/tcp/cui_ops_tcp.h: -------------------------------------------------------------------------------- 1 | #ifndef _CUI_OPS_TCP_H_ 2 | #define _CUI_OPS_TCP_H_ 3 | 4 | extern void cui_ops_tcp_init(void); 5 | 6 | #endif /* _CUI_OPS_TCP_H_ */ 7 | -------------------------------------------------------------------------------- /src/inc/cpu_config_ops.h: -------------------------------------------------------------------------------- 1 | #ifndef _CPU_CONFIG_OPS_H_ 2 | #define _CPU_CONFIG_OPS_H_ 3 | 4 | extern int cpu_config_get_core_id_num(void); 5 | 6 | #endif /* _CPU_CONFIG_OPS_H_ */ -------------------------------------------------------------------------------- /apl/src/athrill-syscall.c: -------------------------------------------------------------------------------- 1 | #include "athrill_syscall.h" 2 | 3 | void athrill_syscall(AthrillSyscallArgType *param) 4 | { 5 | athrill_device_func_call = (sys_addr)(param); 6 | } 7 | -------------------------------------------------------------------------------- /src/lib/cui/stdio/cui_ops_stdio.h: -------------------------------------------------------------------------------- 1 | #ifndef _CUI_OPS_STDIO_H_ 2 | #define _CUI_OPS_STDIO_H_ 3 | 4 | extern void cui_ops_stdio_init(void); 5 | 6 | #endif /* _CUI_OPS_STDIO_H_ */ 7 | -------------------------------------------------------------------------------- /src/lib/cui/udp/cui_ops_udp.h: -------------------------------------------------------------------------------- 1 | #ifndef _CUI_OPS_UDP_H_ 2 | #define _CUI_OPS_UDP_H_ 3 | 4 | extern void cui_ops_udp_init(uint16 server_port, uint16 client_port); 5 | 6 | #endif /* _CUI_OPS_UDP_H_ */ 7 | -------------------------------------------------------------------------------- /src/lib/winsock_wrapper/winsock_wrapper.h: -------------------------------------------------------------------------------- 1 | #ifndef _WINSOCK_H_ 2 | #define _WINSOCK_H_ 3 | 4 | #include 5 | 6 | extern int winsock_init(void); 7 | extern void winsock_fini(void); 8 | 9 | #endif /* _WINSOCK_H_ */ 10 | -------------------------------------------------------------------------------- /src/lib/dwarf/data_type/elf_dwarf_base_type.h: -------------------------------------------------------------------------------- 1 | #ifndef _ELF_DWARF_BASE_TYPE_H_ 2 | #define _ELF_DWARF_BASE_TYPE_H_ 3 | 4 | #include "elf_dwarf_data_type.h" 5 | #include "elf_dwarf_info.h" 6 | 7 | extern void elf_dwarf_build_base_type(ElfDwarfDieType *die); 8 | 9 | #endif /* _ELF_DWARF_BASE_TYPE_H_ */ 10 | -------------------------------------------------------------------------------- /src/lib/dwarf/data_type/elf_dwarf_enum_type.h: -------------------------------------------------------------------------------- 1 | #ifndef _ELF_DWARF_ENUM_TYPE_H_ 2 | #define _ELF_DWARF_ENUM_TYPE_H_ 3 | 4 | #include "elf_dwarf_data_type.h" 5 | #include "elf_dwarf_info.h" 6 | 7 | extern void elf_dwarf_build_enum_type(ElfDwarfDieType *die); 8 | 9 | #endif /* _ELF_DWARF_ENUM_TYPE_H_ */ 10 | -------------------------------------------------------------------------------- /src/debugger/executor/concrete_executor/target/dbg_target_cpu.h: -------------------------------------------------------------------------------- 1 | #ifndef _DBG_TARGET_CPU_H_ 2 | #define _DBG_TARGET_CPU_H_ 3 | 4 | #include "std_types.h" 5 | 6 | extern void dbg_target_print_cpu(uint32 core_id); 7 | extern void cpu_debug_print_mpu_status(uint32 core_id); 8 | 9 | #endif /* _DBG_TARGET_CPU_H_ */ 10 | -------------------------------------------------------------------------------- /src/debugger/interaction/front/parser/dbg_parser.h: -------------------------------------------------------------------------------- 1 | #ifndef _DBG_PARSER_H_ 2 | #define _DBG_PARSER_H_ 3 | 4 | #include "dbg_executor.h" 5 | 6 | typedef enum { 7 | DBG_MODE_DEBUG, 8 | DBG_MODE_CPU, 9 | } DbgModeType; 10 | extern DbgCmdExecutorType *dbg_parse(uint8 *str, uint32 len); 11 | 12 | 13 | #endif /* _DBG_PARSER_H_ */ 14 | -------------------------------------------------------------------------------- /src/inc/std_errno.h: -------------------------------------------------------------------------------- 1 | #ifndef _STD_ERRNO_H_ 2 | #define _STD_ERRNO_H_ 3 | 4 | #define STD_E_OK 0U 5 | #define STD_E_DECODE 1U 6 | #define STD_E_EXEC 2U 7 | #define STD_E_SEGV 3U 8 | #define STD_E_INVALID 4U 9 | #define STD_E_NOENT 5U 10 | #define STD_E_LIMIT 6U 11 | #define STD_E_PERM 7U 12 | 13 | #endif /* _STD_ERRNO_H_ */ 14 | -------------------------------------------------------------------------------- /src/lib/assert.h: -------------------------------------------------------------------------------- 1 | #ifndef _ASSERT_H_ 2 | #define _ASSERT_H_ 3 | 4 | #include 5 | #include 6 | 7 | #define ASSERT(expr) \ 8 | do { \ 9 | if (!(expr)) { \ 10 | printf("ASSERTION FAILED:%s:%s:%d:%s\n", __FILE__, __FUNCTION__, __LINE__, #expr); \ 11 | exit(1); \ 12 | } \ 13 | } while (0) 14 | 15 | #endif /* _ASSERT_H_ */ 16 | -------------------------------------------------------------------------------- /src/debugger/interaction/inc/target/rh850/dbg_interaction_target_ids.h: -------------------------------------------------------------------------------- 1 | #ifndef _DBG_INTERACTION_TARGET_IDS_H_ 2 | #define _DBG_INTERACTION_TARGET_IDS_H_ 3 | 4 | #include "dbg_interaction_std_ids.h" 5 | 6 | typedef enum { 7 | DBG_CMD_TARGET_ID_XXX = DBG_CMD_STD_ID_TARGET, 8 | } DbgCmdTargetIdType; 9 | 10 | #endif /* _DBG_INTERACTION_TARGET_IDS_H_ */ 11 | -------------------------------------------------------------------------------- /src/debugger/interaction/inc/target/v850e2m/dbg_interaction_target_ids.h: -------------------------------------------------------------------------------- 1 | #ifndef _DBG_INTERACTION_TARGET_IDS_H_ 2 | #define _DBG_INTERACTION_TARGET_IDS_H_ 3 | 4 | #include "dbg_interaction_std_ids.h" 5 | 6 | typedef enum { 7 | DBG_CMD_TARGET_ID_XXX = DBG_CMD_STD_ID_TARGET, 8 | } DbgCmdTargetIdType; 9 | 10 | #endif /* _DBG_INTERACTION_TARGET_IDS_H_ */ 11 | -------------------------------------------------------------------------------- /src/debugger/interaction/inc/target/v850esfk3/dbg_interaction_target_ids.h: -------------------------------------------------------------------------------- 1 | #ifndef _DBG_INTERACTION_TARGET_IDS_H_ 2 | #define _DBG_INTERACTION_TARGET_IDS_H_ 3 | 4 | #include "dbg_interaction_std_ids.h" 5 | 6 | typedef enum { 7 | DBG_CMD_TARGET_ID_XXX = DBG_CMD_STD_ID_TARGET, 8 | } DbgCmdTargetIdType; 9 | 10 | #endif /* _DBG_INTERACTION_TARGET_IDS_H_ */ 11 | -------------------------------------------------------------------------------- /src/lib/dwarf/data_type/elf_dwarf_array_type.h: -------------------------------------------------------------------------------- 1 | #ifndef _ELF_DWARF_ARRAY_TYPE_H_ 2 | #define _ELF_DWARF_ARRAY_TYPE_H_ 3 | 4 | #include "elf_dwarf_data_type.h" 5 | #include "elf_dwarf_info.h" 6 | 7 | extern void elf_dwarf_build_array_type(ElfDwarfDieType *die); 8 | extern void elf_dwarf_resolve_array_type(void); 9 | 10 | #endif /* _ELF_DWARF_ARRAY_TYPE_H_ */ 11 | -------------------------------------------------------------------------------- /src/lib/dwarf/data_type/elf_dwarf_struct_type.h: -------------------------------------------------------------------------------- 1 | #ifndef _ELF_DWARF_STRUCT_TYPE_H_ 2 | #define _ELF_DWARF_STRUCT_TYPE_H_ 3 | 4 | #include "elf_dwarf_data_type.h" 5 | #include "elf_dwarf_info.h" 6 | 7 | extern void elf_dwarf_build_struct_type(ElfDwarfDieType *die); 8 | extern void elf_dwarf_resolve_struct_type(void); 9 | 10 | #endif /* _ELF_DWARF_STRUCT_TYPE_H_ */ 11 | -------------------------------------------------------------------------------- /src/lib/dwarf/data_type/elf_dwarf_pointer_type.h: -------------------------------------------------------------------------------- 1 | #ifndef _ELF_DWARF_POINTER_TYPE_H_ 2 | #define _ELF_DWARF_POINTER_TYPE_H_ 3 | 4 | #include "elf_dwarf_data_type.h" 5 | #include "elf_dwarf_info.h" 6 | 7 | extern void elf_dwarf_build_pointer_type(ElfDwarfDieType *die); 8 | extern void elf_dwarf_resolve_pointer_type(void); 9 | 10 | #endif /* _ELF_DWARF_POINTER_TYPE_H_ */ 11 | -------------------------------------------------------------------------------- /src/lib/dwarf/data_type/elf_dwarf_typedef_type.h: -------------------------------------------------------------------------------- 1 | #ifndef _ELF_DWARF_TYPEDEF_TYPE_H_ 2 | #define _ELF_DWARF_TYPEDEF_TYPE_H_ 3 | 4 | #include "elf_dwarf_data_type.h" 5 | #include "elf_dwarf_info.h" 6 | 7 | extern void elf_dwarf_build_typedef_type(ElfDwarfDieType *die); 8 | extern void elf_dwarf_resolve_typedef_type(void); 9 | 10 | #endif /* _ELF_DWARF_TYPEDEF_TYPE_H_ */ 11 | -------------------------------------------------------------------------------- /src/lib/dwarf/data_type/elf_dwarf_variable_type.h: -------------------------------------------------------------------------------- 1 | #ifndef _ELF_DWARF_VARIABLE_TYPE_H_ 2 | #define _ELF_DWARF_VARIABLE_TYPE_H_ 3 | 4 | #include "elf_dwarf_data_type.h" 5 | #include "elf_dwarf_info.h" 6 | 7 | extern void elf_dwarf_build_variable_type(ElfDwarfDieType *die); 8 | extern void elf_dwarf_resolve_variable_type(void); 9 | 10 | #endif /* _ELF_DWARF_VARIABLE_TYPE_H_ */ 11 | -------------------------------------------------------------------------------- /src/lib/winsock_wrapper/winsock_wrapper.c: -------------------------------------------------------------------------------- 1 | #ifdef OS_LINUX 2 | #else 3 | #include "winsock_wrapper.h" 4 | 5 | int winsock_init(void) 6 | { 7 | WSADATA wsaData; 8 | int err; 9 | 10 | err = WSAStartup(MAKEWORD(2,0), &wsaData); 11 | if (err < 0) { 12 | return -1; 13 | } 14 | 15 | return 0; 16 | } 17 | 18 | void winsock_fini(void) 19 | { 20 | WSACleanup(); 21 | } 22 | #endif 23 | -------------------------------------------------------------------------------- /bin/linux/athrill_terminal: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ $# -ne 1 ] 4 | then 5 | echo "Usage: $0 " 6 | exit 1 7 | fi 8 | CHANNEL=${1} 9 | 10 | athrill_remote c > /dev/null 11 | while [ 1 ] 12 | do 13 | #echo -n "$ " 14 | read -rN1 str 15 | athrill_remote q > /dev/null 16 | athrill_remote S ${CHANNEL} $str > /dev/null 17 | athrill_remote c > /dev/null 18 | done 19 | 20 | -------------------------------------------------------------------------------- /src/lib/dwarf/data_type/elf_dwarf_subprogram_type.h: -------------------------------------------------------------------------------- 1 | #ifndef _ELF_DWARF_SUBPROGRAM_TYPE_H_ 2 | #define _ELF_DWARF_SUBPROGRAM_TYPE_H_ 3 | 4 | #include "elf_dwarf_data_type.h" 5 | #include "elf_dwarf_info.h" 6 | 7 | extern void elf_dwarf_build_subprogram_type(ElfDwarfDieType *die); 8 | extern void elf_dwarf_resolve_subprogram_type(void); 9 | 10 | #endif /* _ELF_DWARF_SUBPROGRAM_TYPE_H_ */ 11 | -------------------------------------------------------------------------------- /src/device/peripheral/mros-dev/mros-athrill/target/os/kernel_cfg.h: -------------------------------------------------------------------------------- 1 | /* kernel_cfg.h */ 2 | #ifndef TOPPERS_KERNEL_CFG_H 3 | #define TOPPERS_KERNEL_CFG_H 4 | 5 | #define MAIN_TASK 0 6 | #define SUB_TASK 1 7 | #define PUB_TASK 2 8 | #define XML_SLV_TASK 3 9 | #define XML_MAS_TASK 4 10 | #define ATHRILL_TASK 5 11 | #define NUM_TASK 6 12 | 13 | #endif /* TOPPERS_KERNEL_CFG_H */ 14 | 15 | -------------------------------------------------------------------------------- /src/device/mpu/loader/loader.h: -------------------------------------------------------------------------------- 1 | #ifndef _LOADER_H_ 2 | #define _LOADER_H_ 3 | 4 | #include "std_errno.h" 5 | #include "std_types.h" 6 | #include "cpuemu_ops.h" 7 | 8 | extern Std_ReturnType binary_load(uint8 *binary_data, uint32 load_addr, uint32 binary_data_len); 9 | extern Std_ReturnType elf_load(uint8 *elf_data, MemoryAddressMapType *memap, uint32* entry_addr); 10 | 11 | #endif /* _LOADER_H_ */ 12 | -------------------------------------------------------------------------------- /command/remote/remote_cui_client/cpuemu_config.h: -------------------------------------------------------------------------------- 1 | #ifndef _CPUEMU_CONFIG_H_ 2 | #define _CPUEMU_CONFIG_H_ 3 | 4 | /* 5 | * symbol table config 6 | */ 7 | #define CPUEMU_CONFIG_FUNC_SYMBOL_TABLE_NUM 10240 8 | #define CPUEMU_CONFIG_OBJECT_SYMBOL_TABLE_NUM 10240 9 | 10 | #define CPUEMU_CONFIG_CUI_EMULATOR_PORTNO 49152 11 | #define CPUEMU_CONFIG_CUI_CLIENT_PORTNO 49153 12 | 13 | #endif /* _CPUEMU_CONFIG_H_ */ 14 | -------------------------------------------------------------------------------- /src/device/peripheral/mros-dev/mros-src/inc/mros_name.h: -------------------------------------------------------------------------------- 1 | #ifndef _MROS_NAME_H_ 2 | #define _MROS_NAME_H_ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include "mros_types.h" 9 | 10 | extern void mros_name_formalize(const char *src_name, mros_uint32 src_namelen, char *dst_name, mros_uint32 *dst_namelen); 11 | 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | 17 | #endif /* _MROS_NAME_H_ */ 18 | -------------------------------------------------------------------------------- /src/lib/udp/udp_common.h: -------------------------------------------------------------------------------- 1 | #ifndef _UDP_COMMON_H_ 2 | #define _UDP_COMMON_H_ 3 | 4 | #include "std_types.h" 5 | #include "std_errno.h" 6 | 7 | typedef struct { 8 | uint16 server_port; 9 | uint16 client_port; 10 | bool is_wait; 11 | } UdpCommConfigType; 12 | 13 | #define UDP_BUFFER_LEN 4096 14 | typedef struct { 15 | int len; 16 | char buffer[UDP_BUFFER_LEN]; 17 | } UdpBufferType; 18 | 19 | #endif /* _UDP_COMMON_H_ */ 20 | -------------------------------------------------------------------------------- /src/device/peripheral/mros-dev/mros-athrill/config/mros_sys_config.c: -------------------------------------------------------------------------------- 1 | #include "mros_types.h" 2 | #include "mros_memory.h" 3 | #include "mros_sys_config.h" 4 | #include "kernel.h" 5 | 6 | mRosMemoryManagerType ros_inner_topic_publisher_mempool; 7 | mRosMemoryManagerType ros_outer_topic_publisher_mempool; 8 | 9 | void mros_sys_config_init(void) 10 | { 11 | return; 12 | } 13 | 14 | 15 | void usr_task_activation(void) 16 | { 17 | } 18 | 19 | -------------------------------------------------------------------------------- /src/device/peripheral/mros-dev/mros-src/transfer/cimpl/mros_topic_data_publisher_cimpl.h: -------------------------------------------------------------------------------- 1 | #ifndef _MROS_TOPIC_DATA_PUBLISHER_CIMPL_H_ 2 | #define _MROS_TOPIC_DATA_PUBLISHER_CIMPL_H_ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include "mros_types.h" 9 | 10 | extern mRosReturnType mros_topic_data_publisher_init(void); 11 | 12 | #ifdef __cplusplus 13 | } 14 | #endif 15 | #endif /* _MROS_TOPIC_DATA_PUBLISHER_CIMPL_H_ */ 16 | -------------------------------------------------------------------------------- /src/device/peripheral/mros-dev/mros-src/transfer/cimpl/mros_topic_data_subscriber_cimpl.h: -------------------------------------------------------------------------------- 1 | #ifndef _MROS_TOPIC_DATA_SUBSCRIBER_CIMPL_H_ 2 | #define _MROS_TOPIC_DATA_SUBSCRIBER_CIMPL_H_ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include "mros_types.h" 9 | 10 | extern mRosReturnType mros_topic_data_subscriber_init(void); 11 | 12 | #ifdef __cplusplus 13 | } 14 | #endif 15 | #endif /* _MROS_TOPIC_DATA_SUBSCRIBER_CIMPL_H_ */ 16 | -------------------------------------------------------------------------------- /src/lib/tcp/tcp_socket.h: -------------------------------------------------------------------------------- 1 | #ifndef _TCP_SOCKET_H_ 2 | #define _TCP_SOCKET_H_ 3 | 4 | #include "std_types.h" 5 | #include "std_errno.h" 6 | 7 | typedef struct { 8 | int fd; 9 | } TcpSocketType; 10 | 11 | extern Std_ReturnType tcp_socket_open(TcpSocketType *socket); 12 | extern void tcp_socket_close(TcpSocketType *socket); 13 | extern Std_ReturnType tcp_inet_get_ipaddr(const char *hostname, uint32 *ipaddr); 14 | 15 | #endif /* _TCP_SOCKET_H_ */ 16 | -------------------------------------------------------------------------------- /src/device/peripheral/mros-dev/mros-src/topic/cimpl/mros_topic_runner_cimpl.h: -------------------------------------------------------------------------------- 1 | #ifndef _MROS_TOPIC_RUNNER_CIMPL_H_ 2 | #define _MROS_TOPIC_RUNNER_CIMPL_H_ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include "mros_types.h" 9 | 10 | extern void mros_topic_data_publisher_run(void); 11 | extern void mros_topic_data_subscriber_run(void); 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | #endif /* _MROS_TOPIC_RUNNER_CIMPL_H_ */ 17 | -------------------------------------------------------------------------------- /src/device/peripheral/mros-dev/mros-src/api/mros_topic_callback.h: -------------------------------------------------------------------------------- 1 | #ifndef _MROS_INTEGRATION_H_ 2 | #define _MROS_INTEGRATION_H_ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include "mros_types.h" 9 | 10 | extern void mros_topic_callback(mros_uint32 topic_id, mros_uint32 type_id, mRosFuncIdType func_id, const char *data, mros_uint32 len); 11 | 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | 17 | 18 | #endif /* _MROS_INTEGRATION_H_ */ 19 | -------------------------------------------------------------------------------- /src/device/mpu/mpu_malloc.h: -------------------------------------------------------------------------------- 1 | #ifndef _MPU_MALLOC_H_ 2 | #define _MPU_MALLOC_H_ 3 | 4 | #include "std_types.h" 5 | #include "std_errno.h" 6 | #include "mpu_types.h" 7 | #include "mpu_types.h" 8 | 9 | extern void mpu_malloc_add_region(MpuAddressRegionType *region); 10 | extern uint32 mpu_malloc_get_memory(uint32 size); 11 | extern void mpu_malloc_rel_memory(uint32 addr); 12 | extern uint32 mpu_malloc_ref_size(uint32 addr); 13 | 14 | 15 | #endif /* _MPU_MALLOC_H_ */ -------------------------------------------------------------------------------- /src/inc/athrill_exdev_header.h: -------------------------------------------------------------------------------- 1 | #ifndef _ATHRILL_EXDEV_HEADER_H_ 2 | #define _ATHRILL_EXDEV_HEADER_H_ 3 | 4 | #define ATHRILL_EXTERNAL_DEVICE_MAGICNO 0xBEEFDEAD 5 | #define ATHRILL_EXTERNAL_DEVICE_VERSION 0x00000004 6 | typedef struct { 7 | unsigned int magicno; /* ATHRILL_EXTERNAL_DEVICE_MAGICNO */ 8 | unsigned int version; /* ATHRILL_EXTERNAL_DEVICE_VERSION */ 9 | int memory_size; /* Bytes */ 10 | } AthrillExDeviceHeaderType; 11 | 12 | 13 | #endif /* _ATHRILL_EXDEV_HEADER_H_ */ 14 | -------------------------------------------------------------------------------- /src/debugger/executor/concrete_executor/util/dbg_print_data_type.h: -------------------------------------------------------------------------------- 1 | #ifndef _DBG_PRINT_DATA_TYPE_H_ 2 | #define _DBG_PRINT_DATA_TYPE_H_ 3 | 4 | #include "std_types.h" 5 | 6 | extern bool print_variable_with_data_type(char *variable_name, uint32 vaddr, uint8 *top_addr, uint32 size); 7 | extern bool print_addr_with_data_type(uint32 vaddr, uint8 *top_addr, char* dataType, char* dataTypeName); 8 | extern bool print_local_variable_type(char *variable_name); 9 | 10 | #endif /* _DBG_PRINT_DATA_TYPE_H_ */ 11 | -------------------------------------------------------------------------------- /src/device/peripheral/mros-dev/mros-src/os/target/os_asp/mros_test.h: -------------------------------------------------------------------------------- 1 | #ifndef _MROS_TEST_H_ 2 | #define _MROS_TEST_H_ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | extern void do_test_register_publisher(void); 9 | extern void do_test_register_subscriber(void); 10 | extern void do_test_request_topic(void); 11 | extern void do_test_tcpros_topic(void); 12 | extern void do_test_server(void); 13 | 14 | 15 | #ifdef __cplusplus 16 | } 17 | #endif 18 | 19 | 20 | #endif /* _MROS_TEST_H_ */ 21 | -------------------------------------------------------------------------------- /src/device/peripheral/mros-dev/mros-src/os/target/os_asp/mros_log.h: -------------------------------------------------------------------------------- 1 | #ifndef _MROS_LOG_H_ 2 | #define _MROS_LOG_H_ 3 | 4 | #include 5 | #include 6 | 7 | #define ROS_DEBUG(...) syslog(LOG_DEBUG, __VA_ARGS__) 8 | #define ROS_INFO(...) syslog(LOG_NOTICE, __VA_ARGS__) 9 | #define ROS_WARN(...) syslog(LOG_WARNING, __VA_ARGS__) 10 | #define ROS_ERROR(...) syslog(LOG_ERROR, __VA_ARGS__) 11 | #define ROS_FATAL(...) syslog(LOG_EMERG, __VA_ARGS__) 12 | 13 | 14 | #endif /* _MROS_LOG_H_ */ 15 | -------------------------------------------------------------------------------- /src/lib/cui/cui_ops.c: -------------------------------------------------------------------------------- 1 | #include "cui/cui_ops.h" 2 | 3 | static FileOpType *cui_fileop; 4 | CuiPrintBufferType CuiPrintBuffer; 5 | 6 | int cui_fileop_register(FileOpType *fileop) 7 | { 8 | cui_fileop = fileop; 9 | return 0; 10 | } 11 | 12 | int cui_getline(char *line, int size) 13 | { 14 | return cui_fileop->cui_getline(line, size); 15 | } 16 | void cui_write(char *line, int size) 17 | { 18 | return cui_fileop->cui_write(line, size); 19 | } 20 | 21 | void cui_close(void) 22 | { 23 | return cui_fileop->cui_close(); 24 | } 25 | -------------------------------------------------------------------------------- /bin/linux/geany.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | SAKURA_FILE="./arg_sakura.txt" 4 | 5 | which code > /dev/null 6 | if [ $? -eq 0 ] 7 | then 8 | FILE=$(cat ./arg_sakura.txt | awk '{print $3}') 9 | LINE=$(cat ./arg_sakura.txt | awk '{print $2}') 10 | code -r -g ${FILE}:${LINE} 11 | else 12 | which geany > /dev/null 13 | if [ $? -eq 0 ] 14 | then 15 | geany -r `cat ${SAKURA_FILE}` & 16 | else 17 | echo "ERROR not found editor: please install vscode or geany!" 18 | exit 1 19 | fi 20 | fi 21 | 22 | exit 0 -------------------------------------------------------------------------------- /src/debugger/interaction/front/parser/dbg_parser_config.h: -------------------------------------------------------------------------------- 1 | #ifndef _DBG_PARSER_CONFIG_H_ 2 | #define _DBG_PARSER_CONFIG_H_ 3 | 4 | #include "dbg_interaction_std_ids.h" 5 | #include "dbg_parser_config.h" 6 | #include "dbg_executor.h" 7 | #include "token.h" 8 | 9 | typedef struct { 10 | DbgCmdExecutorType* (*parse) (DbgCmdExecutorType *arg, const TokenContainerType *token_container); 11 | } DbgCmdParserTableType; 12 | 13 | extern DbgCmdParserTableType dbg_cmd_parser_std_table[DBG_CMD_STD_ID_NUM]; 14 | 15 | #endif /* _DBG_PARSER_CONFIG_H_ */ 16 | -------------------------------------------------------------------------------- /src/device/peripheral/mros-dev/mros-athrill/target/os/t_syslog.h: -------------------------------------------------------------------------------- 1 | #ifndef _T_SYSLOG_H_ 2 | #define _T_SYSLOG_H_ 3 | 4 | #include 5 | #include 6 | 7 | #define LOG_ERROR 1 8 | #define LOG_WARNING 1 9 | #define LOG_NOTICE 1 10 | 11 | static inline void syslog(int flag, const char* fmt, ...) 12 | { 13 | va_list arg_ptr; 14 | static char format[1024]; 15 | 16 | sprintf(format, "%s\n", fmt); 17 | va_start(arg_ptr, fmt); 18 | vprintf(format, arg_ptr); 19 | va_end(arg_ptr); 20 | return; 21 | } 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /src/device/peripheral/target/device_ex_serial_ops.h: -------------------------------------------------------------------------------- 1 | #ifndef _DEVICE_EX_SERIAL_OPS_H_ 2 | #define _DEVICE_EX_SERIAL_OPS_H_ 3 | 4 | typedef struct { 5 | /* 6 | * シリアル出力をCPUエミュレータから外部に出力する. 7 | */ 8 | bool (*putchar) (uint8 channel, uint8 data); 9 | /* 10 | * シリアル入力をCPUエミュレータの外部から入力する. 11 | */ 12 | bool (*getchar) (uint8 channel, uint8 *data); 13 | 14 | void (*flush) (uint8 channel); 15 | } DeviceExSerialOpType; 16 | extern void device_ex_serial_register_ops(uint8 channel, DeviceExSerialOpType *ops); 17 | 18 | #endif /* _DEVICE_EX_SERIAL_OPS_H_ */ 19 | -------------------------------------------------------------------------------- /src/debugger/executor/dbg_executor.h: -------------------------------------------------------------------------------- 1 | #ifndef _DBG_EXECUTOR_H_ 2 | #define _DBG_EXECUTOR_H_ 3 | 4 | #include "dbg_interaction_std_ids.h" 5 | #include "dbg_interaction_target_ids.h" 6 | #include "std_types.h" 7 | 8 | 9 | #define DBG_CMD_BUFFER_SIZE (4096*256U) 10 | typedef struct { 11 | DbgCmdStdIdType std_id; 12 | DbgCmdTargetIdType target_id; 13 | uint8 original_str[DBG_CMD_BUFFER_SIZE]; 14 | uint8 parsed_args[DBG_CMD_BUFFER_SIZE]; 15 | void (*run) (void *executor); 16 | bool result_ok; 17 | } DbgCmdExecutorType; 18 | 19 | #endif /* _DBG_EXECUTOR_H_ */ 20 | -------------------------------------------------------------------------------- /src/device/mpu/mpu.h: -------------------------------------------------------------------------------- 1 | #ifndef _MPU_H_ 2 | #define _MPU_H_ 3 | 4 | #include "std_types.h" 5 | #include "std_errno.h" 6 | #include "mpu_types.h" 7 | #include "mpu_config.h" 8 | 9 | typedef struct { 10 | MpuAddressRegionType map[MPU_CONFIG_REGION_NUM]; 11 | uint32 dynamic_map_num; 12 | MpuAddressRegionType *dynamic_map; 13 | } MpuAddressMapType; 14 | 15 | extern MpuAddressMapType mpu_address_map; 16 | 17 | extern void mpu_add_dynamic_map(MpuAddressRegionType *p); 18 | extern MpuAddressRegionType *mpu_search_dynamic_map(uint32 start, uint32 size); 19 | 20 | #endif /* _MPU_H_ */ 21 | -------------------------------------------------------------------------------- /src/device/peripheral/mros-dev/mros-athrill/target/os/mros_exclusive_ops_linux.c: -------------------------------------------------------------------------------- 1 | #include "mros_os.h" 2 | #include "mros_exclusive_ops.h" 3 | #define _OPEN_THREADS 4 | #include "kernel.h" 5 | 6 | void mros_exclusive_init(mRosExclusiveObjectType *exobj, mRosTaskPriorityType priority) 7 | { 8 | return; 9 | } 10 | 11 | void mros_exclusive_lock(mRosExclusiveObjectType *exobj, mROsExclusiveUnlockObjType *unlock_obj) 12 | { 13 | os_lock_recursive(); 14 | return; 15 | } 16 | 17 | void mros_exclusive_unlock(mROsExclusiveUnlockObjType *unlock_obj) 18 | { 19 | os_unlock_recursive(); 20 | return; 21 | } 22 | -------------------------------------------------------------------------------- /src/lib/tcp/tcp_client.h: -------------------------------------------------------------------------------- 1 | #ifndef _TCP_CLIENT_H_ 2 | #define _TCP_CLIENT_H_ 3 | 4 | #include "tcp_connection.h" 5 | 6 | typedef struct { 7 | const char* ipaddr; 8 | uint16 server_port; 9 | } TcpClientConfigType; 10 | 11 | typedef struct { 12 | TcpClientConfigType config; 13 | TcpConnectionType connection; 14 | } TcpClientType; 15 | 16 | 17 | extern Std_ReturnType tcp_client_create(const TcpClientConfigType *config, TcpClientType *client); 18 | extern Std_ReturnType tcp_client_connect(TcpClientType *client); 19 | extern void tcp_client_close(TcpClientType *server); 20 | 21 | #endif /* _TCP_CLIENT_H_ */ 22 | -------------------------------------------------------------------------------- /src/lib/tcp/tcp_server.h: -------------------------------------------------------------------------------- 1 | #ifndef _TCP_SERVER_H_ 2 | #define _TCP_SERVER_H_ 3 | 4 | #include "tcp_connection.h" 5 | 6 | typedef struct { 7 | uint16 server_port; 8 | } TcpServerConfigType; 9 | 10 | typedef struct { 11 | TcpServerConfigType config; 12 | TcpSocketType socket; 13 | } TcpServerType; 14 | 15 | 16 | extern Std_ReturnType tcp_server_create(const TcpServerConfigType *config, TcpServerType *server); 17 | extern Std_ReturnType tcp_server_accept(const TcpServerType *server, TcpConnectionType *connection); 18 | extern void tcp_server_close(TcpServerType *server); 19 | 20 | #endif /* _TCP_SERVER_H_ */ 21 | -------------------------------------------------------------------------------- /src/device/peripheral/mros-dev/mros-src/inc/mros_os.h: -------------------------------------------------------------------------------- 1 | #ifndef _MROS_OS_H_ 2 | #define _MROS_OS_H_ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include "mros_types.h" 9 | 10 | extern mRosTaskIdType mros_get_taskid(void); 11 | extern mRosTaskPriorityType mros_get_taskpri(void); 12 | extern void mros_change_taskpri(mRosTaskPriorityType priority); 13 | extern void mros_sleep_task(void); 14 | extern void mros_sleep_task_msec(mRosTaskSleepIntervalType msec); 15 | extern void mros_wakeup_task(mRosTaskIdType task_id); 16 | 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | 21 | 22 | #endif /* _MROS_OS_H_ */ 23 | -------------------------------------------------------------------------------- /src/device/peripheral/mros-dev/mros-src/protocol/cimpl/mros_protocol_slave_cimpl.h: -------------------------------------------------------------------------------- 1 | #ifndef _MROS_PROTOCOL_SLAVE_CIMPL_H_ 2 | #define _MROS_PROTOCOL_SLAVE_CIMPL_H_ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include "mros_types.h" 9 | 10 | typedef enum { 11 | MROS_PROTOCOL_SLAVE_STATE_WAITING = 0, 12 | MROS_PROTOCOL_SLAVE_STATE_REPLYING_REQUEST_TOPIC, 13 | } mRosProtocolSlaveStateEnumType; 14 | 15 | 16 | extern mRosReturnType mros_protocol_slave_init(void); 17 | extern void mros_protocol_slave_run(void); 18 | 19 | #ifdef __cplusplus 20 | } 21 | #endif 22 | #endif /* _MROS_PROTOCOL_SLAVE_CIMPL_H_ */ 23 | -------------------------------------------------------------------------------- /src/device/peripheral/mros-dev/mros-src/protocol/cimpl/mros_protocol_publish_cimpl.h: -------------------------------------------------------------------------------- 1 | #ifndef _MROS_PROTOCOL_PUBLISH_CIMPL_H_ 2 | #define _MROS_PROTOCOL_PUBLISH_CIMPL_H_ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include "mros_types.h" 9 | 10 | typedef enum { 11 | MROS_PROTOCOL_PUBLISH_STATE_WAITING = 0, 12 | MROS_PROTOCOL_PUBLISH_STATE_STARTING_PUBLISH_TOPIC, 13 | } mRosProtocolPublishStateEnumType; 14 | 15 | 16 | extern mRosReturnType mros_protocol_publish_init(void); 17 | extern void mros_protocol_publish_run(void); 18 | 19 | #ifdef __cplusplus 20 | } 21 | #endif 22 | #endif /* _MROS_PROTOCOL_PUBLISH_CIMPL_H_ */ 23 | -------------------------------------------------------------------------------- /src/device/peripheral/mros-dev/mros-src/os/mros_exclusive_ops.c: -------------------------------------------------------------------------------- 1 | #include "mros_os.h" 2 | #include "mros_exclusive_ops.h" 3 | 4 | void mros_exclusive_init(mRosExclusiveObjectType *exobj, mRosTaskPriorityType priority) 5 | { 6 | exobj->priority = priority; 7 | return; 8 | } 9 | 10 | void mros_exclusive_lock(mRosExclusiveObjectType *exobj, mROsExclusiveUnlockObjType *unlock_obj) 11 | { 12 | unlock_obj->org_priority = mros_get_taskpri(); 13 | mros_change_taskpri(exobj->priority); 14 | return; 15 | } 16 | 17 | void mros_exclusive_unlock(mROsExclusiveUnlockObjType *unlock_obj) 18 | { 19 | mros_change_taskpri(unlock_obj->org_priority); 20 | return; 21 | } 22 | -------------------------------------------------------------------------------- /src/main/option/option.h: -------------------------------------------------------------------------------- 1 | #ifndef _OPTION_H_ 2 | #define _OPTION_H_ 3 | 4 | #include "std_types.h" 5 | #include "file.h" 6 | 7 | typedef struct { 8 | bool is_interaction; 9 | uint32 core_id_num; 10 | uint64 timeout; 11 | bool is_binary_data; 12 | bool is_remote; 13 | 14 | char *fifocfgpath; 15 | char buffer_fifopath[4096]; 16 | 17 | char *load_filepath; 18 | FileType load_file; 19 | 20 | char *devcfgpath; 21 | char buffer_devcfgpath[4096]; 22 | 23 | char* memfilepath; 24 | char buffer_memfile[4096]; 25 | } CmdOptionType; 26 | 27 | extern CmdOptionType *parse_args(int argc, const char* argv[]); 28 | 29 | 30 | #endif /* _OPTION_H_ */ 31 | -------------------------------------------------------------------------------- /src/inc/std_cpu_ops.h: -------------------------------------------------------------------------------- 1 | #ifndef _STD_CPU_OPS_H_ 2 | #define _STD_CPU_OPS_H_ 3 | 4 | #include "std_types.h" 5 | #include "std_errno.h" 6 | #include "cpu_config_ops.h" 7 | 8 | extern void cpu_init(void); 9 | extern void cpu_reset(CoreIdType core_id); 10 | extern void cpu_illegal_opcode_trap(CoreIdType core_id); 11 | extern void cpu_set_current_core(CoreIdType core_id); 12 | extern Std_ReturnType cpu_supply_clock(CoreIdType core_id); 13 | extern bool cpu_is_halt(CoreIdType core_id); 14 | extern bool cpu_is_halt_all(void); 15 | extern void cpu_mpu_construct_containers(CoreIdType core_id); 16 | extern bool cpu_illegal_access(CoreIdType core_id); 17 | 18 | #endif /* _STD_CPU_OPS_H_ */ 19 | -------------------------------------------------------------------------------- /src/device/peripheral/mros-dev/mros-src/inc/mros_exclusive_area.h: -------------------------------------------------------------------------------- 1 | #ifndef _MROS_EXCLUSIVE_AREA_H_ 2 | #define _MROS_EXCLUSIVE_AREA_H_ 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | #include "mros_exclusive_ops.h" 8 | #include "mros_wait_queue.h" 9 | #include "mros_types.h" 10 | 11 | extern mRosExclusiveObjectType mros_exclusive_area; 12 | extern mRosWaitQueueType mros_master_wait_queue; 13 | extern mRosWaitQueueType mros_subscribe_wait_queue; 14 | 15 | extern void mros_exclusive_area_init(mRosTaskIdType mas_task_id, 16 | mRosTaskIdType sub_task_id); 17 | 18 | #ifdef __cplusplus 19 | } 20 | #endif 21 | 22 | #endif /* _MROS_EXCLUSIVE_AREA_H_ */ 23 | -------------------------------------------------------------------------------- /src/device/peripheral/mros-dev/mros-src/protocol/cimpl/mros_protocol_subscribe_cimpl.h: -------------------------------------------------------------------------------- 1 | #ifndef _MROS_PROTOCOL_SUBSCRIBE_CIMPL_H_ 2 | #define _MROS_PROTOCOL_SUBSCRIBE_CIMPL_H_ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include "mros_types.h" 9 | 10 | typedef enum { 11 | MROS_PROTOCOL_SUBSCRIBE_STATE_WAITING = 0, 12 | MROS_PROTOCOL_SUBSCRIBE_STATE_PUB_CONNECTING, 13 | MROS_PROTOCOL_SUBSCRIBE_STATE_PUB_REQUESTING, 14 | } mRosProtocolSubscribeStateEnumType; 15 | 16 | extern mRosReturnType mros_protocol_subscribe_init(void); 17 | extern void mros_protocol_subscribe_run(void); 18 | 19 | #ifdef __cplusplus 20 | } 21 | #endif 22 | #endif /* _MROS_PROTOCOL_SUBSCRIBE_CIMPL_H_ */ 23 | -------------------------------------------------------------------------------- /src/lib/hash.h: -------------------------------------------------------------------------------- 1 | #ifndef _HASH_H_ 2 | #define _HASH_H_ 3 | 4 | #include "std_types.h" 5 | 6 | #define HASH_VALUE_CONTAINER_SIZE 4 7 | typedef struct { 8 | uint32 rawdata; 9 | uint8 data[HASH_VALUE_CONTAINER_SIZE]; 10 | } HashValueType; 11 | typedef uint32 HashIdType; 12 | 13 | #define HASHID_MIN 0 14 | #define HASHID_MAX 0 15 | #define HASHID_NUM 1 16 | #define HASHSIZE 119U 17 | 18 | extern void hash_init(void); 19 | extern HashValueType* hash_search(HashIdType id, HashValueType *value); 20 | extern void hash_add(HashIdType id, HashValueType *value); 21 | 22 | extern HashValueType* hash_first(HashIdType id); 23 | extern HashValueType* hash_next(HashIdType id); 24 | 25 | 26 | #endif /* _HASH_H_ */ 27 | -------------------------------------------------------------------------------- /src/debugger/executor/cpu_control/dbg_cpu_thread_control.h: -------------------------------------------------------------------------------- 1 | #ifndef _DBG_CPU_THREAD_CONTROL_H_ 2 | #define _DBG_CPU_THREAD_CONTROL_H_ 3 | 4 | extern void cputhr_control_init(void); 5 | extern void cputhr_control_start(void *(*cpu_run) (void *)); 6 | 7 | /* 8 | * for debugger 9 | */ 10 | extern void cputhr_control_dbg_waitfor_cpu_stopped(void); 11 | extern void cputhr_control_dbg_wakeup_cpu_and_wait_for_cpu_stopped(void); 12 | extern void cputhr_control_dbg_wait(void); 13 | extern void cputhr_control_dbg_wakeup_cpu(void); 14 | 15 | /* 16 | * for cpu 17 | */ 18 | extern void cputhr_control_cpu_wait(void); 19 | extern void cputhr_control_cpu_wakeup_dbg(void); 20 | 21 | 22 | #endif /* _DBG_CPU_THREAD_CONTROL_H_ */ 23 | -------------------------------------------------------------------------------- /src/device/peripheral/mros-dev/mros-src/os/mros_exclusive_area.c: -------------------------------------------------------------------------------- 1 | #include "mros_exclusive_area.h" 2 | #include "mros_wait_queue.h" 3 | #include "mros_sys_config.h" 4 | 5 | mRosExclusiveObjectType mros_exclusive_area MROS_MATTR_BSS_NOCLR; 6 | mRosWaitQueueType mros_master_wait_queue MROS_MATTR_BSS_NOCLR; 7 | 8 | mRosWaitQueueType mros_subscribe_wait_queue MROS_MATTR_BSS_NOCLR; 9 | 10 | void mros_exclusive_area_init(mRosTaskIdType mas_task_id, mRosTaskIdType sub_task_id) 11 | { 12 | mros_exclusive_init(&mros_exclusive_area, MROS_GIANT_EXCLUSIVE_AREA_PRIORITY); 13 | mros_server_queue_init(&mros_master_wait_queue, mas_task_id); 14 | mros_server_queue_init(&mros_subscribe_wait_queue, sub_task_id); 15 | 16 | return; 17 | } 18 | -------------------------------------------------------------------------------- /src/device/peripheral/mros-dev/mros-src/lib/mros_name.c: -------------------------------------------------------------------------------- 1 | #include "mros_name.h" 2 | #include 3 | 4 | void mros_name_formalize(const char *src_name, mros_uint32 src_namelen, char *dst_name, mros_uint32 *dst_namelen) 5 | { 6 | mros_uint32 i; 7 | mros_uint32 slash_count = 0; 8 | const char* src_copy_head = MROS_NULL; 9 | mros_uint32 src_copy_len; 10 | 11 | for (i = 0; i < src_namelen; i++) { 12 | if (src_name[i] != '/') { 13 | src_copy_head = &src_name[i]; 14 | break; 15 | } 16 | else { 17 | slash_count++; 18 | } 19 | } 20 | src_copy_len = src_namelen - slash_count; 21 | dst_name[0] = '/'; 22 | memcpy(&dst_name[1], src_copy_head, src_copy_len); 23 | dst_name[src_copy_len + 1] = '\0'; 24 | *dst_namelen = src_copy_len + 1; 25 | return; 26 | } 27 | -------------------------------------------------------------------------------- /src/device/peripheral/mros-dev/mros-src/topic/cimpl/mros_topic_connector_factory_cimpl.h: -------------------------------------------------------------------------------- 1 | #ifndef _MROS_TOPIC_CONNECTOR_FACTORY_CIMPL_H_ 2 | #define _MROS_TOPIC_CONNECTOR_FACTORY_CIMPL_H_ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include "mros_topic_connector_cimpl.h" 9 | 10 | typedef enum { 11 | MROS_TOPIC_CONNECTOR_PUB = 0, 12 | MROS_TOPIC_CONNECTOR_SUB, 13 | MROS_TOPIC_CONNECTOR_NUM, 14 | } mRosTopicConnectorEnumType; 15 | 16 | extern mRosTopicConnectorManagerType *mros_topic_connector_factory_create(mRosTopicConnectorEnumType type); 17 | extern mRosTopicConnectorManagerType *mros_topic_connector_factory_get(mRosTopicConnectorEnumType type); 18 | 19 | #ifdef __cplusplus 20 | } 21 | #endif 22 | #endif /* _MROS_TOPIC_CONNECTOR_FACTORY_CIMPL_H_ */ 23 | -------------------------------------------------------------------------------- /src/lib/dwarf/elf_dwarf_loc.h: -------------------------------------------------------------------------------- 1 | #ifndef _ELF_DWARF_LOC_H_ 2 | #define _ELF_DWARF_LOC_H_ 3 | 4 | #include "loader/elf.h" 5 | #include "elf_dwarf_util.h" 6 | #include "data_type/elf_dwarf_subprogram_type.h" 7 | #include "std_errno.h" 8 | 9 | struct ElfDwarfLocEntryType_tag; 10 | typedef struct ElfDwarfLocEntryType_tag { 11 | uint32 entryOffset; 12 | uint32 entrySize; 13 | uint32 relativeAddress0; 14 | uint32 relativeAddress1; 15 | uint16 block_length; 16 | uint8 *blocks; 17 | struct ElfDwarfLocEntryType_tag *next; 18 | } ElfDwarfLocEntryType; 19 | 20 | extern Std_ReturnType elf_dwarf_loc_load(uint8 *elf_data); 21 | extern bool printLocalValueV850(DwarfDataSubprogramType *subprogram, DwarfLocalVariableType *localVariable, uint32 pc, uint32 funcaddr, uint32 *vaddr); 22 | 23 | #endif /* _ELF_DWARF_LOC_H_ */ 24 | -------------------------------------------------------------------------------- /src/inc/athrill_device.h: -------------------------------------------------------------------------------- 1 | #ifndef _ATHRILL_DEVICE_H_ 2 | #define _ATHRILL_DEVICE_H_ 3 | 4 | #include "std_types.h" 5 | #include "cpu.h" 6 | #include "std_device_ops.h" 7 | #include "cpu.h" 8 | 9 | extern void device_init_athrill_device(void); 10 | extern void device_init_athrill_exdev(void); 11 | extern void device_add_athrill_exdev(void *devp, void *region); 12 | 13 | extern void device_supply_clock_athrill_device(void); 14 | extern void device_supply_clock_exdev(DeviceClockType *dev_clock); 15 | extern void athrill_device_cleanup(void); 16 | 17 | 18 | typedef struct { 19 | int fd; 20 | void *addr; 21 | } AthrillDeviceMmapInfoType; 22 | extern void athrill_device_set_mmap_info(AthrillDeviceMmapInfoType *info); 23 | 24 | extern void athrill_syscall_device(uint32 addr); 25 | 26 | #endif /* _ATHRILL_DEVICE_H_ */ 27 | -------------------------------------------------------------------------------- /src/lib/tcp/tcp_connection.h: -------------------------------------------------------------------------------- 1 | #ifndef _TCP_CONNECTION_H_ 2 | #define _TCP_CONNECTION_H_ 3 | 4 | #include "tcp_socket.h" 5 | 6 | typedef struct { 7 | TcpSocketType socket; 8 | bool connected; 9 | } TcpConnectionType; 10 | 11 | extern Std_ReturnType tcp_connection_send(TcpConnectionType *connection, const char *data, uint32 size, uint32 *res); 12 | extern Std_ReturnType tcp_connection_receive(TcpConnectionType *connection, char *data, uint32 size, uint32 *res); 13 | extern Std_ReturnType tcp_connection_send_nblk(TcpConnectionType *connection, const char *data, uint32 size, uint32 *res); 14 | extern Std_ReturnType tcp_connection_receive_nblk(TcpConnectionType *connection, char *data, uint32 size, uint32 *res); 15 | extern void tcp_connection_close(TcpConnectionType *connection); 16 | 17 | #endif /* _TCP_CONNECTION_H_ */ 18 | -------------------------------------------------------------------------------- /src/lib/dwarf/file_address_mapping.h: -------------------------------------------------------------------------------- 1 | #ifndef _FILE_ADDRESS_MAPPING_H_ 2 | #define _FILE_ADDRESS_MAPPING_H_ 3 | 4 | #include "std_types.h" 5 | #include "std_errno.h" 6 | 7 | typedef struct { 8 | uint32 addr; 9 | } KeyAddressType; 10 | 11 | typedef struct { 12 | char *dir; 13 | char *file; 14 | uint32 line; 15 | } ValueFileType; 16 | 17 | extern void file_address_mapping_init(void); 18 | extern Std_ReturnType file_address_mapping_get(uint32 addr, ValueFileType *value); 19 | extern Std_ReturnType file_address_mapping_get_addr(const char*file, uint32 line, KeyAddressType *value); 20 | extern Std_ReturnType file_address_mapping_get_candidate(const char*file, uint32 line, ValueFileType *value); 21 | extern Std_ReturnType file_address_mapping_get_last(KeyAddressType *key, ValueFileType *value); 22 | 23 | #endif /* _FILE_ADDRESS_MAPPING_H_ */ 24 | -------------------------------------------------------------------------------- /src/device/peripheral/mros-dev/mros-athrill/device/athrill_mros_device.h: -------------------------------------------------------------------------------- 1 | #ifndef _ATHRILL_MROS_DEVICE_H_ 2 | #define _ATHRILL_MROS_DEVICE_H_ 3 | 4 | #include "ros_cimpl.h" 5 | 6 | typedef struct { 7 | const char* topic_name; 8 | mRosPublisherType *pub; 9 | } AthrillMrosDevPubReqType; 10 | 11 | typedef struct { 12 | const char* topic_name; 13 | void (*callback) (const char *data, int datalen); 14 | mRosSubscriberType *sub; 15 | } AthrillMrosDevSubReqType; 16 | 17 | extern int athrill_mros_device_pub_register(AthrillMrosDevPubReqType *reqs, int req_num); 18 | extern int athrill_mros_device_sub_register(AthrillMrosDevSubReqType *reqs, int req_num); 19 | 20 | extern int athrill_mros_device_start(void); 21 | extern int athrill_mros_device_sub_read(mRosSubscriberType *sub, char *datap, int datalen, int *res); 22 | 23 | #endif /* _ATHRILL_MROS_DEVICE_H_ */ 24 | -------------------------------------------------------------------------------- /bin/linux/athrill-run: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | CORE_NUM=1 4 | if [ $# -eq 1 ] 5 | then 6 | CORE_NUM=2 7 | fi 8 | 9 | if [ -f device_config.txt ] 10 | then 11 | echo "OK: found device_config.txt" 12 | else 13 | echo "ERROR: not found device_config.txt" 14 | exit 1 15 | fi 16 | 17 | if [ -f memory.txt ] 18 | then 19 | echo "OK: found memory.txt" 20 | else 21 | echo "ERROR: not found memory.txt" 22 | exit 1 23 | fi 24 | 25 | ls | grep -v "\.o" | grep -v "\.exe" | xargs file | grep ELF > /dev/null 26 | if [ $? -ne 0 ] 27 | then 28 | echo "ERROR: not found elf file for execution" 29 | exit 1 30 | fi 31 | 32 | ELF_FILE=`ls | grep -v "\.o" | grep -v "\.exe" | xargs file | grep ELF | awk -F\: '{print $1}'` 33 | echo "OK: found ${ELF_FILE}" 34 | 35 | athrill2 -c${CORE_NUM} -i -m memory.txt -d device_config.txt ${ELF_FILE} 36 | 37 | exit 0 38 | -------------------------------------------------------------------------------- /bin/linux/athrill-run-remote: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | CORE_NUM=1 4 | if [ $# -eq 1 ] 5 | then 6 | CORE_NUM=2 7 | fi 8 | 9 | if [ -f device_config.txt ] 10 | then 11 | echo "OK: found device_config.txt" 12 | else 13 | echo "ERROR: not found device_config.txt" 14 | exit 1 15 | fi 16 | 17 | if [ -f memory.txt ] 18 | then 19 | echo "OK: found memory.txt" 20 | else 21 | echo "ERROR: not found memory.txt" 22 | exit 1 23 | fi 24 | 25 | ls | grep -v "\.o" | grep -v "\.exe" | xargs file | grep ELF > /dev/null 26 | if [ $? -ne 0 ] 27 | then 28 | echo "ERROR: not found elf file for execution" 29 | exit 1 30 | fi 31 | 32 | ELF_FILE=`ls | grep -v "\.o" | grep -v "\.exe" | xargs file | grep ELF | awk -F\: '{print $1}'` 33 | echo "OK: found ${ELF_FILE}" 34 | 35 | athrill2 -c${CORE_NUM} -r -i -m memory.txt -d device_config.txt ${ELF_FILE} 36 | 37 | exit 0 38 | -------------------------------------------------------------------------------- /src/debugger/interaction/front/parser/dbg_parser_config.c: -------------------------------------------------------------------------------- 1 | #include "front/parser/dbg_parser_config.h" 2 | #include "front/parser/concrete_parser/dbg_std_parser.h" 3 | 4 | DbgCmdParserTableType dbg_cmd_parser_std_table[DBG_CMD_STD_ID_NUM] = { 5 | { dbg_parse_break, }, 6 | { dbg_parse_delete, }, 7 | { dbg_parse_intr, }, 8 | { dbg_parse_watch_data, }, 9 | { dbg_parse_cont, }, 10 | { dbg_parse_core, }, 11 | { dbg_parse_elaps, }, 12 | { dbg_parse_next, }, 13 | { dbg_parse_return, }, 14 | { dbg_parse_view, }, 15 | { dbg_parse_print, }, 16 | { dbg_parse_memset, }, 17 | { dbg_parse_quit, }, 18 | { dbg_parse_exit, }, 19 | { dbg_parse_serialin, }, 20 | { dbg_parse_info_cpu, }, 21 | { dbg_parse_func_trace, }, 22 | { dbg_parse_data_access_info, }, 23 | { dbg_parse_back_trace, }, 24 | { dbg_parse_profile, }, 25 | { dbg_parse_list, }, 26 | { dbg_parse_help, }, 27 | }; 28 | -------------------------------------------------------------------------------- /src/lib/udp/udp_comm.h: -------------------------------------------------------------------------------- 1 | #ifndef _UDP_SERVER_H_ 2 | #define _UDP_SERVER_H_ 3 | 4 | #include "target/target_os_api.h" 5 | #include "udp_common.h" 6 | 7 | typedef struct { 8 | TARGET_OS_SOCKET_TYPE srv_sock; 9 | UdpBufferType read_data; 10 | 11 | uint32 client_port; 12 | TARGET_OS_SOCKET_TYPE clt_sock; 13 | UdpBufferType write_data; 14 | } UdpCommType; 15 | 16 | extern Std_ReturnType udp_comm_create(const UdpCommConfigType *config, UdpCommType *comm); 17 | extern Std_ReturnType udp_comm_create_ipaddr(const UdpCommConfigType *config, UdpCommType *comm, const char* my_ipaddr); 18 | 19 | extern Std_ReturnType udp_comm_read(UdpCommType *comm); 20 | extern Std_ReturnType udp_comm_write(UdpCommType *comm); 21 | extern Std_ReturnType udp_comm_remote_write(UdpCommType *comm, const char *remote_ipaddr); 22 | extern void udp_server_delete(UdpCommType *comm); 23 | 24 | #endif /* _UDP_SERVER_H_ */ 25 | -------------------------------------------------------------------------------- /src/device/peripheral/mros-dev/mros-src/os/target/os_asp/mros_os.c: -------------------------------------------------------------------------------- 1 | #include "mros_os_target.h" 2 | 3 | mRosTaskIdType mros_get_taskid(void) 4 | { 5 | mRosTaskIdType tid; 6 | (void)get_tid(&tid); 7 | return tid; 8 | } 9 | 10 | mRosTaskPriorityType mros_get_taskpri(void) 11 | { 12 | mRosTaskIdType tid; 13 | PRI pri; 14 | (void)get_tid(&tid); 15 | (void)get_pri(tid, &pri); 16 | return pri; 17 | } 18 | 19 | void mros_change_taskpri(mRosTaskPriorityType priority) 20 | { 21 | mRosTaskIdType tid; 22 | (void)get_tid(&tid); 23 | chg_pri(tid, priority); 24 | return; 25 | } 26 | 27 | void mros_sleep_task(void) 28 | { 29 | (void)slp_tsk(); 30 | return; 31 | } 32 | 33 | void mros_sleep_task_msec(mRosTaskSleepIntervalType msec) 34 | { 35 | (void)dly_tsk(msec); 36 | return; 37 | } 38 | 39 | void mros_wakeup_task(mRosTaskIdType task_id) 40 | { 41 | (void)wup_tsk(task_id); 42 | return; 43 | } 44 | 45 | -------------------------------------------------------------------------------- /src/device/peripheral/mros-dev/mros-src/inc/mros_exclusive_ops.h: -------------------------------------------------------------------------------- 1 | #ifndef _MROS_EXCLUSIVE_OPS_H_ 2 | #define _MROS_EXCLUSIVE_OPS_H_ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include "mros_types.h" 9 | #include "mros_os.h" 10 | 11 | 12 | typedef struct { 13 | /* 14 | * 排他エリアのプライオリティ 15 | * 排他エリア内では,タスクのプライオリティは本プライオリティに引き上げられる 16 | */ 17 | mRosTaskPriorityType priority; 18 | } mRosExclusiveObjectType; 19 | 20 | typedef struct { 21 | mRosTaskPriorityType org_priority; 22 | } mROsExclusiveUnlockObjType; 23 | 24 | extern void mros_exclusive_init(mRosExclusiveObjectType *exobj, mRosTaskPriorityType priority); 25 | extern void mros_exclusive_lock(mRosExclusiveObjectType *exobj, mROsExclusiveUnlockObjType *unlock_obj); 26 | extern void mros_exclusive_unlock(mROsExclusiveUnlockObjType *unlock_objj); 27 | 28 | #ifdef __cplusplus 29 | } 30 | #endif 31 | 32 | #endif /* _MROS_EXCLUSIVE_OPS_H_ */ 33 | -------------------------------------------------------------------------------- /src/device/peripheral/mros-dev/mros-src/packet/template/version/kinetic/mros_packet_fmt_http.h: -------------------------------------------------------------------------------- 1 | #ifndef _MROS_PACKET_FMT_HTTP_H_ 2 | #define _MROS_PACKET_FMT_HTTP_H_ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #define MROS_PACKET_HTT_OK_CODE_LEN 3 9 | #define MROS_PACKET_HTT_OK_CODE "200" 10 | 11 | /* 12 | * ARG1: xml size 13 | */ 14 | #define MROS_PACKET_FMT_HTTP_POST \ 15 | "POST /RPC2 HTTP/1.1\n" \ 16 | "Host: \n" \ 17 | "Accept-Encoding: \n" \ 18 | "User-Agent: \n" \ 19 | "Content-Type: \n" \ 20 | "Content-Length: %u\n\n" \ 21 | 22 | 23 | /* 24 | * ARG1: xml size 25 | */ 26 | #define MROS_PACKET_FMT_HTTP_OK \ 27 | "HTTP/1.1 200 OK\n" \ 28 | "Host: \n" \ 29 | "Accept-Encoding: \n" \ 30 | "User-Agent: \n" \ 31 | "Content-Type: \n" \ 32 | "Content-Length: %u\n\n" \ 33 | 34 | #ifdef __cplusplus 35 | } 36 | #endif 37 | 38 | #endif /* _MROS_PACKET_FMT_HTTP_H_ */ 39 | -------------------------------------------------------------------------------- /src/debugger/executor/concrete_executor/target/dbg_target_serial.h: -------------------------------------------------------------------------------- 1 | #ifndef _DBG_TARGET_SERIAL_H_ 2 | #define _DBG_TARGET_SERIAL_H_ 3 | 4 | #include "std_types.h" 5 | #include "std_errno.h" 6 | 7 | extern Std_ReturnType dbg_serial_in(uint8 channel, uint8 data); 8 | 9 | extern bool dbg_serial_getchar(uint8 channel, uint8 *data); 10 | extern bool dbg_serial_putchar(uint8 channel, uint8 data); 11 | 12 | extern bool dbg_serial_getchar_file(uint8 channel, uint8 *data); 13 | extern bool dbg_serial_putchar_file(uint8 channel, uint8 data); 14 | extern void dbg_serial_flush_file(uint8 channel); 15 | 16 | 17 | extern Std_ReturnType dbg_serial_init_tcp(uint8 channel_num); 18 | extern Std_ReturnType dbg_serial_open_tcp(uint8 channel, uint32 server_portno); 19 | extern bool dbg_serial_getchar_tcp(uint8 channel, uint8 *data); 20 | extern bool dbg_serial_putchar_tcp(uint8 channel, uint8 data); 21 | 22 | 23 | #endif /* _DBG_TARGET_SERIAL_H_ */ 24 | -------------------------------------------------------------------------------- /src/device/peripheral/mros-dev/mros-src/packet/cimpl/mros_packet_cimpl.h: -------------------------------------------------------------------------------- 1 | #ifndef _MROS_PACKET_CIMPL_H_ 2 | #define _MROS_PACKET_CIMPL_H_ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include "mros_types.h" 9 | 10 | typedef enum { 11 | MROS_PACKET_DATA_REGISTER_PUBLISHER_REQ = 0, 12 | MROS_PACKET_DATA_REGISTER_SUBSCRIBER_REQ, 13 | MROS_PACKET_DATA_REQUEST_TOPIC_REQ, 14 | MROS_PACKET_DATA_REQUEST_TOPIC_RES, 15 | MROS_PACKET_DATA_PUBLISHER_UPDATE_REQ, 16 | MROS_PACKET_DATA_TCPROS_TOPIC_REQ, 17 | MROS_PACKET_DATA_TCPROS_TOPIC_RES, 18 | MROS_PACKET_DATA_TOPIC, 19 | MROS_PACKET_DATA_NUM, 20 | } mRosPacketDataEnumType; 21 | #define MROS_PACKET_DATA_INVALID MROS_PACKET_DATA_NUM 22 | 23 | typedef struct { 24 | mRosSizeType total_size; 25 | mRosSizeType data_size; 26 | char *data; 27 | } mRosPacketType; 28 | 29 | #ifdef __cplusplus 30 | } 31 | #endif 32 | 33 | #endif /* _MROS_PACKET_CIMPL_H_ */ 34 | -------------------------------------------------------------------------------- /src/debugger/executor/cpu_control/dbg_cpu_callback.h: -------------------------------------------------------------------------------- 1 | #ifndef _DBG_CPU_CALLBACK_H_ 2 | #define _DBG_CPU_CALLBACK_H_ 3 | 4 | #include "std_types.h" 5 | #include "cpu_config.h" 6 | #include "target_cpu.h" 7 | #include "dbg_log.h" 8 | 9 | typedef struct { 10 | uint32 enable_ft; 11 | uint32 enable_bt; 12 | uint32 enable_prof; 13 | uint32 enable_watch; 14 | /* 15 | * enable sync real time and virtual time. 16 | */ 17 | uint32 enable_sync_time; 18 | uint32 show_skip_time; 19 | uint32 reset_pc; 20 | } DbgCpuCallbackFuncEnableType; 21 | 22 | extern void dbg_notify_cpu_clock_supply_start(const TargetCoreType *core); 23 | extern void dbg_notify_cpu_clock_supply_end(const TargetCoreType *core, const DbgCpuCallbackFuncEnableType *enable_dbg); 24 | 25 | extern std_bool private_cpuemu_is_cui_mode; 26 | 27 | static inline std_bool cpuemu_cui_mode(void) 28 | { 29 | return private_cpuemu_is_cui_mode; 30 | } 31 | #endif /* _DBG_CPU_CALLBACK_H_ */ 32 | -------------------------------------------------------------------------------- /src/device/peripheral/mros-dev/mros-src/os/target/os_asp/mros_os_target.h: -------------------------------------------------------------------------------- 1 | #ifndef _MROS_OS_TARGET_H_ 2 | #define _MROS_OS_TARGET_H_ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | #include 10 | 11 | #include "mros_types.h" 12 | 13 | typedef ID mRosTaskIdType; 14 | typedef PRI mRosTaskPriorityType; 15 | typedef mros_uint32 mRosTaskSleepIntervalType; 16 | 17 | #define MROS_TASK_MAX_PRIORITY TMIN_TPRI 18 | #define MROS_TASK_MIN_PRIORITY TMAX_TPRI 19 | 20 | #define MROS_LOG_EMRG LOG_EMERG 21 | #define MROS_LOG_ALERT LOG_ALERT 22 | #define MROS_LOG_CRIT LOG_CRIT 23 | #define MROS_LOG_ERROR LOG_ERROR 24 | #define MROS_LOG_WARNING LOG_WARNING 25 | #define MROS_LOG_NOTICE LOG_NOTICE 26 | #define MROS_LOG_INFO LOG_INFO 27 | #define MROS_LOG_DEBUG LOG_DEBUG 28 | 29 | #include "mros_log.h" 30 | 31 | 32 | #ifdef __cplusplus 33 | } 34 | #endif 35 | 36 | 37 | #endif /* _MROS_OS_TARGET_H_ */ 38 | -------------------------------------------------------------------------------- /src/lib/cui/cui_ops.h: -------------------------------------------------------------------------------- 1 | #ifndef _CUI_OPS_H_ 2 | #define _CUI_OPS_H_ 3 | 4 | #include "std_types.h" 5 | 6 | typedef struct { 7 | int (*cui_getline) (char *line, int size); 8 | void (*cui_write) (char *line, int size); 9 | void (*cui_close) (void); 10 | } FileOpType; 11 | extern int cui_fileop_register(FileOpType *fileop); 12 | 13 | extern int cui_getline(char *line, int size); 14 | extern void cui_write(char *line, int size); 15 | extern void cui_close(void); 16 | 17 | #define CUI_BUFP_LEN (1024U) 18 | typedef struct { 19 | uint32 write_len; 20 | char p[CUI_BUFP_LEN]; 21 | } CuiPrintBufferType; 22 | 23 | extern CuiPrintBufferType CuiPrintBuffer; 24 | #define CPU_PRINT_BUF() ((CuiPrintBuffer.p)) 25 | #define CPU_PRINT_BUF_LEN() (CUI_BUFP_LEN) 26 | 27 | #define CUI_PRINTF(arg) \ 28 | do { \ 29 | CuiPrintBuffer.write_len = snprintf arg; \ 30 | cui_write(CPU_PRINT_BUF(), CuiPrintBuffer.write_len); \ 31 | } while (0) 32 | #endif /* _CUI_OPS_H_ */ 33 | -------------------------------------------------------------------------------- /src/device/peripheral/mros-dev/mros-src/protocol/cimpl/mros_protocol_operation_cimpl.h: -------------------------------------------------------------------------------- 1 | #ifndef _MROS_PROTOCOL_OPERATION_CIMPL_H_ 2 | #define _MROS_PROTOCOL_OPERATION_CIMPL_H_ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include "mros_memory.h" 9 | #include "mros_comm_tcp_client_cimpl.h" 10 | 11 | extern mRosReturnType mros_protocol_topic_data_send(mRosCommTcpClientType *client, const char *data, mRosSizeType datalen); 12 | extern mRosReturnType mros_protocol_topic_data_receive(mRosCommTcpClientType *client, mRosMemoryManagerType *mempool, mRosMemoryListEntryType **retp); 13 | 14 | extern mRosSizeType mros_protocol_get_buffersize(mRosSizeType body_size); 15 | extern char* mros_protocol_get_body(char *buffer); 16 | 17 | /* 18 | * reqp: mRosCommTcpClientListReqEntryType 19 | */ 20 | extern void mros_protocol_client_obj_free(void* reqp); 21 | 22 | 23 | #ifdef __cplusplus 24 | } 25 | #endif 26 | #endif /* _MROS_PROTOCOL_OPERATION_CIMPL_H_ */ 27 | -------------------------------------------------------------------------------- /src/device/peripheral/mros-dev/mros-src/node/cimpl/mros_node_cimpl.h: -------------------------------------------------------------------------------- 1 | #ifndef _MROS_NODE_CIMPL_H_ 2 | #define _MROS_NODE_CIMPL_H_ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include "mros_types.h" 9 | 10 | typedef enum { 11 | MROS_NODE_TYPE_INNER = 0, 12 | MROS_NODE_TYPE_OUTER, 13 | MROS_NODE_TYPE_NUM, 14 | } mRosNodeEnumType; 15 | 16 | 17 | extern mRosReturnType mros_node_init(void); 18 | extern mRosReturnType mros_node_get_byname(const char *node_name, mRosNodeIdType *id); 19 | extern mRosReturnType mros_node_get_bytid(mRosNodeIdType *id); 20 | extern mRosNodeEnumType mros_node_type(mRosNodeIdType id); 21 | extern const char* mros_node_name(mRosNodeIdType id); 22 | 23 | extern mRosReturnType mros_node_create_inner(const char *node_name, mRosNodeIdType *id); 24 | extern mRosReturnType mros_node_create_outer(mRosNodeIdType *id); 25 | 26 | extern mRosReturnType mros_node_remove(mRosNodeIdType id); 27 | 28 | #ifdef __cplusplus 29 | } 30 | #endif 31 | #endif /* _MROS_NODE_CIMPL_H_ */ 32 | -------------------------------------------------------------------------------- /src/device/peripheral/mros-dev/mros-athrill/target/os/kernel.h: -------------------------------------------------------------------------------- 1 | #ifndef _KERNEL_H_ 2 | #define _KERNEL_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | typedef int ID; 8 | typedef int PRI; 9 | 10 | extern int slp_tsk(void); 11 | extern int act_tsk(ID); 12 | extern int get_tid(ID *p_tskid); 13 | extern int chg_pri(ID tskid, PRI tskpri); 14 | extern int iwup_tsk(ID tskid); 15 | extern int get_pri(ID tskid, PRI *p_tskpri); 16 | extern int dly_tsk(int dlytim); 17 | extern int wup_tsk(ID tskid); 18 | 19 | extern pthread_mutex_t mutex_lock; 20 | extern pthread_cond_t cond_wait; 21 | 22 | #include "kernel_cfg.h" 23 | 24 | 25 | typedef struct { 26 | int tskid; 27 | int lockCount; 28 | } OsSaveLockType; 29 | extern void os_save_unlock(OsSaveLockType *save); 30 | extern void os_restore_lock(OsSaveLockType *save); 31 | extern void os_lock_recursive(void); 32 | extern void os_unlock_recursive(void); 33 | 34 | #define TMAX_TPRI 1 35 | 36 | typedef int* mros_intptr_t; 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /src/debugger/interaction/inc/dbg_interaction_std_ids.h: -------------------------------------------------------------------------------- 1 | #ifndef _DBG_INTERACTION_STD_IDS_H_ 2 | #define _DBG_INTERACTION_STD_IDS_H_ 3 | 4 | typedef enum { 5 | DBG_CMD_STD_ID_PARSE_ERROR = 0, 6 | DBG_CMD_STD_ID_BREAK, 7 | DBG_CMD_STD_ID_DELETE, 8 | DBG_CMD_STD_ID_CONT, 9 | DBG_CMD_STD_ID_CORE, 10 | DBG_CMD_STD_ID_INTR, 11 | DBG_CMD_STD_ID_DATA_WATCH, 12 | DBG_CMD_STD_ID_ELAPS, 13 | DBG_CMD_STD_ID_NEXT, 14 | DBG_CMD_STD_ID_RETURN, 15 | DBG_CMD_STD_ID_VIEW, 16 | DBG_CMD_STD_ID_PRINT, 17 | DBG_CMD_STD_ID_MEMSET, 18 | DBG_CMD_STD_ID_QUIT, 19 | DBG_CMD_STD_ID_EXIT, 20 | DBG_CMD_STD_ID_SERIALIN, 21 | DBG_CMD_STD_ID_INFO_CPU, 22 | DBG_CMD_STD_ID_FUNC_TRACE, 23 | DBG_CMD_STD_ID_DATA_ACCESS_INFO, 24 | DBG_CMD_STD_ID_BACK_TRACE, 25 | DBG_CMD_STD_ID_PROFILE, 26 | DBG_CMD_STD_ID_LIST, 27 | DBG_CMD_STD_ID_HELP, 28 | DBG_CMD_STD_ID_TARGET 29 | } DbgCmdStdIdType; 30 | 31 | #define DBG_CMD_STD_ID_NUM (DBG_CMD_STD_ID_TARGET - 1) //DBG_CMD_STD_ID_PARSE_ERRORは含まない. 32 | 33 | #endif /* _DBG_INTERACTION_STD_IDS_H_ */ 34 | -------------------------------------------------------------------------------- /src/device/peripheral/mros-dev/mros-src/inc/mros_array_container.h: -------------------------------------------------------------------------------- 1 | #ifndef _MROS_ARRAY_CONTAINER_H_ 2 | #define _MROS_ARRAY_CONTAINER_H_ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include "mros_types.h" 9 | 10 | typedef struct { 11 | mros_uint32 count; 12 | mros_uint32 array_num; 13 | mRosContainerObjType *array; 14 | } mRosArrayContainerType; 15 | 16 | #define MROS_ARRAY_CONTAINER_CONFIG_DECLARE_MANAGER(manager_name, array_num) \ 17 | static mRosContainerObjType manager_name##_array [(array_num)] MROS_MATTR_BSS_NOCLR; \ 18 | static mRosArrayContainerType manager_name = { \ 19 | (0), \ 20 | (array_num), \ 21 | manager_name##_array, \ 22 | }; 23 | 24 | static inline void mros_array_container_add(mRosArrayContainerType *mgrp, mRosContainerObjType obj) 25 | { 26 | if (mgrp->count >= mgrp->array_num) { 27 | return; 28 | } 29 | mgrp->array[mgrp->count] = obj; 30 | mgrp->count++; 31 | } 32 | #ifdef __cplusplus 33 | } 34 | #endif 35 | 36 | #endif /* _MROS_ARRAY_CONTAINER_H_ */ 37 | -------------------------------------------------------------------------------- /command/remote/remote_cui_client/Makefile: -------------------------------------------------------------------------------- 1 | ROOTDIR := ../../../src 2 | TARGETDIR := . 3 | BINDIR := ../../../bin/linux/ 4 | TARGET := athrill_remote 5 | 6 | WFLAGS := -g -Wall 7 | GCC := gcc 8 | 9 | IFLAGS := -I$(ROOTDIR)/inc 10 | IFLAGS += -I$(ROOTDIR)/lib 11 | 12 | VPATH := $(TARGETDIR) 13 | VPATH += $(ROOTDIR)/lib/winsock_wrapper 14 | VPATH += $(ROOTDIR)/lib/udp 15 | 16 | 17 | 18 | CFLAGS := $(WFLAGS) 19 | CFLAGS += $(IFLAGS) 20 | CFLAGS += -DOS_LINUX 21 | 22 | UNAME_S := $(shell uname -s) 23 | ifeq ($(UNAME_S),Darwin) 24 | LFLAGS := -Wl,-multiply_defined,suppress 25 | else 26 | LFLAGS := -Wl,--allow-multiple-definition 27 | endif 28 | 29 | LIBS := -lpthread 30 | 31 | OBJS := main.o 32 | OBJS += udp_comm.o 33 | 34 | 35 | .SUFFIXES: .c .o 36 | 37 | all: $(TARGET) 38 | 39 | $(TARGET): $(OBJS) 40 | $(GCC) -O3 $(LFLAGS) $(OBJS) -o $(TARGET) $(LIBS) 41 | cp $(TARGET) $(BINDIR)/$(TARGET) 42 | 43 | .c.o: $< 44 | $(GCC) -O3 -c $(CFLAGS) $< 45 | 46 | clean: 47 | rm -f $(OBJS) $(TARGET) $(BINDIR)/$(TARGET) 48 | -------------------------------------------------------------------------------- /src/device/peripheral/mros-dev/mros-src/packet/cimpl/version/kinetic/mros_packet_config.h: -------------------------------------------------------------------------------- 1 | #ifndef _MROS_PACKET_CONFIG_H_ 2 | #define _MROS_PACKET_CONFIG_H_ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #define MROS_TOPIC_RAWDATA_HEADER_SIZE 4 9 | #define MROS_TCPROS_RAWDATA_HEADER_SIZE 4 10 | 11 | /************************************** 12 | * PACKET 13 | **************************************/ 14 | #define MROS_PACKET_MAXSIZE_REQ_REGISTER_PUBLISHER 1024 15 | #define MROS_PACKET_MAXSIZE_RES_REGISTER_PUBLISHER 1024 16 | #define MROS_PACKET_MAXSIZE_REQ_REGISTER_SUBSCRIBER 1024 17 | #define MROS_PACKET_MAXSIZE_RES_REGISTER_SUBSCRIBER 1024 18 | #define MROS_PACKET_MAXSIZE_REQ_REQUEST_TOPIC 1024 19 | #define MROS_PACKET_MAXSIZE_RES_REQUEST_TOPIC 1024 20 | #define MROS_PACKET_MAXSIZE_REQ_PUBLISHER_UPDATE 1024 21 | 22 | 23 | #define MROS_PACKET_MAXSIZE_REQ_TCPROS 512 24 | #define MROS_PACKET_MAXSIZE_RES_TCPROS 512 25 | 26 | 27 | #ifdef __cplusplus 28 | } 29 | #endif 30 | 31 | #endif /* _MROS_PACKET_CONFIG_H_ */ 32 | -------------------------------------------------------------------------------- /src/device/peripheral/mros-dev/mros-src/protocol/cimpl/mros_protocol_master_cimpl.h: -------------------------------------------------------------------------------- 1 | #ifndef _MROS_PROTOCOL_MASTER_CIMPL_H_ 2 | #define _MROS_PROTOCOL_MASTER_CIMPL_H_ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include "mros_types.h" 9 | 10 | typedef enum { 11 | MROS_PROTOCOL_MASTER_STATE_WAITING = 0, 12 | MROS_PROTOCOL_MASTER_STATE_REGISTER_PUBLISHER, 13 | MROS_PROTOCOL_MASTER_STATE_REGISTER_SUBSCRIBER, 14 | MROS_PROTOCOL_MASTER_STATE_REQUESTING_TOPIC, 15 | } mRosProtocolMasterStateEnumType; 16 | 17 | typedef enum { 18 | MROS_PROTOCOL_MASTER_REQ_REGISTER_PUBLISHER = 0, 19 | MROS_PROTOCOL_MASTER_REQ_REGISTER_SUBSCRIBER, 20 | } mRosProtocolMasterRequestEnumType; 21 | 22 | typedef struct { 23 | mRosProtocolMasterRequestEnumType req_type; 24 | mRosContainerObjType connector_obj; 25 | } mRosProtocolMasterRequestType; 26 | 27 | extern mRosReturnType mros_protocol_master_init(void); 28 | extern void mros_protocol_master_run(void); 29 | 30 | #ifdef __cplusplus 31 | } 32 | #endif 33 | #endif /* _MROS_PROTOCOL_MASTER_CIMPL_H_ */ 34 | -------------------------------------------------------------------------------- /src/inc/athrill_mpthread.h: -------------------------------------------------------------------------------- 1 | #ifndef _ATHRILL_MPTHREAD_H_ 2 | #define _ATHRILL_MPTHREAD_H_ 3 | 4 | #include "std_types.h" 5 | #include "std_errno.h" 6 | 7 | typedef uint32 MpthrIdType; 8 | typedef struct { 9 | Std_ReturnType (*do_init) (MpthrIdType id); 10 | Std_ReturnType (*do_proc) (MpthrIdType id); 11 | } MpthrOperationType; 12 | 13 | /* 14 | * Manager api 15 | */ 16 | extern Std_ReturnType mpthread_init(void); 17 | extern Std_ReturnType mpthread_register(MpthrIdType *id, MpthrOperationType *op); 18 | 19 | /* 20 | * Thread api 21 | */ 22 | typedef enum { 23 | MPTHR_STATUS_INITIALIZING = 0, 24 | MPTHR_STATUS_RUNNING, 25 | MPTHR_STATUS_WAITING, 26 | } MpthrStatusType; 27 | extern void mpthread_lock(MpthrIdType id); 28 | extern void mpthread_unlock(MpthrIdType id); 29 | extern MpthrStatusType mpthread_get_status(MpthrIdType id); 30 | extern Std_ReturnType mpthread_start_proc(MpthrIdType id); 31 | extern Std_ReturnType mpthread_wait_proc(MpthrIdType id); 32 | extern Std_ReturnType mpthread_timedwait_proc(MpthrIdType id, sint32 timeout); 33 | 34 | #endif /* _ATHRILL_MPTHREAD_H_ */ -------------------------------------------------------------------------------- /bin/windows/athrill_scenario_cmd.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | function athrill_cont() { 4 | athrill_remote c ${1} 5 | } 6 | 7 | CPU_ELAPS="" 8 | function athrill_elaps() { 9 | RET=`athrill_remote e` 10 | CPU_ELAPS=`echo ${RET} | awk '{print $1}'` 11 | } 12 | 13 | MEMORY_VALUE="" 14 | function athrill_print_memory() { 15 | ADDR=${1} 16 | SIZE=${2} 17 | 18 | if [ ${SIZE} -gt 4 ] 19 | then 20 | echo "ERROR: can not print memory data size over 4bytes" 21 | else 22 | RET=`athrill_remote p ${ADDR} ${SIZE}` 23 | MEMORY_VALUE=`echo ${RET} | awk '{print $1}'` 24 | fi 25 | } 26 | 27 | VARIABLE_VALUE="" 28 | function athrill_print_variable() { 29 | RET=`athrill_remote p ${1}` 30 | ADDR=`echo ${RET} | awk '{print $1}'` 31 | SIZE=`echo ${RET} | awk '{print $2}'` 32 | athrill_print_memory ${ADDR} ${SIZE} 33 | VARIABLE_VALUE=${MEMORY_VALUE} 34 | } 35 | 36 | 37 | #SAMPLE USAGE 38 | #athrill_cont 10 39 | #athrill_elaps 40 | #echo ${CPU_ELAPS} 41 | #athrill_print_variable gl_variable1 42 | #echo ${VARIABLE_VALUE} 43 | #athrill_print_memory 0x6ff7408 2 44 | #echo ${VARIABLE_VALUE} 45 | -------------------------------------------------------------------------------- /src/lib/file.h: -------------------------------------------------------------------------------- 1 | #ifndef _FILE_H_ 2 | #define _FILE_H_ 3 | 4 | #include "std_types.h" 5 | #include "token.h" 6 | 7 | extern bool file_exist(const char *path); 8 | 9 | #define MAX_FILE_SIZE ((uint32)(1024 * 1024 * 10)) 10 | typedef struct { 11 | TokenStringType filepath; 12 | void *fp; 13 | uint32 size; 14 | uint8 buffer[MAX_FILE_SIZE]; 15 | } FileType; 16 | extern bool file_load(FileType *file); 17 | 18 | extern uint32 file_get_parent_folder_pathlen(const char *filepath); 19 | 20 | extern bool file_ropen(FileType *file); 21 | extern bool file_wopen(FileType *file); 22 | extern bool file_ropen_filepath(const char *dir, const char *filename, FileType *file); 23 | extern uint32 file_getline(FileType *file, char *line, int size); 24 | extern uint32 file_readline(FileType *file, char *line, int size, int lineno); 25 | 26 | extern void file_putline(FileType *file, char *line, int size); 27 | extern void file_appendline(FileType *file); 28 | 29 | extern void file_close(FileType *file); 30 | 31 | extern bool file_printline(const char *dir, const char *filename, FileType *file, uint32 start, uint32 end); 32 | 33 | #endif /* _FILE_H_ */ 34 | -------------------------------------------------------------------------------- /src/lib/comm_buffer.h: -------------------------------------------------------------------------------- 1 | #ifndef _COMM_BUFFER_H_ 2 | #define _COMM_BUFFER_H_ 3 | 4 | #include "std_types.h" 5 | #include "std_errno.h" 6 | 7 | typedef struct { 8 | uint32 max_size; 9 | uint32 count; 10 | uint32 rx_off; 11 | uint32 tx_off; 12 | char* data; 13 | } CommFifoBufferType; 14 | extern Std_ReturnType comm_fifo_buffer_create(uint32 size, CommFifoBufferType *fifop); 15 | extern Std_ReturnType comm_fifo_buffer_add(CommFifoBufferType *fifop, const char* datap, uint32 datalen, uint32 *res); 16 | extern Std_ReturnType comm_fifo_buffer_get(CommFifoBufferType *fifop, char* datap, uint32 datalen, uint32 *res); 17 | extern void comm_fifo_buffer_close(CommFifoBufferType *fifop); 18 | extern void comm_fifo_buffer_destroy(CommFifoBufferType *fifop); 19 | 20 | #define COMM_FIFO_IS_EMPTY(fifop) ((fifop)->count == 0) 21 | #define COMM_FIFO_IS_FULL(fifop) ((fifop)->count >= (fifop)->max_size) 22 | 23 | typedef struct { 24 | uint32 max_size; 25 | char* data; 26 | } CommBufferType; 27 | extern Std_ReturnType comm_buffer_create(uint32 size, CommBufferType *bufferp); 28 | extern void comm_buffer_destroy(CommBufferType *bufferp); 29 | 30 | 31 | #endif /* _COMM_BUFFER_H_ */ 32 | -------------------------------------------------------------------------------- /src/lib/dwarf/data_type/elf_dwarf_base_type.c: -------------------------------------------------------------------------------- 1 | #include "elf_dwarf_base_type.h" 2 | #include "assert.h" 3 | 4 | void elf_dwarf_build_base_type(ElfDwarfDieType *die) 5 | { 6 | int i; 7 | uint32 size; 8 | DwarfDataBaseType *obj = dwarf_alloc_data_type(DATA_TYPE_BASE); 9 | ElfDwarfAttributeType *attr; 10 | ElfDwarfAbbrevType *abbrev; 11 | DwAtType attr_type; 12 | 13 | for (i = 0; i < die->attribute->current_array_size; i++) { 14 | abbrev = (ElfDwarfAbbrevType *)die->abbrev_info; 15 | attr = (ElfDwarfAttributeType*)die->attribute->data[i]; 16 | attr_type = abbrev->attribute_name->data[i]; 17 | 18 | switch (attr_type) { 19 | case DW_AT_byte_size: 20 | obj->info.size = elf_dwarf_info_get_value(abbrev->attribute_form->data[i], attr, &size); 21 | break; 22 | case DW_AT_name: 23 | obj->info.typename = attr->encoded.string; 24 | break; 25 | case DW_AT_encoding: 26 | obj->encoding = elf_dwarf_info_get_value(abbrev->attribute_form->data[i], attr, &size); 27 | //printf("encoding=0x%x\n", obj->encoding); 28 | break; 29 | default: 30 | ASSERT(0); 31 | } 32 | } 33 | obj->info.die = die; 34 | 35 | dwarf_register_data_type(&obj->info); 36 | return; 37 | } 38 | -------------------------------------------------------------------------------- /src/lib/dwarf/elf_dwarf_util.h: -------------------------------------------------------------------------------- 1 | #ifndef _ELF_DWARF_UTIL_H_ 2 | #define _ELF_DWARF_UTIL_H_ 3 | 4 | #include "std_types.h" 5 | 6 | extern uint32 elf_dwarf_decode_uleb128(uint8 *ptr, uint32 *size); 7 | 8 | #define BYTESLEBMAX 10 9 | extern sint32 elf_dwarf_decode_sleb128(uint8 *ptr, uint32 *size); 10 | 11 | /* 12 | * reallocと同じ 13 | * 異常発生時はASSERTで失敗する. 14 | */ 15 | #define ELF_POINTER_ARRAY_SIZE_UNIT 16 16 | typedef struct { 17 | uint32 max_array_size; 18 | uint32 current_array_size; 19 | void **data; 20 | } ElfPointerArrayType; 21 | extern ElfPointerArrayType *elf_array_alloc(void); 22 | extern void elf_array_realloc(ElfPointerArrayType *array); 23 | extern void elf_array_add_entry(ElfPointerArrayType *array, void *entry); 24 | 25 | extern void *elf_obj_alloc(uint32 size); 26 | 27 | #define DWARF_ARRAY_SIZE_UNIT32 16 28 | typedef struct { 29 | uint32 max_array_size; 30 | uint32 current_array_size; 31 | uint32 *data; 32 | } DwarfUint32ArrayType; 33 | extern DwarfUint32ArrayType *dwarf_uint32_array_alloc(void); 34 | extern void dwarf_uint32_array_realloc(DwarfUint32ArrayType *array); 35 | extern void dwarf_uint32_array_add_entry(DwarfUint32ArrayType *array, uint32 entry); 36 | 37 | 38 | #endif /* _ELF_DWARF_UTIL_H_ */ 39 | -------------------------------------------------------------------------------- /src/device/peripheral/mros-dev/mros-src/packet/template/version/kinetic/mros_packet_fmt_tcpros.h: -------------------------------------------------------------------------------- 1 | #ifndef _MROS_PACKET_FMT_TCPROS_H_ 2 | #define _MROS_PACKET_FMT_TCPROS_H_ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #define MROS_PACKET_FMT_TCPROS_CALLER_ID "callerid=%s" 9 | #define MROS_PACKET_FMT_TCPROS_TOPIC "topic=%s" 10 | #define MROS_PACKET_FMT_TCPROS_TYPE "type=%s" 11 | #define MROS_PACKET_FMT_TCPROS_MD5SUM "md5sum=%s" 12 | #define MROS_PACKET_FMT_TCPROS_TCPNODELAY "tcp_nodelay=%s" 13 | 14 | /* 15 | * ARG1: callerid 16 | * ARG2: topic 17 | * ARG3: type 18 | * ARG4: md5sum 19 | */ 20 | #define MROS_PACKET_FMT_TCPROS_TOPIC_REQ \ 21 | "SIZE" \ 22 | "SIZE" \ 23 | "callerid=%s" \ 24 | "SIZE" \ 25 | "tcp_nodelay=1" \ 26 | "SIZE" \ 27 | "topic=%s" \ 28 | "SIZE" \ 29 | "type=%s" \ 30 | "SIZE" \ 31 | "md5sum=%s" 32 | 33 | 34 | /* 35 | * ARG1: callerid 36 | * ARG2: topic 37 | * ARG3: type 38 | * ARG4: md5sum 39 | */ 40 | #define MROS_PACKET_FMT_TCPROS_TOPIC_RES \ 41 | "SIZE" \ 42 | "SIZE" \ 43 | "callerid=%s" \ 44 | "SIZE" \ 45 | "topic=%s" \ 46 | "SIZE" \ 47 | "type=%s" \ 48 | "SIZE" \ 49 | "md5sum=%s" 50 | 51 | 52 | #ifdef __cplusplus 53 | } 54 | #endif 55 | 56 | 57 | #endif /* _MROS_PACKET_FMT_TCPROS_H_ */ 58 | -------------------------------------------------------------------------------- /src/device/peripheral/mros-dev/mros-athrill/api/ros_cimpl.h: -------------------------------------------------------------------------------- 1 | #ifndef _ROS_CIMPL_H_ 2 | #define _ROS_CIMPL_H_ 3 | 4 | typedef struct { 5 | void *objp; 6 | } mRosObjType; 7 | 8 | typedef struct { 9 | mRosObjType *objp; 10 | int topic_id; 11 | } mRosPublisherType; 12 | 13 | typedef struct { 14 | mRosObjType *objp; 15 | int topic_id; 16 | void *ptr; 17 | } mRosSubscriberType; 18 | 19 | extern void ros_init(int argc, char *argv, const char* node_name); 20 | extern mRosSubscriberType *ros_topic_subscribe(const char* topic, int queue_size, void (*fp) (const char *)); 21 | extern mRosPublisherType *ros_topic_advertise(const char* topic, int queue_size); 22 | extern int ros_topic_publish(mRosPublisherType* pub, void *data, int datalen); 23 | 24 | typedef unsigned int mRosCallbackTopicIdType; 25 | typedef unsigned int mRosCallbackDataLenType; 26 | extern mRosCallbackTopicIdType ros_topic_callback_topic_id(void); 27 | extern mRosCallbackDataLenType ros_topic_callback_datalen(void); 28 | extern void ros_topic_callback_lock(void); 29 | extern void ros_topic_callback_unlock(void); 30 | 31 | extern void set_main_task(void); 32 | extern void set_athrill_task(void); 33 | 34 | #include "mros_log.h" 35 | 36 | #endif /* _ROS_CIMPL_H_ */ 37 | -------------------------------------------------------------------------------- /src/inc/std_types.h: -------------------------------------------------------------------------------- 1 | #ifndef _STD_TYPES_H_ 2 | #define _STD_TYPES_H_ 3 | 4 | typedef signed char sint8; 5 | typedef signed short sint16; 6 | typedef signed int sint32; 7 | typedef signed long long sint64; 8 | 9 | typedef unsigned char uint8; 10 | typedef unsigned short uint16; 11 | typedef unsigned int uint32; 12 | typedef unsigned long long uint64; 13 | typedef int bool; 14 | typedef int std_bool; 15 | #define DEFINE_FLOAT_TYPEDEF 16 | typedef float float32; 17 | typedef double float64; 18 | 19 | typedef uint32 Std_ReturnType; 20 | 21 | typedef uint32 CoreIdType; 22 | 23 | 24 | #ifndef NULL 25 | #define NULL ((void*)0) 26 | #endif 27 | 28 | #ifndef TRUE 29 | #define TRUE (1U) 30 | #endif 31 | 32 | #ifndef FALSE 33 | #define FALSE (0U) 34 | #endif 35 | 36 | #ifndef UINT_C 37 | #define UINT_C(val) (val ## U) 38 | #endif /* UINT_C */ 39 | 40 | 41 | #ifdef __i386__ 42 | #define CAST_UINT32_TO_ADDR(uint32_data) ( (void*)((uint32)(uint32_data)) ) 43 | #elif __x86_64__ 44 | #define CAST_UINT32_TO_ADDR(uint32_data) ( (void*)((uint64)(uint32_data)) ) 45 | #elif defined(__arm64) || defined(__arm64__) || defined(__aarch64__) 46 | #define CAST_UINT32_TO_ADDR(uint32_data) ( (void*)((uint64)(uint32_data)) ) 47 | #else 48 | #error "unknown arch." 49 | #endif 50 | 51 | #endif /* _STD_TYPES_H_ */ 52 | -------------------------------------------------------------------------------- /src/lib/cui/tcp/cui_ops_tcp.c: -------------------------------------------------------------------------------- 1 | #include "cui/tcp/cui_ops_tcp.h" 2 | #include "tcp/tcp_server.h" 3 | 4 | static TcpServerConfigType tcp_server_config; 5 | static TcpServerType tcp_server; 6 | static TcpConnectionType tcp_connection; 7 | 8 | static FileOpType cui_fileop_tcp; 9 | 10 | void cui_ops_tcp_init(void) 11 | { 12 | Std_ReturnType err; 13 | 14 | err = tcp_server_create(&tcp_server_config, &tcp_server); 15 | if (err != STD_E_OK) { 16 | printf("ERROR:internal error: tcp_server_create()\n"); 17 | exit(1); 18 | } 19 | 20 | err = tcp_server_poll(&tcp_server, &tcp_connection); 21 | if (err != STD_E_OK) { 22 | printf("ERROR:internal error: tcp_server_poll()\n"); 23 | exit(1); 24 | } 25 | cui_fileop_tcp.write_fd = tcp_connection.client_socket; 26 | cui_fileop_tcp.read_fd = tcp_connection.client_socket; 27 | cui_fileop_register(&cui_fileop_tcp); 28 | return; 29 | } 30 | 31 | void cui_close(void) 32 | { 33 | Std_ReturnType err; 34 | tcp_connection_close(&tcp_connection); 35 | 36 | err = tcp_server_poll(&tcp_server, &tcp_connection); 37 | if (err != STD_E_OK) { 38 | printf("ERROR:internal error: tcp_server_poll()\n"); 39 | exit(1); 40 | } 41 | cui_fileop_tcp.write_fd = tcp_connection.client_socket; 42 | cui_fileop_tcp.read_fd = tcp_connection.client_socket; 43 | return; 44 | } 45 | -------------------------------------------------------------------------------- /src/device/peripheral/mros-dev/mros-src/inc/mros_wait_queue.h: -------------------------------------------------------------------------------- 1 | #ifndef _MROS_WAIT_QUEUE_H_ 2 | #define _MROS_WAIT_QUEUE_H_ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include "mros_list.h" 9 | 10 | typedef struct { 11 | mRosTaskIdType task_id; 12 | mRosTaskPriorityType task_priority; 13 | void *reqp; 14 | } mRosWaitEntryType; 15 | typedef ListEntryType(mRosWaitListEntryType, mRosWaitEntryType) mRosWaitListEntryType; 16 | typedef ListHeadType(mRosWaitListEntryType) mRosWaitListHeadType; 17 | 18 | typedef struct { 19 | mRosTaskIdType task_id; 20 | mRosWaitListHeadType head; 21 | } mRosWaitQueueType; 22 | 23 | extern void mros_client_wait_entry_init(mRosWaitListEntryType *wait_entry, void *reqp); 24 | extern void mros_server_queue_init(mRosWaitQueueType *wait_queue, mRosTaskIdType task_id); 25 | 26 | extern void mros_client_wakeup(mRosWaitListEntryType *wait_entry); 27 | extern void mros_client_put_request(mRosWaitQueueType *wait_queue, mRosWaitListEntryType *wait_entry); 28 | extern void mros_client_wait_for_request_done(mRosWaitQueueType *wait_queue, mRosWaitListEntryType *wait_entry); 29 | extern mRosWaitListEntryType *mros_server_queue_wait(mRosWaitQueueType *wait_queue); 30 | 31 | 32 | #ifdef __cplusplus 33 | } 34 | #endif 35 | 36 | #endif /* _MROS_WAIT_QUEUE_H_ */ 37 | -------------------------------------------------------------------------------- /src/device/peripheral/mros-dev/mros-src/lib/mros_memory.c: -------------------------------------------------------------------------------- 1 | #include "mros_memory.h" 2 | #define ASSERT(expr) \ 3 | do { \ 4 | if (!(expr)) { \ 5 | printf("ASSERTION FAILED:%s:%s:%d:%s\n", __FILE__, __FUNCTION__, __LINE__, #expr); \ 6 | exit(1); \ 7 | } \ 8 | } while (0) 9 | 10 | 11 | #define MEMORY_ID(index) ((index) + 1U) 12 | #define MEMORY_INDEX(id) ((id) - 1U) 13 | 14 | #define MEMORY_OBJ(mid, id) memory_manager[(mid)].memory_entries[MEMORY_INDEX((id))] 15 | 16 | mRosReturnType mros_mem_init(mRosSizeType config_num, mRosMemoryConfigType **config, mRosMemoryManagerType *mgrp) 17 | { 18 | return MROS_E_OK; 19 | } 20 | 21 | mRosReturnType mros_mem_alloc(mRosMemoryManagerType *mgrp, mRosSizeType size, mRosMemoryListEntryType **memory) 22 | { 23 | mRosMemoryListEntryType *mp; 24 | char *ptr; 25 | mp = malloc(sizeof(mRosMemoryListEntryType)); 26 | ASSERT(mp != MROS_NULL); 27 | ptr = malloc(size); 28 | ASSERT(ptr != MROS_NULL); 29 | mp->data.memp = ptr; 30 | mp->data.memsize = size; 31 | mp->data.size = size; 32 | *memory = mp; 33 | return MROS_E_OK; 34 | } 35 | 36 | mRosReturnType mros_mem_free(mRosMemoryManagerType *mgrp, mRosMemoryListEntryType *memory) 37 | { 38 | if (memory != NULL) { 39 | if (memory->data.memp != MROS_NULL) { 40 | free(memory->data.memp); 41 | } 42 | free(memory); 43 | } 44 | return MROS_E_OK; 45 | } 46 | 47 | -------------------------------------------------------------------------------- /src/lib/symbol_ops.h: -------------------------------------------------------------------------------- 1 | #ifndef _SYMBOL_OPS_H_ 2 | #define _SYMBOL_OPS_H_ 3 | 4 | #include "std_types.h" 5 | #include "cpu_config.h" 6 | 7 | typedef struct { 8 | char *name; 9 | uint32 addr; 10 | uint32 size; 11 | uint32 enter_sp[CPU_CONFIG_CORE_NUM]; 12 | } DbgSymbolType; 13 | 14 | extern uint32 symbol_get_func_num(void); 15 | extern uint32 symbol_get_gl_num(void); 16 | 17 | extern int symbol_get_func(char *funcname, uint32 func_len, uint32 *addrp, uint32 *size); 18 | extern char * symbol_pc2func(uint32 pc); 19 | extern int symbol_pc2funcid(uint32 pc, uint32 *funcaddr); 20 | extern char * symbol_funcid2funcname(int id); 21 | extern uint32 symbol_funcid2funcaddr(int id); 22 | extern int symbol_get_gl(char *gl_name, uint32 gl_len, uint32 *addrp, uint32 *size); 23 | 24 | extern int symbol_addr2glid(uint32 addr, uint32 *gladdr); 25 | extern char * symbol_glid2glname(int id); 26 | extern uint32 symbol_glid2gladdr(int id); 27 | 28 | extern void symbol_print_gl(char *gl_name, uint32 show_num); 29 | extern void symbol_print_func(char *gl_name, uint32 show_num); 30 | 31 | 32 | extern int symbol_gl_add(DbgSymbolType *sym); 33 | extern int symbol_func_add(DbgSymbolType *sym); 34 | extern uint32 symbol_funcid2funcsize(int id); 35 | 36 | 37 | extern uint32 symbol_get_entered_sp(int funcid, uint32 core_id); 38 | extern void symbol_set_pc(int funcid, uint32 core_id, uint32 sp); 39 | 40 | 41 | #endif /* _SYMBOL_OPS_H_ */ 42 | -------------------------------------------------------------------------------- /src/lib/cui/stdio/cui_ops_stdio.c: -------------------------------------------------------------------------------- 1 | #include "cui/stdio/cui_ops_stdio.h" 2 | #include "cui/cui_ops.h" 3 | #include 4 | #include 5 | 6 | typedef struct { 7 | int read_fd; 8 | int write_fd; 9 | FileOpType op; 10 | } StdioFileOpType; 11 | 12 | static void cui_close_stdio(void); 13 | static int cui_getline_stdio(char *line, int size); 14 | static void cui_write_stdio(char *line, int size); 15 | 16 | static StdioFileOpType cui_fileop_stdio = { 17 | .read_fd = 0, 18 | .write_fd = 1, 19 | .op = { 20 | .cui_getline = cui_getline_stdio, 21 | .cui_write = cui_write_stdio, 22 | .cui_close = cui_close_stdio, 23 | }, 24 | }; 25 | 26 | 27 | void cui_ops_stdio_init(void) 28 | { 29 | (void)cui_fileop_register(&cui_fileop_stdio.op); 30 | return; 31 | } 32 | 33 | static void cui_close_stdio(void) 34 | { 35 | //nothing to do 36 | return; 37 | } 38 | 39 | static int cui_getline_stdio(char *line, int size) 40 | { 41 | int n = 0; 42 | char c; 43 | int rc; 44 | 45 | while (TRUE) { 46 | if (n >= size) { 47 | printf("ERROR:input is too long\n"); 48 | return -1; 49 | } 50 | rc = read(cui_fileop_stdio.read_fd, &c, 1); 51 | if (rc <= 0) { 52 | return -1; 53 | } 54 | if (c < 0 || c == '\n') { 55 | break; 56 | } 57 | line[n] = c; 58 | n++; 59 | } 60 | return n; 61 | } 62 | 63 | static void cui_write_stdio(char *line, int size) 64 | { 65 | //nothing to do 66 | return; 67 | } 68 | -------------------------------------------------------------------------------- /src/bus/bus.c: -------------------------------------------------------------------------------- 1 | #include "bus.h" 2 | 3 | typedef struct { 4 | BusAccessType access_type; 5 | uint32 access_size; 6 | uint32 access_addr; 7 | uint32 access_last_data; 8 | } BusAccessLogType; 9 | 10 | uint32 bus_access_log_size = 0; 11 | BusAccessLogType bus_access_log[BUS_ACCESS_LOG_SIZE]; 12 | 13 | #undef bus_access_set_log 14 | void bus_access_set_log(BusAccessType type, uint32 size, uint32 access_addr, uint32 data) 15 | { 16 | if (type == BUS_ACCESS_TYPE_NONE) { 17 | bus_access_log_size = 0; 18 | return; 19 | } 20 | else if (bus_access_log_size >= BUS_ACCESS_LOG_SIZE) { 21 | return; 22 | } 23 | bus_access_log[bus_access_log_size].access_type = type; 24 | bus_access_log[bus_access_log_size].access_size = size; 25 | bus_access_log[bus_access_log_size].access_addr = access_addr; 26 | bus_access_log[bus_access_log_size].access_last_data = data; 27 | bus_access_log_size++; 28 | return; 29 | } 30 | 31 | Std_ReturnType bus_access_get_log(BusAccessType *type, uint32 *size, uint32 *access_addr, uint32 *last_data) 32 | { 33 | if (bus_access_log_size == 0) { 34 | return STD_E_NOENT; 35 | } 36 | bus_access_log_size--; 37 | *type = bus_access_log[bus_access_log_size].access_type; 38 | *size = bus_access_log[bus_access_log_size].access_size; 39 | *access_addr = bus_access_log[bus_access_log_size].access_addr; 40 | *last_data = bus_access_log[bus_access_log_size].access_last_data; 41 | return STD_E_OK; 42 | } 43 | -------------------------------------------------------------------------------- /src/device/peripheral/mros-dev/mros-src/protocol/cimpl/mros_protocol_server_proc_cimpl.h: -------------------------------------------------------------------------------- 1 | #ifndef _MROS_PROTOCOL_SERVER_PROC_CIMPL_H_ 2 | #define _MROS_PROTOCOL_SERVER_PROC_CIMPL_H_ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include "mros_packet_cimpl.h" 9 | #include "mros_comm_tcp_client_cimpl.h" 10 | #include "mros_protocol_client_rpc_cimpl.h" 11 | #include "mros_node_cimpl.h" 12 | #include "mros_topic_connector_factory_cimpl.h" 13 | 14 | extern mRosReturnType mros_proc_init(void); 15 | extern mRosReturnType mros_proc_receive(mRosCommTcpClientType *client, mRosPacketType *packet); 16 | extern mRosReturnType mros_proc_tcpros_receive(mRosCommTcpClientType *client, mRosPacketType *packet); 17 | extern mRosReturnType mros_proc_slave(mRosCommTcpClientType *client, mRosPacketType *packet, mros_uint32 self_ipaddr); 18 | extern mRosReturnType mros_proc_pub_tcpros(mRosCommTcpClientType *client, mRosPacketType *packet); 19 | extern mRosReturnType mros_proc_request_outer_node_addition(mRosTopicIdType topic_id, mRosRequestTopicResType *rpc_response, void *api_reqp); 20 | typedef struct { 21 | mros_uint32 ipaddr; 22 | mros_int32 port; 23 | } mRosTopicOuterTcpConnectionType; 24 | extern mRosNodeIdType mros_proc_connector_get_first(mRosTopicIdType topic_id, mRosTopicConnectorEnumType type, mRosNodeEnumType nodeType, mRosTopicOuterTcpConnectionType *tcp_conn); 25 | 26 | 27 | #ifdef __cplusplus 28 | } 29 | #endif 30 | #endif /* _MROS_PROTOCOL_SERVER_PROC_CIMPL_H_ */ 31 | -------------------------------------------------------------------------------- /src/debugger/executor/concrete_executor/dbg_std_executor.h: -------------------------------------------------------------------------------- 1 | #ifndef _DBG_STD_EXECUTOR_H_ 2 | #define _DBG_STD_EXECUTOR_H_ 3 | 4 | extern void dbg_std_executor_parse_error(void *executor); 5 | extern void dbg_std_executor_break(void *executor); 6 | extern void dbg_std_executor_delete(void *executor); 7 | extern void dbg_std_executor_cont(void *executor); 8 | extern void dbg_std_executor_core(void *executor); 9 | extern void dbg_std_executor_watch_data(void *executor); 10 | extern void dbg_std_executor_intr(void *executor); 11 | 12 | extern void dbg_std_executor_next(void *executor); 13 | extern void dbg_std_executor_return(void *executor); 14 | extern void dbg_std_executor_quit(void *executor); 15 | extern void dbg_std_executor_exit(void *executor); 16 | 17 | extern void dbg_std_executor_elaps(void *executor); 18 | extern void dbg_std_executor_view(void *executor); 19 | extern void dbg_std_executor_print(void *executor); 20 | extern void dbg_std_executor_memset(void *executor); 21 | 22 | extern void dbg_std_executor_serialin(void *executor); 23 | extern void dbg_std_executor_info_cpu(void *executor); 24 | extern void dbg_std_executor_func_trace(void *executor); 25 | extern void dbg_std_executor_data_access_info(void *executor); 26 | extern void dbg_std_executor_back_trace(void *executor); 27 | extern void dbg_std_executor_profile(void *executor); 28 | extern void dbg_std_executor_list(void *executor); 29 | extern void dbg_std_executor_help(void *executor); 30 | 31 | 32 | #endif /* _DBG_STD_EXECUTOR_H_ */ 33 | -------------------------------------------------------------------------------- /src/lib/dwarf/elf_section.h: -------------------------------------------------------------------------------- 1 | #ifndef _ELF_SECTION_H_ 2 | #define _ELF_SECTION_H_ 3 | 4 | #include "loader/elf.h" 5 | #include "std_errno.h" 6 | 7 | extern Std_ReturnType elf_symbol_load(uint8 *elf_data); 8 | extern Std_ReturnType elfsym_get_symbol_num(uint32 *sym_num); 9 | 10 | typedef enum { 11 | SYMBOL_TYPE_OBJECT, 12 | SYMBOL_TYPE_FUNC, 13 | SYMBOL_TYPE_NOTYPE, 14 | SYMBOL_TYPE_NOSUP, 15 | } ElfSymbolEnumType; 16 | 17 | typedef struct { 18 | char* name; 19 | uint32 size; 20 | uint32 addr; 21 | ElfSymbolEnumType type; 22 | } ElfSymbolType; 23 | extern Std_ReturnType elfsym_get_symbol(uint32 index, ElfSymbolType *elfsym); 24 | 25 | 26 | #define SECTION_DWARF_LINE_NAME ".debug_line" 27 | #define SECTION_DWARF_ABBREV_NAME ".debug_abbrev" 28 | #define SECTION_DWARF_INFO_NAME ".debug_info" 29 | #define SECTION_DWARF_STR_NAME ".debug_str" 30 | #define SECTION_DWARF_LOC_NAME ".debug_loc" 31 | extern Std_ReturnType elf_section_get_dwarf_line(uint8 *elf_data, uint8 **section_data, uint32 *section_size); 32 | extern Std_ReturnType elf_section_get(uint8 *elf_data, char *key, uint8 **section_data, uint32 *section_size); 33 | 34 | extern uint8 elf_get_data8(uint8 *elf_data, uint32 off); 35 | extern uint16 elf_get_data16(uint8 *elf_data, uint32 off); 36 | extern uint32 elf_get_data32(uint8 *elf_data, uint32 off); 37 | extern uint64 elf_get_data64(uint8 *elf_data, uint32 off); 38 | extern float32 elf_get_float32(uint8 *elf_data, uint32 off); 39 | extern float64 elf_get_float64(uint8 *elf_data, uint32 off); 40 | 41 | #endif /* _ELF_SECTION_H_ */ 42 | -------------------------------------------------------------------------------- /src/lib/dbg_log.c: -------------------------------------------------------------------------------- 1 | #include "dbg_log.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "target/target_os_api.h" 9 | 10 | DbgExecOpBufferType DbgExecOpBuffer; 11 | char dbg_tmp_logbuf[DBG_BUFP_LEN]; 12 | uint32 dbg_tmp_logbuflen; 13 | 14 | void dbg_log_init(char *filepath) 15 | { 16 | int fd; 17 | fd = target_os_api_open_ctw(filepath, 0777); 18 | if (fd < 0) { 19 | printf("debugger_exec_op_bufinit:open err=%d\n", errno); 20 | fflush(stdout); 21 | exit(1); 22 | } 23 | DbgExecOpBuffer.is_view_mode = FALSE; 24 | DbgExecOpBuffer.fd = fd; 25 | DbgExecOpBuffer.filepath = filepath; 26 | DbgExecOpBuffer.count = 0; 27 | return; 28 | } 29 | 30 | void dbg_log_sync(void) 31 | { 32 | int i; 33 | int err; 34 | for (i = 0; i < DbgExecOpBuffer.count; i++) { 35 | err = write(DbgExecOpBuffer.fd, DbgExecOpBuffer.buf[i].p, DbgExecOpBuffer.buf[i].write_len); 36 | if (err <= 0) { 37 | printf("debugger_exec_op_bufsync:write err=%d\n", errno); 38 | fflush(stdout); 39 | exit(1); 40 | } 41 | } 42 | err = close(DbgExecOpBuffer.fd); 43 | if (err < 0) { 44 | printf("debugger_exec_op_bufsync:close err=%d\n", errno); 45 | fflush(stdout); 46 | exit(1); 47 | } 48 | int fd; 49 | fd = target_os_api_open_aw(DbgExecOpBuffer.filepath); 50 | if (fd < 0) { 51 | printf("debugger_exec_op_bufsync:open err=%d\n", errno); 52 | fflush(stdout); 53 | exit(1); 54 | } 55 | DbgExecOpBuffer.fd = fd; 56 | DbgExecOpBuffer.count = 0; 57 | return; 58 | } 59 | 60 | 61 | -------------------------------------------------------------------------------- /src/device/mpu/mpu_ops.h: -------------------------------------------------------------------------------- 1 | #ifndef _MPU_OPS_H_ 2 | #define _MPU_OPS_H_ 3 | 4 | #include "std_types.h" 5 | 6 | extern Std_ReturnType mpu_get_data8(CoreIdType core_id, uint32 addr, uint8 *data); 7 | extern Std_ReturnType mpu_get_data16(CoreIdType core_id, uint32 addr, uint16 *data); 8 | extern Std_ReturnType mpu_get_data32(CoreIdType core_id, uint32 addr, uint32 *data); 9 | 10 | extern Std_ReturnType mpu_put_data8(CoreIdType core_id, uint32 addr, uint8 data); 11 | extern Std_ReturnType mpu_put_data16(CoreIdType core_id, uint32 addr, uint16 data); 12 | extern Std_ReturnType mpu_put_data32(CoreIdType core_id, uint32 addr, uint32 data); 13 | 14 | extern Std_ReturnType mpu_get_pointer(CoreIdType core_id, uint32 addr, uint8 **data); 15 | 16 | 17 | /* 18 | * the following enum values must be equal MemoryAddressImplType(cpuemu_ops.h). 19 | */ 20 | typedef enum { 21 | MpuAddressGetType_ROM = 0, 22 | MpuAddressGetType_RAM, 23 | MpuAddressGetType_MMAP, 24 | MpuAddressGetType_MALLOC, 25 | } MpuAddressGetType; 26 | #define MPU_MALLOC_REGION_UNIT_SIZE 1024 /* KB */ 27 | #define MPU_MALLOC_REGION_UNIT_GROUP_NUM 10 /* 10MB */ 28 | 29 | extern uint8 *mpu_address_set_rom_ram(MpuAddressGetType getType, uint32 addr, uint32 size, void *mmap_addr); 30 | extern uint8 *mpu_address_set_dev(uint32 addr, uint32 size, void *handler); 31 | extern uint8 *mpu_address_get_rom(uint32 addr, uint32 size); 32 | extern uint8 *mpu_address_get_ram(uint32 addr, uint32 size); 33 | extern void mpu_address_set_malloc_region(uint32 addr, uint32 size); 34 | 35 | #endif /* _MPU_OPS_H_ */ 36 | -------------------------------------------------------------------------------- /src/lib/token.h: -------------------------------------------------------------------------------- 1 | #ifndef _TOKEN_H_ 2 | #define _TOKEN_H_ 3 | 4 | #include "std_types.h" 5 | 6 | typedef enum { 7 | TOKEN_TYPE_VALUE_HEX, 8 | TOKEN_TYPE_VALUE_DEC, 9 | TOKEN_TYPE_STRING, 10 | TOKEN_TYPE_UNKNOWN, 11 | } TokenEnumType; 12 | 13 | typedef struct { 14 | uint32 value; 15 | } TokenValueHexType; 16 | 17 | typedef struct { 18 | uint32 value; 19 | } TokenValueDecType; 20 | 21 | #define TOKEN_STRING_MAX_SIZE 4096 22 | typedef struct { 23 | uint32 len; 24 | uint8 str[TOKEN_STRING_MAX_SIZE]; 25 | } TokenStringType; 26 | 27 | typedef struct { 28 | TokenEnumType type; 29 | union { 30 | TokenValueHexType hex; 31 | TokenValueDecType dec; 32 | TokenStringType str; 33 | } body; 34 | } TokenValueType; 35 | 36 | #define TOKEN_CONTAINER_MAX_SIZE 128 37 | typedef struct { 38 | uint32 num; 39 | TokenValueType array[TOKEN_CONTAINER_MAX_SIZE]; 40 | } TokenContainerType; 41 | 42 | extern Std_ReturnType token_split(TokenContainerType *token_container, uint8 *str, uint32 len); 43 | extern Std_ReturnType token_split_with_delimiter(TokenContainerType *token_container, uint8 *str, uint32 len, char delimiter); 44 | extern bool token_split_merge(const TokenContainerType *token_container, uint8 start_index, TokenStringType *out); 45 | extern void token_trim_newline(TokenStringType *token); 46 | 47 | extern bool token_string_set(TokenStringType *dest, const char* src); 48 | extern bool token_strcmp(const TokenStringType *str1, const TokenStringType *str2); 49 | extern bool token_merge(TokenStringType *dest, const TokenStringType *src); 50 | 51 | 52 | 53 | #endif /* _TOKEN_H_ */ 54 | -------------------------------------------------------------------------------- /src/lib/tcp/tcp_socket.c: -------------------------------------------------------------------------------- 1 | #include "tcp_socket.h" 2 | #include 3 | #include 4 | #ifdef OS_LINUX 5 | #include 6 | #include 7 | #include 8 | #else 9 | #include 10 | #endif 11 | #include 12 | #include 13 | #include 14 | 15 | Std_ReturnType tcp_socket_open(TcpSocketType *sock) 16 | { 17 | sock->fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); 18 | if (sock->fd < 0) { 19 | printf("%s %s() %u errno=%d\n", __FILE__, __FUNCTION__, __LINE__, errno); 20 | return STD_E_INVALID; 21 | } 22 | //printf("tcp_socket_open: fd=%d\n", sock->fd); 23 | return STD_E_OK; 24 | } 25 | 26 | void tcp_socket_close(TcpSocketType *socket) 27 | { 28 | if (socket->fd >= 0) { 29 | close(socket->fd); 30 | socket->fd = -1; 31 | } 32 | return; 33 | } 34 | 35 | Std_ReturnType tcp_inet_get_ipaddr(const char *hostname, uint32 *ipaddr) 36 | { 37 | sint32 result; 38 | uint8 addr_array[5]; 39 | uint8 *paddr = addr_array; 40 | 41 | result = sscanf(hostname, "%hhu.%hhu.%hhu.%hhu", 42 | (uint8*)&addr_array[3], 43 | (uint8*)&addr_array[2], 44 | (uint8*)&addr_array[1], 45 | (uint8*)&addr_array[0]); 46 | 47 | if (result != 4) { 48 | struct hostent *host_address = gethostbyname(hostname); 49 | if (host_address == NULL) { 50 | printf("%s %s() %u ret=%d", __FILE__, __FUNCTION__, __LINE__, STD_E_INVALID); 51 | return STD_E_INVALID; 52 | } 53 | paddr = (uint8*)host_address->h_addr_list[0]; 54 | } 55 | memcpy((void*)ipaddr, (void*)paddr, 4U); 56 | return STD_E_OK; 57 | } 58 | -------------------------------------------------------------------------------- /src/lib/dwarf/elf_dwarf_info_ops.c: -------------------------------------------------------------------------------- 1 | #include "elf_dwarf_info_ops.h" 2 | #include "elf_dwarf_util.h" 3 | #include "assert.h" 4 | #include 5 | 6 | static ElfDwarfStackType elf_dwaf_info_ops; 7 | 8 | void elf_dwarf_info_ops_init(void) 9 | { 10 | elf_dwaf_info_ops.stack_size = 0; 11 | elf_dwaf_info_ops.stack = dwarf_uint32_array_alloc(); 12 | return; 13 | } 14 | uint32 elf_dwarf_info_ops_pop(void) 15 | { 16 | if (elf_dwaf_info_ops.stack_size > 0) { 17 | elf_dwaf_info_ops.stack_size--; 18 | return elf_dwaf_info_ops.stack->data[elf_dwaf_info_ops.stack_size]; 19 | } 20 | return 0; 21 | } 22 | void elf_dwarf_info_ops_push(uint32 data) 23 | { 24 | if (elf_dwaf_info_ops.stack->current_array_size > elf_dwaf_info_ops.stack_size) { 25 | elf_dwaf_info_ops.stack->data[elf_dwaf_info_ops.stack_size] = data; 26 | elf_dwaf_info_ops.stack_size++; 27 | } 28 | else { 29 | dwarf_uint32_array_add_entry(elf_dwaf_info_ops.stack, data); 30 | elf_dwaf_info_ops.stack_size++; 31 | } 32 | return; 33 | } 34 | 35 | void elf_dwarf_info_ops_DW_OP_plus_uconst(uint8 *addr) 36 | { 37 | uint32 size; 38 | uint32 data1 = elf_dwarf_info_ops_pop(); 39 | uint32 data2 = elf_dwarf_decode_uleb128(addr, &size); 40 | //printf("data1=%u data2=%u\n", data1, data2); 41 | elf_dwarf_info_ops_push(data1 + data2); 42 | return; 43 | } 44 | void elf_dwarf_info_ops_DW_OP(ElfDwarfInfoOpsType optype, uint8 *data) 45 | { 46 | switch (optype) { 47 | case DW_OP_plus_uconst: 48 | elf_dwarf_info_ops_DW_OP_plus_uconst(data); 49 | break; 50 | default: 51 | printf("not supported optype = 0x%x\n", optype); 52 | ASSERT(0); 53 | break; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/lib/dwarf/elf_dwarf_info.h: -------------------------------------------------------------------------------- 1 | #ifndef _ELF_DWARF_INFO_H_ 2 | #define _ELF_DWARF_INFO_H_ 3 | #include "std_types.h" 4 | #include "std_errno.h" 5 | #include "elf_dwarf_util.h" 6 | #include "elf_dwarf_abbrev.h" 7 | 8 | 9 | typedef struct { 10 | DwFormType type; 11 | uint32 offset; 12 | uint32 size; 13 | char *typename; 14 | union { 15 | uint32 addr; 16 | uint8 const8; 17 | uint16 const16; 18 | uint32 const32; 19 | uint64 const64; 20 | sint64 scont64; 21 | uint8 ref8; 22 | uint16 ref16; 23 | uint32 ref32; 24 | uint64 ref64; 25 | uint32 sec_offset; 26 | bool flag; 27 | char *string; 28 | struct { 29 | uint32 len; 30 | uint8 *ops; 31 | } op; 32 | } encoded; 33 | } ElfDwarfAttributeType; 34 | 35 | struct ElfDwarfDie; 36 | typedef struct ElfDwarfDie { 37 | uint32 offset; 38 | uint32 abbrev_code; 39 | ElfDwarfAbbrevType *abbrev_info; 40 | ElfPointerArrayType *attribute; 41 | uint32 level; 42 | struct ElfDwarfDie *parent; 43 | ElfPointerArrayType *children; 44 | } ElfDwarfDieType; 45 | 46 | typedef struct { 47 | uint32 offset; 48 | uint32 length; 49 | uint16 version; 50 | uint32 abbrev_offset; 51 | uint8 pointer_size; 52 | ElfPointerArrayType *dies; 53 | } ElfDwarfCompilationUnitHeaderType; 54 | 55 | extern Std_ReturnType elf_dwarf_info_load(uint8 *elf_data); 56 | extern ElfDwarfCompilationUnitHeaderType *elf_dwarf_info_alloc_empty_ElfDwarfCompilationUnitHeader(void); 57 | 58 | extern ElfPointerArrayType *elf_dwarf_info_get(void); 59 | 60 | extern uint32 elf_dwarf_info_get_value(DwFormType form, ElfDwarfAttributeType *obj, uint32 *size); 61 | 62 | 63 | 64 | #endif /* _ELF_DWARF_INFO_H_ */ 65 | -------------------------------------------------------------------------------- /src/lib/tcp/tcp_client.c: -------------------------------------------------------------------------------- 1 | #include "tcp/tcp_client.h" 2 | #include 3 | #ifdef OS_LINUX 4 | #include 5 | #include 6 | #else 7 | #include 8 | #endif 9 | #include 10 | #include 11 | #include 12 | 13 | Std_ReturnType tcp_client_create(const TcpClientConfigType *config, TcpClientType *client) 14 | { 15 | int ret; 16 | 17 | client->connection.connected = FALSE; 18 | ret = tcp_socket_open(&client->connection.socket); 19 | if (ret != STD_E_OK) { 20 | return ret; 21 | } 22 | client->config.server_port = config->server_port; 23 | client->config.ipaddr = config->ipaddr; 24 | return STD_E_OK; 25 | } 26 | 27 | Std_ReturnType tcp_client_connect(TcpClientType *client) 28 | { 29 | uint32 ipaddr; 30 | int ret; 31 | struct sockaddr_in addr; 32 | 33 | ret = tcp_inet_get_ipaddr(client->config.ipaddr, &ipaddr); 34 | if (ret != STD_E_OK) { 35 | return ret; 36 | } 37 | 38 | memset(&addr, 0, sizeof(struct sockaddr_in)); 39 | addr.sin_family = AF_INET; 40 | addr.sin_port = htons(client->config.server_port); 41 | addr.sin_addr.s_addr = htonl(ipaddr); 42 | 43 | ret = connect(client->connection.socket.fd, (struct sockaddr*)&addr, sizeof(struct sockaddr_in)); 44 | if (ret < 0) { 45 | printf("%s %s() %u errno=%d\n", __FILE__, __FUNCTION__, __LINE__, errno); 46 | return STD_E_NOENT; 47 | } 48 | client->connection.connected = TRUE; 49 | return STD_E_OK; 50 | } 51 | 52 | void tcp_client_close(TcpClientType *client) 53 | { 54 | if (client != NULL) { 55 | tcp_socket_close(&client->connection.socket); 56 | } 57 | return; 58 | } 59 | -------------------------------------------------------------------------------- /README.ja.md: -------------------------------------------------------------------------------- 1 | athrill 2 | ======= 3 | 4 | Athrill は CPU エミュレータです. 5 | Athrill を使用すると,仮想マイコン上で組込みプログラムを簡単に実行/デバッグすることができます. 6 | ベアメタルプログラムやリアルタイムOS上で動作する組込み制御プログラムを評価できます. 7 | 現時点の Athrill は V850 のCPU命令をサポートしています. 8 | 9 | # Table of Contents 10 | ----------------- 11 | * [Requirements](#requirements) 12 | * [Install](#install) 13 | * [License](#license) 14 | 15 | # Requirements 16 | ------------ 17 | Athrill は, 以下の環境で動作します: 18 | 19 | * OS 20 | * [Linux] 21 | * Ubuntu(32bit) 22 | * [Windows] 23 | * MinGW32_NT-6.2(Windows10, Windows7) 24 | 25 | Athrill は, ソースデバッグ用に以下のエディタを使用します: 26 | 27 | * エディタ 28 | * [Linux] 29 | * geany 30 | * [Windows] 31 | * Sakura Editor 32 | 33 | # Install 34 | ----- 35 | Athrill プロジェクトをダウンロード後, 環境変数(PATH)にathrillの実行バイナリフォルダのパスを追加しててください. 36 | 37 | ``` 38 | export PATH=[athrill root folder]/src/bin:$PATH 39 | ``` 40 | 任意のフォルダ上でathrillを空打ちし, usageが表示されればインストール完了です: 41 | 42 | Usage:athrill -m [OPTION]... 43 | -i : execute on the interaction mode. if -i is not set, execute on the background mode. 44 | -r : execute on the remote mode. this option is valid on the interaction mode. 45 | -t : set program end time using clocks. this option is valid on the background mode. 46 | -m : set athrill memory configuration. rom, ram region is configured on your system. 47 | -d : set device parameter. 48 | 49 | 50 | # License 51 | ------- 52 | Athrill is licensed under the TOPPERS License Agreement (http://www.toppers.jp/en/license.html). 53 | -------------------------------------------------------------------------------- /src/device/peripheral/mros-dev/mros-src/packet/cimpl/mros_packet_encoder_cimpl.h: -------------------------------------------------------------------------------- 1 | #ifndef _MROS_PACKET_ENCODER_CIMPL_H_ 2 | #define _MROS_PACKET_ENCODER_CIMPL_H_ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include "mros_packet_cimpl.h" 9 | 10 | /************************************* 11 | * Encoder 12 | *************************************/ 13 | #define MROS_ENCODE_ARGS_MAX 5 14 | typedef struct { 15 | mRosPacketDataEnumType type; 16 | mRosSizeType args_char; 17 | const char* argv[MROS_ENCODE_ARGS_MAX]; 18 | mRosSizeType args_int; 19 | mros_uint32 argi[MROS_ENCODE_ARGS_MAX]; 20 | } mRosEncodeArgType; 21 | 22 | extern mRosReturnType mros_packet_encoder_init(void); 23 | 24 | /* 25 | * arg.type = MROS_PACKET_DATA_REGISTER_PUBLISHER_REQ; 26 | * arg.argv[0] = "registerPublisher"; 27 | * arg.argv[1] = req->node_name; 28 | * arg.argv[2] = req->topic_name; 29 | * arg.argv[3] = req->topic_typename; 30 | * arg.argv[4] = MROS_URI_SLAVE; 31 | */ 32 | /* 33 | * arg.type = MROS_PACKET_DATA_REGISTER_SUBSCRIBER_REQ; 34 | * arg.argv[0] = "registerSubscriber"; 35 | * arg.argv[1] = req->node_name; 36 | * arg.argv[2] = req->topic_name; 37 | * arg.argv[3] = req->topic_typename; 38 | * arg.argv[4] = MROS_URI_SLAVE; 39 | */ 40 | /* 41 | * arg.type = MROS_PACKET_DATA_REQUEST_TOPIC_REQ; 42 | * arg.argv[0] = "requestTopic"; 43 | * arg.argv[1] = req->node_name; 44 | * arg.argv[2] = req->topic_name; 45 | * arg.argv[3] = "TCPROS"; 46 | */ 47 | /* 48 | * arg.type = MROS_PACKET_DATA_REQUEST_TOPIC_RES; 49 | * arg.argi[0] = mros_publisher_port_no; 50 | * arg.argv[0] ="TCPROS"; 51 | * arg.argv[1] = MROS_NODE_IPADDR; 52 | */ 53 | extern mRosReturnType mros_packet_encode(mRosEncodeArgType *arg, mRosPacketType *packet); 54 | 55 | #ifdef __cplusplus 56 | } 57 | #endif 58 | 59 | #endif /* _MROS_PACKET_ENCODER_CIMPL_H_ */ 60 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | athrill 2 | ======= 3 | 4 | Athrill is a CPU emulator. 5 | Athrill was developed to easily execute and debug embedded programs on virtual microcomputer. 6 | You can evaluate bare metal programs or embedded control programs running on real-time OS. 7 | Athrill at the moment supports V850 CPU instructions. 8 | 9 | # Table of Contents 10 | ----------------- 11 | * [Requirements](#requirements) 12 | * [Install](#install) 13 | * [License](#license) 14 | 15 | # Requirements 16 | ------------ 17 | Athrill requires the following to run: 18 | 19 | * OS 20 | * [Linux] 21 | * Ubuntu(32bit) 22 | * [Windows] 23 | * MinGW32_NT-6.2(Windows10, Windows7) 24 | 25 | Athrill uses the following editors for source debugging: 26 | 27 | * Editor 28 | * [Linux] 29 | * geany 30 | * [Windows] 31 | * Sakura Editor 32 | 33 | # Install 34 | ----- 35 | After downloading Athrill project, add the following athrill executable binary folder path on the environment-variable (PATH). 36 | 37 | ``` 38 | export PATH=[athrill root folder]/src/bin:$PATH 39 | ``` 40 | Then make sure you can display usage of athrill on an arbitrary folder: 41 | 42 | Usage:athrill -m [OPTION]... 43 | -i : execute on the interaction mode. if -i is not set, execute on the background mode. 44 | -r : execute on the remote mode. this option is valid on the interaction mode. 45 | -t : set program end time using clocks. this option is valid on the background mode. 46 | -m : set athrill memory configuration. rom, ram region is configured on your system. 47 | 48 | 49 | # License 50 | ------- 51 | Athrill is licensed under the TOPPERS License Agreement (http://www.toppers.jp/en/license.html). 52 | -------------------------------------------------------------------------------- /src/lib/athrill_memory.h: -------------------------------------------------------------------------------- 1 | #ifndef _ATHRLL_MEMORY_H_ 2 | #define _ATHRLL_MEMORY_H_ 3 | 4 | #include "std_types.h" 5 | #include "assert.h" 6 | #include 7 | 8 | #define ATHRILL_MEM_ENTRY_SIZE (10240 * 1024 * 4) 9 | typedef struct { 10 | uint32 free_start; 11 | uint32 freesize; 12 | void *next; 13 | uint8 data[ATHRILL_MEM_ENTRY_SIZE]; 14 | } AthrillMemEntryType; 15 | 16 | typedef struct { 17 | AthrillMemEntryType *headp; 18 | AthrillMemEntryType *currp; 19 | } AthrillMemHeadType; 20 | 21 | extern AthrillMemHeadType athrill_mem_head; 22 | 23 | static inline void athrill_mem_init(AthrillMemEntryType *entryp) 24 | { 25 | entryp->next = NULL; 26 | entryp->free_start = 0U; 27 | entryp->freesize = ATHRILL_MEM_ENTRY_SIZE; 28 | return; 29 | } 30 | 31 | static inline void *athrill_mem_alloc(uint32 size) 32 | { 33 | ASSERT(size <= ATHRILL_MEM_ENTRY_SIZE); 34 | if (athrill_mem_head.headp == NULL) { 35 | athrill_mem_head.headp = malloc(sizeof(AthrillMemEntryType)); 36 | ASSERT(athrill_mem_head.headp != NULL); 37 | athrill_mem_head.currp = athrill_mem_head.headp; 38 | athrill_mem_init(athrill_mem_head.headp); 39 | } 40 | if (size > athrill_mem_head.currp->freesize) { 41 | AthrillMemEntryType *new_entryp = malloc(sizeof(AthrillMemEntryType)); 42 | ASSERT(new_entryp != NULL); 43 | athrill_mem_init(new_entryp); 44 | new_entryp->next = athrill_mem_head.currp; 45 | athrill_mem_head.currp = new_entryp; 46 | } 47 | void *retp = &athrill_mem_head.currp->data[athrill_mem_head.currp->free_start]; 48 | athrill_mem_head.currp->free_start += size; 49 | athrill_mem_head.currp->freesize -= size; 50 | return retp; 51 | } 52 | static inline void *athrill_mem_calloc(uint32 memsz, uint32 size) 53 | { 54 | void *p = athrill_mem_alloc(memsz * size); 55 | memset(p, 0, size); 56 | return p; 57 | } 58 | 59 | #endif /* _ATHRLL_MEMORY_H_ */ 60 | -------------------------------------------------------------------------------- /src/device/peripheral/mros-dev/mros-athrill/config/mros_sys_config.h: -------------------------------------------------------------------------------- 1 | #ifndef _MROS_SYS_CONFIG_H_ 2 | #define _MROS_SYS_CONFIG_H_ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include "std_types.h" 9 | #include "mros_usr_config.h" 10 | #include "mros_os_config.h" 11 | #include "mros_packet_config.h" 12 | 13 | 14 | 15 | /************************************** 16 | * PROTOCOL 17 | **************************************/ 18 | /* 19 | * portno of master 20 | */ 21 | #define MROS_MASTER_PORT_NO 11311 22 | /* 23 | * ipaddr of master 24 | */ 25 | #define MROS_MASTER_IPADDR "0.0.0.0" 26 | 27 | extern char *mros_master_ipaddr; 28 | extern char *mros_node_ipaddr; 29 | extern uint32 mros_slave_port_no; 30 | extern uint32 mros_publisher_port_no; 31 | extern char *mros_uri_slave; 32 | 33 | /* 34 | * ipaddr of self node 35 | */ 36 | #define MROS_NODE_IPADDR "127.0.0.1" 37 | 38 | /* 39 | * portno of slave 40 | */ 41 | #define MROS_SLAVE_PORT_NO 11411 42 | 43 | /* 44 | * portno of pub 45 | */ 46 | #define MROS_PUBLISHER_PORT_NO 11511 47 | 48 | /* 49 | * uri of mROS slave 50 | */ 51 | #define MROS_URI_SLAVE "http://127.0.0.1:11411" 52 | 53 | /* 54 | * do not change this parameter 55 | */ 56 | #define MROS_TOPIC_TCP_CLIENT_MAX_NUM ( MROS_PUB_TOPIC_CONNECTOR_MAX_NUM + MROS_SUB_TOPIC_CONNECTOR_MAX_NUM ) 57 | 58 | 59 | /***************************************** 60 | * EXCLUSIVE AREA 61 | *****************************************/ 62 | 63 | /* 64 | * do not change this parameter 65 | */ 66 | #define MROS_GIANT_EXCLUSIVE_AREA_PRIORITY ( \ 67 | ( MROS_USR_TASK_PRI < MROS_TASK_PRI) ? \ 68 | MROS_USR_TASK_PRI : \ 69 | MROS_TASK_PRI \ 70 | ) 71 | 72 | 73 | extern void mros_sys_config_init(void); 74 | extern void usr_task_activation(void); 75 | 76 | #ifdef __cplusplus 77 | } 78 | #endif 79 | 80 | #endif /* _MROS_SYS_CONFIG_H_ */ 81 | 82 | -------------------------------------------------------------------------------- /src/device/peripheral/mros-dev/mros-athrill/config/os/target/os_asp/mros_os_config.h: -------------------------------------------------------------------------------- 1 | #ifndef _MROS_OS_CONFIG_H_ 2 | #define _MROS_OS_CONFIG_H_ 3 | 4 | #include "kernel.h" 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | extern void main_task(void); 11 | extern void sub_task(void); 12 | extern void pub_task(void); 13 | extern void xml_slv_task(void); 14 | extern void xml_mas_task(void); 15 | extern void cyclic_handler(mros_intptr_t exinf); 16 | 17 | /**************************************** 18 | * kernel cfg 19 | ****************************************/ 20 | #ifndef MROS_USR_TASK_PRI 21 | /* 22 | * main task priority 23 | * 24 | * do not change this parameter 25 | */ 26 | #define MAIN_TASK_PRI 7 27 | /* 28 | * mROS task priority 29 | * 30 | * do not change this parameter 31 | */ 32 | #define MROS_TASK_PRI 6 33 | 34 | /* 35 | * user task priority 36 | * 37 | * following config parameter is an example. 38 | */ 39 | 40 | /* 41 | * user task max priority 42 | * 43 | * please set max priority of user tasks. 44 | */ 45 | #define MROS_USR_TASK_PRI 8 46 | #endif /* ROS_USR_TASK_PRI */ 47 | 48 | #ifndef TASK_PORTID 49 | #define TASK_PORTID 1 /* serial port ID for something typing */ 50 | #endif /* TASK_PORTID */ 51 | 52 | #ifndef MROS_TASK_STACK_SIZE 53 | /* 54 | * user task stack size 55 | */ 56 | /* 57 | * mROS task stack size 58 | * 59 | * do not change this parameter 60 | */ 61 | #define MROS_TASK_STACK_SIZE 1024 * 2 //for mros task 62 | #endif /*MROS_TASK_STACK_SIZE*/ 63 | 64 | /* 65 | * do not change this parameter 66 | */ 67 | #ifndef CYC 68 | #define MROS_LOOP_RATE 100 69 | #define CYC 70 | #endif /*CYC*/ 71 | 72 | /* 73 | * do not change this parameter 74 | */ 75 | #ifndef LOOP_REF 76 | #define LOOP_REF ULONG_C(1000000) /* number of loops to evaluate speed */ 77 | #endif /* LOOP_REF */ 78 | 79 | #ifdef __cplusplus 80 | } 81 | #endif 82 | 83 | 84 | #endif /* _MROS_OS_CONFIG_H_ */ 85 | -------------------------------------------------------------------------------- /src/device/peripheral/mros-dev/mros-src/protocol/cimpl/mros_protocol_client_rpc_cimpl.h: -------------------------------------------------------------------------------- 1 | #ifndef _MROS_PROTOCOL_CLIENT_RPC_CIMPL_H_ 2 | #define _MROS_PROTOCOL_CLIENT_RPC_CIMPL_H_ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include "mros_types.h" 9 | #include "mros_packet_cimpl.h" 10 | #include "mros_comm_tcp_client_cimpl.h" 11 | 12 | typedef struct { 13 | const char* node_name; 14 | const char* topic_name; 15 | const char* topic_typename; 16 | mRosPacketType *req_packet; 17 | } mRosRegisterTopicReqType; 18 | 19 | typedef struct { 20 | mRosReturnType result; 21 | mRosPacketType *reply_packet; 22 | } mRosRegisterTopicResType; 23 | extern mRosReturnType mros_rpc_register_publisher(mRosCommTcpClientType *client, mRosRegisterTopicReqType *req, mRosRegisterTopicResType *res); 24 | extern mRosReturnType mros_rpc_register_subscriber(mRosCommTcpClientType *client, mRosRegisterTopicReqType *req, mRosRegisterTopicResType *res); 25 | 26 | typedef struct { 27 | const char* node_name; 28 | const char* topic_name; 29 | mRosPacketType *req_packet; 30 | } mRosRequestTopicReqType; 31 | 32 | typedef struct { 33 | mRosReturnType result; 34 | mRosPacketType *reply_packet; 35 | } mRosRequestTopicResType; 36 | extern mRosReturnType mros_rpc_request_topic(mRosCommTcpClientType *client, mRosRequestTopicReqType *req, mRosRequestTopicResType *res); 37 | 38 | typedef struct { 39 | const char* node_name; 40 | const char* topic_name; 41 | const char* topic_typename; 42 | const char* md5sum; 43 | mRosPacketType *req_packet; 44 | } mRosRcpRosReqType; 45 | 46 | typedef struct { 47 | mRosReturnType result; 48 | mRosPacketType *reply_packet; 49 | } mRosTcpRosResType; 50 | extern mRosReturnType mros_rpc_tcpros(mRosCommTcpClientType *client, mRosRcpRosReqType *req, mRosTcpRosResType *res); 51 | 52 | 53 | #ifdef __cplusplus 54 | } 55 | #endif 56 | #endif /* _MROS_PROTOCOL_CLIENT_RPC_CIMPL_H_ */ 57 | -------------------------------------------------------------------------------- /src/device/peripheral/mros-dev/mros-src/lib/mros_wait_queue.c: -------------------------------------------------------------------------------- 1 | #include "mros_wait_queue.h" 2 | #include "mros_os.h" 3 | 4 | void mros_client_wait_entry_init(mRosWaitListEntryType *wait_entry, void *reqp) 5 | { 6 | wait_entry->data.reqp = reqp; 7 | wait_entry->data.task_id = mros_get_taskid(); 8 | wait_entry->data.task_priority = mros_get_taskpri(); 9 | return; 10 | } 11 | 12 | void mros_server_queue_init(mRosWaitQueueType *wait_queue, mRosTaskIdType task_id) 13 | { 14 | wait_queue->task_id = task_id; 15 | List_InitEmpty(&wait_queue->head, mRosWaitListEntryType); 16 | 17 | return; 18 | } 19 | 20 | void mros_client_wakeup(mRosWaitListEntryType *wait_entry) 21 | { 22 | mros_wakeup_task(wait_entry->data.task_id); 23 | return; 24 | } 25 | 26 | 27 | void mros_client_put_request(mRosWaitQueueType *wait_queue, mRosWaitListEntryType *wait_entry) 28 | { 29 | ListEntry_AddEntry(&wait_queue->head, wait_entry); 30 | mros_wakeup_task(wait_queue->task_id); 31 | return; 32 | } 33 | 34 | void mros_client_wait_for_request_done(mRosWaitQueueType *wait_queue, mRosWaitListEntryType *wait_entry) 35 | { 36 | mros_client_put_request(wait_queue, wait_entry); 37 | mros_sleep_task(); 38 | return; 39 | } 40 | static mRosWaitListEntryType *mros_server_queue_get(mRosWaitQueueType *wait_queue) 41 | { 42 | mRosTaskPriorityType min_priority = MROS_TASK_MIN_PRIORITY; 43 | mRosWaitListEntryType *entry; 44 | mRosWaitListEntryType *target = MROS_NULL; 45 | 46 | ListEntry_Foreach(&wait_queue->head, entry) { 47 | if (entry->data.task_priority < min_priority) { 48 | min_priority = entry->data.task_priority; 49 | target = entry; 50 | } 51 | } 52 | if (target != MROS_NULL) { 53 | ListEntry_RemoveEntry(&wait_queue->head, target); 54 | } 55 | return target; 56 | } 57 | 58 | mRosWaitListEntryType *mros_server_queue_wait(mRosWaitQueueType *wait_queue) 59 | { 60 | if (wait_queue->head.entry_num == 0) { 61 | mros_sleep_task(); 62 | } 63 | return mros_server_queue_get(wait_queue); 64 | } 65 | -------------------------------------------------------------------------------- /src/device/peripheral/mros-dev/mros-src/topic/cimpl/mros_topic_cimpl.h: -------------------------------------------------------------------------------- 1 | #ifndef _MROS_TOPIC_CIMPL_H_ 2 | #define _MROS_TOPIC_CIMPL_H_ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include "mros_memory.h" 9 | 10 | extern mRosReturnType mros_topic_init(void); 11 | extern mRosContainerObjType mros_topic_get_first(void); 12 | extern mRosContainerObjType mros_topic_get_next(mRosContainerObjType obj); 13 | extern const char *mros_topic_get_topic_name(mRosTopicIdType id); 14 | extern const char *mros_topic_get_topic_typename(mRosTopicIdType id); 15 | extern mRosTopicIdType mros_topic_get_id(mRosContainerObjType obj); 16 | extern mRosReturnType mros_topic_get(const char *topic_name, mRosTopicIdType *id); 17 | extern mRosReturnType mros_topic_create(const char *topic_name, const char *topic_typename, mRosTopicIdType *id); 18 | extern mRosReturnType mros_topic_set_quesize_byname(const char *topic_name, mRosSizeType size); 19 | extern mRosReturnType mros_topic_set_quesize_byid(mRosTopicIdType id, mRosSizeType size); 20 | extern mRosReturnType mros_topic_remove_byname(const char *topic_name); 21 | extern mRosReturnType mros_topic_remove_byid(mRosTopicIdType id); 22 | extern mRosReturnType mros_topic_add_data(mRosTopicIdType id, mRosMemoryListEntryType *data); 23 | extern mRosReturnType mros_topic_get_data(mRosTopicIdType id, mRosMemoryListEntryType **data); 24 | 25 | 26 | extern mRosReturnType mros_topic_set_typeid(mRosTopicIdType topic_id, mros_uint32 type_id); 27 | extern mRosReturnType mros_topic_get_typeid(mRosTopicIdType topic_id, mros_uint32 *type_id); 28 | 29 | extern mRosReturnType mros_topic_set_definition(mRosTopicIdType topic_id, const char* definition); 30 | extern mRosReturnType mros_topic_get_definition(mRosTopicIdType topic_id, const char **definition); 31 | 32 | extern mRosReturnType mros_topic_set_md5sum(mRosTopicIdType topic_id, const char* md5sum); 33 | extern mRosReturnType mros_topic_get_md5sum(mRosTopicIdType topic_id, const char **md5sum); 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | #endif /* _MROS_TOPIC_CIMPL_H_ */ 39 | -------------------------------------------------------------------------------- /src/lib/tcp/tcp_server.c: -------------------------------------------------------------------------------- 1 | #include "tcp/tcp_server.h" 2 | #include 3 | #ifdef OS_LINUX 4 | #include 5 | #include 6 | #else 7 | #include 8 | #endif 9 | #include 10 | #include 11 | #include 12 | 13 | Std_ReturnType tcp_server_create(const TcpServerConfigType *config, TcpServerType *server) 14 | { 15 | int ret; 16 | struct sockaddr_in addr; 17 | 18 | ret = tcp_socket_open(&server->socket); 19 | if (ret != STD_E_OK) { 20 | return ret; 21 | } 22 | 23 | memset(&addr, 0, sizeof(struct sockaddr_in)); 24 | addr.sin_family = AF_INET; 25 | addr.sin_port = htons(config->server_port); 26 | addr.sin_addr.s_addr = htonl(INADDR_ANY); 27 | server->config.server_port = config->server_port; 28 | 29 | ret = bind(server->socket.fd, (struct sockaddr*)&addr, sizeof(struct sockaddr_in)); 30 | if (ret < 0) { 31 | printf("%s %s() %u errno=%d\n", __FILE__, __FUNCTION__, __LINE__, errno); 32 | return STD_E_NOENT; 33 | } 34 | ret = listen(server->socket.fd, 10); 35 | if (ret < 0) { 36 | printf("%s %s() %u errno=%d\n", __FILE__, __FUNCTION__, __LINE__, errno); 37 | return STD_E_NOENT; 38 | } 39 | 40 | return STD_E_OK; 41 | } 42 | 43 | Std_ReturnType tcp_server_accept(const TcpServerType *server, TcpConnectionType *connection) 44 | { 45 | struct sockaddr_in addr; 46 | #ifdef OS_LINUX 47 | socklen_t len = sizeof(struct sockaddr_in); 48 | #else 49 | int len = sizeof(struct sockaddr_in); 50 | #endif 51 | //printf("tcp_server_accept: fd=%d\n", server->socket.fd); 52 | connection->socket.fd = accept(server->socket.fd, (struct sockaddr *)&addr, &len); 53 | if (connection->socket.fd < 0) { 54 | printf("%s %s() %u ret=%d\n", __FILE__, __FUNCTION__, __LINE__, errno); 55 | return STD_E_NOENT; 56 | } 57 | connection->connected = TRUE; 58 | return STD_E_OK; 59 | } 60 | 61 | void tcp_server_close(TcpServerType *server) 62 | { 63 | if (server != NULL) { 64 | tcp_socket_close(&server->socket); 65 | } 66 | return; 67 | } 68 | -------------------------------------------------------------------------------- /src/device/peripheral/mros-dev/mros-src/comm/cimpl/mros_comm_tcp_server_cimpl.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2012 mbed.org, MIT License 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 4 | * and associated documentation files (the "Software"), to deal in the Software without restriction, 5 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 6 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 7 | * furnished to do so, subject to the following conditions: 8 | * 9 | * The above copyright notice and this permission notice shall be included in all copies or 10 | * substantial portions of the Software. 11 | * 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 13 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 14 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 17 | */ 18 | #ifndef _MROS_COMM_TCP_SERVER_CIMPL_H_ 19 | #define _MROS_COMM_TCP_SERVER_CIMPL_H_ 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | #include "mros_comm_tcp_client_cimpl.h" 26 | 27 | typedef struct { 28 | mRosCommSocketType socket; 29 | } mRosCommTcpServerType; 30 | 31 | extern mRosReturnType mros_comm_tcp_server_init(mRosCommTcpServerType *server); 32 | extern mRosReturnType mros_comm_tcp_server_bind(mRosCommTcpServerType *server, mros_int32 port); 33 | #define MROS_COMM_TCP_SERVER_LISTEN_MAX_DEFAULT_VALUE 1 34 | extern mRosReturnType mros_comm_tcp_server_listen(mRosCommTcpServerType *server, mros_int32 max); 35 | extern mRosReturnType mros_comm_tcp_server_accept(mRosCommTcpServerType *server, mRosCommTcpClientType *client); 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | 41 | #endif /* _MROS_COMM_TCP_SERVER_CIMPL_H_ */ 42 | -------------------------------------------------------------------------------- /src/device/peripheral/mros-dev/mros-athrill/target/lwip/sockets.h: -------------------------------------------------------------------------------- 1 | #ifndef _MROS_SOCKET_H_ 2 | #define _MROS_SOCKET_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #ifdef OS_MAC 9 | #include 10 | #endif 11 | typedef unsigned int ip_addr_t; 12 | 13 | void lwip_init(void); 14 | 15 | void lwip_socket_init(void); 16 | 17 | int lwip_accept(int s, struct sockaddr *addr, socklen_t *addrlen); 18 | 19 | int lwip_bind(int s, const struct sockaddr *name, socklen_t namelen); 20 | int lwip_shutdown(int s, int how); 21 | int lwip_getpeername (int s, struct sockaddr *name, socklen_t *namelen); 22 | int lwip_getsockname (int s, struct sockaddr *name, socklen_t *namelen); 23 | int lwip_getsockopt (int s, int level, int optname, void *optval, socklen_t *optlen); 24 | int lwip_setsockopt (int s, int level, int optname, const void *optval, socklen_t optlen); 25 | int lwip_close(int s); 26 | 27 | int lwip_connect(int s, const struct sockaddr *name, socklen_t namelen); 28 | 29 | int lwip_listen(int s, int backlog); 30 | 31 | int lwip_recv(int s, void *mem, size_t len, int flags); 32 | 33 | int lwip_read(int s, void *mem, size_t len); 34 | int lwip_recvfrom(int s, void *mem, size_t len, int flags, 35 | struct sockaddr *from, socklen_t *fromlen); 36 | int lwip_send(int s, const void *dataptr, size_t size, int flags); 37 | int lwip_sendto(int s, const void *dataptr, size_t size, int flags, 38 | const struct sockaddr *to, socklen_t tolen); 39 | int lwip_socket(int domain, int type, int protocol); 40 | int lwip_write(int s, const void *dataptr, size_t size); 41 | 42 | int lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset, 43 | struct timeval *timeout); 44 | 45 | int lwip_ioctl(int s, long cmd, void *argp); 46 | int lwip_fcntl(int s, int cmd, int val); 47 | struct hostent *lwip_gethostbyname(const char *name); 48 | char *ipaddr_ntoa_r(const ip_addr_t *addr, char *buf, int buflen); 49 | 50 | #ifndef __cplusplus 51 | #define true 1 52 | #define false 0 53 | #endif 54 | 55 | #endif /* _MROS_SOCKET_H_ */ 56 | -------------------------------------------------------------------------------- /src/device/peripheral/mros-dev/mros-athrill/config/mros_usr_config.h: -------------------------------------------------------------------------------- 1 | #ifndef _MROS_USR_CONFIG_H_ 2 | #define _MROS_USR_CONFIG_H_ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include "mros_types.h" 9 | #include "mros_memory.h" 10 | #include "mros_os.h" 11 | 12 | 13 | /************************************** 14 | * TOPIC 15 | **************************************/ 16 | 17 | /* 18 | * num of max topics 19 | */ 20 | #define MROS_TOPIC_MAX_NUM 1024U 21 | 22 | /* 23 | * max name length of topic name 24 | */ 25 | #define MROS_TOPIC_NAME_MAXLEN 1024U 26 | /* 27 | * max name length of topic type name 28 | */ 29 | #define MROS_TOPIC_TYPENAME_MAXLEN 1024U 30 | 31 | 32 | /************************************** 33 | * TOPIC CONNECTOR 34 | **************************************/ 35 | /* 36 | * num of max publish topic connectors 37 | */ 38 | #define MROS_PUB_TOPIC_CONNECTOR_MAX_NUM 1024U 39 | 40 | /* 41 | * num of max subscribe topic connectors 42 | */ 43 | #define MROS_SUB_TOPIC_CONNECTOR_MAX_NUM 1024U 44 | 45 | /* 46 | * max queue length of outer connection topic data buffering 47 | */ 48 | #define MROS_OUTER_CONNECTOR_QUEUE_MAXLEN 1 49 | 50 | 51 | /************************************** 52 | * NODE 53 | **************************************/ 54 | /* 55 | * num of max nodes 56 | */ 57 | #define MROS_NODE_MAX_NUM 1024U 58 | /* 59 | * max name length of node name 60 | */ 61 | #define MROS_NODE_NAME_MAXLEN 1024U 62 | 63 | /* 64 | * do not change for mROS inner data 65 | */ 66 | extern mRosMemoryManagerType ros_inner_topic_publisher_mempool; 67 | extern mRosMemoryManagerType ros_outer_topic_publisher_mempool; 68 | 69 | /**************************************** 70 | * USR OS TASK 71 | ****************************************/ 72 | /* 73 | * num of user task 74 | * 75 | * following config parameter is an example. 76 | * 77 | * please change corresponding variable definitions 78 | * of mros_usr_config.c for changing these parameters. 79 | */ 80 | #define MROS_USR_TASK_NUM 1 // for athrill-thread 81 | /* 82 | * do not change for mROS inner data 83 | */ 84 | extern mRosTaskIdType mros_usr_task_table[MROS_USR_TASK_NUM]; 85 | 86 | #ifdef __cplusplus 87 | } 88 | #endif 89 | 90 | #endif /* _MROS_USR_CONFIG_H_ */ 91 | 92 | -------------------------------------------------------------------------------- /src/device/peripheral/mros-dev/mros-src/comm/cimpl/target/lwip/mros_comm_target.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2012 mbed.org, MIT License 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 4 | * and associated documentation files (the "Software"), to deal in the Software without restriction, 5 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 6 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 7 | * furnished to do so, subject to the following conditions: 8 | * 9 | * The above copyright notice and this permission notice shall be included in all copies or 10 | * substantial portions of the Software. 11 | * 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 13 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 14 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 17 | */ 18 | #ifndef _MROS_COMM_TARGET_H_ 19 | #define _MROS_COMM_TARGET_H_ 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | #include "mros_types.h" 26 | #include "lwip/sockets.h" 27 | #include "lwip/init.h" 28 | #include "lwip/netdb.h" 29 | 30 | typedef struct sockaddr mRosSockAddrType; 31 | typedef struct sockaddr_in mRosSockAddrInType; 32 | typedef struct hostent mRosHostEntType; 33 | typedef ip_addr_t mRosIpAaddrType; 34 | typedef fd_set mRosFdSetType; 35 | typedef struct timeval mRosTimeValType; 36 | 37 | #define MROS_FD_ZERO(arg) FD_ZERO(arg) 38 | #define MROS_FD_SET(arg1, arg2) FD_SET(arg1, arg2) 39 | #define MROS_FD_SETSIZE FD_SETSIZE 40 | #define MROS_FD_ISSET(arg1, arg2) FD_ISSET(arg1, arg2) 41 | 42 | #define MROS_SOCK_STREAM SOCK_STREAM 43 | #define MROS_SOCK_DGRAM SOCK_DGRAM 44 | #define MROS_SOCK_RAW SOCK_RAW 45 | 46 | #define MROS_SOCK_UNSPEC AF_UNSPEC 47 | #define MROS_SOCK_AF_INET AF_INET 48 | 49 | 50 | #ifdef __cplusplus 51 | } 52 | #endif 53 | 54 | 55 | #endif /* _MROS_COMM_TARGET_H_ */ 56 | -------------------------------------------------------------------------------- /.github/workflows/packagebuild.yml: -------------------------------------------------------------------------------- 1 | name: package build 2 | 3 | on: 4 | push: 5 | tags: 6 | - 'v*' 7 | - 'RC*' 8 | 9 | jobs: 10 | build: 11 | runs-on: ubuntu-18.04 12 | steps: 13 | - name: Checkout Repository 14 | uses: actions/checkout@v2 15 | with: 16 | submodules: true # Fetch athrill repo 17 | fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod 18 | 19 | - name: Archive package 20 | id: get_archive 21 | run: | 22 | git clone https://github.com/mitsut/toppers_utils.git 23 | perl toppers_utils/makerelease 24 | FILE_NAME="$(ls -1 RELEASE/ | sed -n 1p)" 25 | echo ::set-output name=FILE_NAME::${FILE_NAME} 26 | 27 | - name: Get the version 28 | id: get_version 29 | run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/} 30 | 31 | - name: Get commit summary 32 | id: get_commit_summary 33 | run: | 34 | PREVIOUS_TAG=$(git tag --sort=-creatordate | sed -n 2p) 35 | echo "PREVIOUS_TAG: $PREVIOUS_TAG" 36 | COMMIT_SUMMARY="$(git log --oneline --pretty=tformat:"%h %s" $PREVIOUS_TAG..${{ github.ref }})" 37 | COMMIT_SUMMARY="${COMMIT_SUMMARY//$'\n'/'%0A'}" 38 | echo ::set-output name=COMMIT_SUMMARY::$COMMIT_SUMMARY 39 | 40 | - name: Create Release 41 | id: create_release 42 | uses: actions/create-release@v1 43 | env: 44 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 45 | with: 46 | tag_name: ${{ steps.get_version.outputs.VERSION }} 47 | release_name: Release ${{ steps.get_version.outputs.VERSION }} 48 | body: | 49 | ${{ steps.get_commit_summary.outputs.COMMIT_SUMMARY }} 50 | draft: true 51 | prerelease: true 52 | 53 | - uses: actions/upload-release-asset@master 54 | env: 55 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 56 | with: 57 | upload_url: ${{ steps.create_release.outputs.upload_url }} 58 | # 添付ファイルのパス (必須) 59 | asset_path: ./RELEASE/${{ steps.get_archive.outputs.FILE_NAME }} 60 | # 添付ファイルの表示名 (必須) 61 | asset_name: ${{ steps.get_archive.outputs.FILE_NAME }} 62 | # 添付ファイルに対応する content-type (必須) 63 | asset_content_type: application/zip -------------------------------------------------------------------------------- /src/device/peripheral/mros-dev/mros-src/transfer/cimpl/mros_topic_data_subscriber_cimpl.c: -------------------------------------------------------------------------------- 1 | #include "mros_topic_data_subscriber_cimpl.h" 2 | #include "mros_topic_connector_factory_cimpl.h" 3 | #include "mros_topic_cimpl.h" 4 | #include "mros_array_container.h" 5 | #include "mros_usr_config.h" 6 | 7 | MROS_ARRAY_CONTAINER_CONFIG_DECLARE_MANAGER(mros_topic_sub_mgr, MROS_TOPIC_MAX_NUM); 8 | 9 | static void mros_topic_subscribe(mRosTopicConnectorManagerType *mgrp, mRosNodeEnumType type, mRosContainerObjType topic_obj, mRosMemoryListEntryType *topic_data) 10 | { 11 | mRosReturnType ret; 12 | mRosContainerObjType obj; 13 | 14 | obj = mros_topic_connector_get_first(mgrp, type, topic_obj); 15 | if (obj == MROS_COBJ_NULL) { 16 | return; 17 | } 18 | 19 | while (obj != MROS_COBJ_NULL) { 20 | ret = mros_topic_connector_send_data(mgrp, obj, topic_data->data.memp, topic_data->data.size); 21 | if (ret != MROS_E_OK) { 22 | ROS_ERROR("%s %s() %u ret=%d", __FILE__, __FUNCTION__, __LINE__, ret); 23 | } 24 | obj = mros_topic_connector_get_next(mgrp, topic_obj, obj); 25 | } 26 | 27 | return; 28 | } 29 | 30 | mRosReturnType mros_topic_data_subscriber_init(void) 31 | { 32 | return MROS_E_OK; 33 | } 34 | 35 | void mros_topic_data_subscriber_run(void) 36 | { 37 | mRosContainerObjType topic_obj; 38 | mRosTopicConnectorManagerType *mgrp; 39 | mRosMemoryListEntryType *topic_data; 40 | mRosTopicIdType topic_id; 41 | mRosReturnType ret; 42 | mros_uint32 i; 43 | 44 | mgrp = mros_topic_connector_factory_get(MROS_TOPIC_CONNECTOR_SUB); 45 | if (mgrp == MROS_NULL) { 46 | return; 47 | } 48 | mros_topic_sub_mgr.count = 0; 49 | 50 | topic_obj = mros_topic_connector_get_topic_first(mgrp); 51 | while (topic_obj != MROS_COBJ_NULL) { 52 | mros_array_container_add(&mros_topic_sub_mgr, topic_obj); 53 | topic_obj = mros_topic_connector_get_topic_next(mgrp, topic_obj); 54 | } 55 | for (i = 0; i < mros_topic_sub_mgr.count; i++) { 56 | ret = mros_topic_connector_get_topic(mros_topic_sub_mgr.array[i], &topic_id); 57 | if (ret != MROS_E_OK) { 58 | continue; 59 | } 60 | ret = mros_topic_get_data(topic_id, &topic_data); 61 | if (ret == MROS_E_OK) { 62 | mros_topic_subscribe(mgrp, MROS_NODE_TYPE_INNER, mros_topic_sub_mgr.array[i], topic_data); 63 | mros_topic_subscribe(mgrp, MROS_NODE_TYPE_OUTER, mros_topic_sub_mgr.array[i], topic_data); 64 | (void)mros_mem_free(topic_data->data.mgrp, topic_data); 65 | } 66 | } 67 | 68 | mros_topic_connector_purge(mgrp); 69 | return; 70 | } 71 | -------------------------------------------------------------------------------- /src/device/mpu/mpu_types.h: -------------------------------------------------------------------------------- 1 | #ifndef _MPU_TYPES_H_ 2 | #define _MPU_TYPES_H_ 3 | 4 | #include "std_types.h" 5 | 6 | typedef enum { 7 | READONLY_MEMORY = 0, 8 | GLOBAL_MEMORY, 9 | LOCAL_MEMORY, 10 | PRIVATE_MEMORY, 11 | DEVICE, 12 | REGION_UNKNOWN, 13 | } MpuAddressRegionEnumType; 14 | 15 | extern MpuAddressRegionEnumType mpu_address_region_type_get(uint32 addr, std_bool *is_malloc); 16 | 17 | #define MPU_ADDRESS_REGION_MASK_ALL 0xFFFFFFFF 18 | #define MPU_ADDRESS_REGION_PERM_ALL 0xFFFFFFFF 19 | 20 | struct mpu_address_region_operation_type; 21 | typedef struct { 22 | MpuAddressRegionEnumType type; 23 | bool is_malloc; 24 | /* 25 | * 本メモリ領域にアクセスできるcore_idのビットマップ 26 | * ビット位置がCPUのコアIDに対応する 27 | * 0:許可されてない 28 | * 1:許可されている 29 | */ 30 | uint32 permission; 31 | uint32 start; 32 | uint32 size; 33 | uint32 mask; 34 | uint8 *data; 35 | struct mpu_address_region_operation_type *ops; 36 | } MpuAddressRegionType; 37 | 38 | typedef struct mpu_address_region_operation_type { 39 | Std_ReturnType (*get_data8) (MpuAddressRegionType *region, CoreIdType core_id, uint32 addr, uint8 *data); 40 | Std_ReturnType (*get_data16) (MpuAddressRegionType *region, CoreIdType core_id, uint32 addr, uint16 *data); 41 | Std_ReturnType (*get_data32) (MpuAddressRegionType *region, CoreIdType core_id, uint32 addr, uint32 *data); 42 | 43 | Std_ReturnType (*put_data8) (MpuAddressRegionType *region, CoreIdType core_id, uint32 addr, uint8 data); 44 | Std_ReturnType (*put_data16) (MpuAddressRegionType *region, CoreIdType core_id, uint32 addr, uint16 data); 45 | Std_ReturnType (*put_data32) (MpuAddressRegionType *region, CoreIdType core_id, uint32 addr, uint32 data); 46 | 47 | Std_ReturnType (*get_pointer) (MpuAddressRegionType *region, CoreIdType core_id, uint32 addr, uint8 **data); 48 | } MpuAddressRegionOperationType; 49 | 50 | extern MpuAddressRegionOperationType default_memory_operation; 51 | 52 | 53 | #ifdef CPU_CONFIG_MEMORY_PROTECTION_ENABLE 54 | #include "target_cpu.h" 55 | extern bool cpu_has_permission(CoreIdType core_id, MpuAddressRegionEnumType region_type, CpuMemoryAccessType access_type, uint32 addr, uint32 size); 56 | #define CPU_HAS_PERMISSION(core_id, region_type, access_type, addr, size) cpu_has_permission(core_id, region_type, access_type, addr, size) 57 | #else 58 | #define CPU_HAS_PERMISSION(core_id, region_type, access_type, addr, size) TRUE 59 | #endif /* MPU_CONFIG_PROTECTION_ENABLE */ 60 | 61 | #endif /* _MPU_TYPES_H_ */ 62 | -------------------------------------------------------------------------------- /src/lib/dwarf/data_type/elf_dwarf_enum_type.c: -------------------------------------------------------------------------------- 1 | #include "elf_dwarf_enum_type.h" 2 | #include "assert.h" 3 | 4 | void elf_dwarf_build_enum_type(ElfDwarfDieType *die) 5 | { 6 | uint32 size; 7 | int i; 8 | int j; 9 | DwarfDataEnumulatorType *obj = dwarf_alloc_data_type(DATA_TYPE_ENUM); 10 | ElfDwarfAttributeType *attr; 11 | ElfDwarfAbbrevType *abbrev; 12 | DwAtType attr_type; 13 | ElfDwarfDieType *member; 14 | 15 | for (i = 0; i < die->attribute->current_array_size; i++) { 16 | abbrev = (ElfDwarfAbbrevType *)die->abbrev_info; 17 | attr = (ElfDwarfAttributeType*)die->attribute->data[i]; 18 | attr_type = abbrev->attribute_name->data[i]; 19 | //printf("name=0x%x form=%s\n", attr_type, attr->typename); 20 | switch (attr_type) { 21 | case DW_AT_name: 22 | obj->info.typename = attr->encoded.string; 23 | break; 24 | case DW_AT_byte_size: 25 | obj->info.size = elf_dwarf_info_get_value(abbrev->attribute_form->data[i], attr, &size); 26 | break; 27 | case DW_AT_sibling: 28 | case DW_AT_decl_file: 29 | case DW_AT_decl_line: 30 | case DW_AT_decl_column: 31 | case DW_AT_MIPS_linkage_name: 32 | case DW_AT_encoding: 33 | case DW_AT_type: 34 | case DW_AT_accessibility: 35 | case DW_AT_virtuality: 36 | case DW_AT_linkage_name: 37 | case DW_AT_enum_class: 38 | break; 39 | default: 40 | printf("name=0x%x form=%s\n", attr_type, attr->typename); 41 | ASSERT(0); 42 | } 43 | } 44 | 45 | for (i = 0; i < die->children->current_array_size; i++) { 46 | DwarfDataEnumMember mem; 47 | mem.name = NULL; 48 | mem.const_value = 0; 49 | member = (ElfDwarfDieType*)die->children->data[i]; 50 | abbrev = (ElfDwarfAbbrevType *)member->abbrev_info; 51 | if (member->abbrev_info->tag != DW_TAG_enumerator) { 52 | continue; 53 | } 54 | for (j = 0; j < member->attribute->current_array_size; j++) { 55 | attr = (ElfDwarfAttributeType*)member->attribute->data[j]; 56 | attr_type = abbrev->attribute_name->data[j]; 57 | //printf("member name=0x%x form=%s\n", attr_type, attr->typename); 58 | switch (attr_type) { 59 | case DW_AT_name: 60 | mem.name = attr->encoded.string; 61 | //printf("enum mem=%s\n", mem.name); 62 | break; 63 | case DW_AT_const_value: 64 | mem.const_value = elf_dwarf_info_get_value(abbrev->attribute_form->data[j], attr, &size); 65 | break; 66 | default: 67 | ASSERT(0); 68 | } 69 | } 70 | dwarf_add_enum_member(obj, mem.name, mem.const_value); 71 | } 72 | 73 | obj->info.die = die; 74 | dwarf_register_data_type(&obj->info); 75 | } 76 | -------------------------------------------------------------------------------- /src/lib/dwarf/data_type/elf_dwarf_typedef_type.c: -------------------------------------------------------------------------------- 1 | #include "elf_dwarf_typedef_type.h" 2 | #include "assert.h" 3 | 4 | void elf_dwarf_build_typedef_type(ElfDwarfDieType *die) 5 | { 6 | int i; 7 | uint32 size; 8 | DwarfDataTypedefType *obj = dwarf_alloc_data_type(DATA_TYPE_TYPEDEF); 9 | ElfDwarfAttributeType *attr; 10 | ElfDwarfAbbrevType *abbrev; 11 | DwAtType attr_type; 12 | uint32 offset; 13 | Std_ReturnType err; 14 | 15 | //printf("elf_dwarf_build_typedef_type:off=0x%x\n", die->offset); 16 | //printf("typedef_type\n"); 17 | for (i = 0; i < die->attribute->current_array_size; i++) { 18 | abbrev = (ElfDwarfAbbrevType *)die->abbrev_info; 19 | attr = (ElfDwarfAttributeType*)die->attribute->data[i]; 20 | attr_type = abbrev->attribute_name->data[i]; 21 | //printf("name=0x%x form=%s\n", attr_type, attr->typename); 22 | switch (attr_type) { 23 | case DW_AT_name: 24 | obj->info.typename = attr->encoded.string; 25 | break; 26 | case DW_AT_type: 27 | offset = elf_dwarf_info_get_value(abbrev->attribute_form->data[i], attr, &size); 28 | err = dwarf_get_real_type_offset(offset, &obj->ref_debug_info_offset); 29 | if (err == STD_E_OK) { 30 | obj->is_valid_ref_debug_info_offset = TRUE; 31 | } 32 | break; 33 | case DW_AT_accessibility: 34 | case DW_AT_decl_file: 35 | case DW_AT_decl_line: 36 | case DW_AT_decl_column: 37 | break; 38 | default: 39 | printf("name=0x%x form=%s\n", attr_type, attr->typename); 40 | ASSERT(0); 41 | } 42 | } 43 | obj->info.die = die; 44 | //printf("typedef=%s ref_offset=0x%x\n", obj->info.typename, obj->ref_debug_info_offset); 45 | 46 | dwarf_register_data_type(&obj->info); 47 | 48 | return; 49 | } 50 | void elf_dwarf_resolve_typedef_type(void) 51 | { 52 | int i; 53 | ElfPointerArrayType *my_types = dwarf_get_data_types(DATA_TYPE_TYPEDEF); 54 | DwarfDataTypedefType *obj; 55 | 56 | if (my_types == NULL) { 57 | return; 58 | } 59 | 60 | for (i = 0; i < my_types->current_array_size; i++) { 61 | obj = (DwarfDataTypedefType *)my_types->data[i]; 62 | if (obj->ref != NULL) { 63 | continue; 64 | } 65 | if (obj->is_valid_ref_debug_info_offset == FALSE) { 66 | continue; 67 | } 68 | obj->ref = elf_dwarf_get_data_type(obj->ref_debug_info_offset); 69 | if (obj->ref == NULL) { 70 | //printf("Not supported:unknown typeref(%s) debug_offset=0x%x\n", obj->info.typename, obj->ref_debug_info_offset); 71 | } 72 | else { 73 | //printf("typedef %s %s\n", obj->ref->typename, obj->info.typename); 74 | } 75 | } 76 | 77 | return; 78 | } 79 | -------------------------------------------------------------------------------- /src/device/peripheral/mros-dev/mros-src/transfer/cimpl/mros_topic_data_publisher_cimpl.c: -------------------------------------------------------------------------------- 1 | #include "mros_topic_data_publisher_cimpl.h" 2 | #include "mros_topic_connector_factory_cimpl.h" 3 | #include "mros_topic_cimpl.h" 4 | #include "mros_array_container.h" 5 | #include "mros_usr_config.h" 6 | 7 | MROS_ARRAY_CONTAINER_CONFIG_DECLARE_MANAGER(mros_topic_pub_mgr, MROS_TOPIC_MAX_NUM); 8 | 9 | static void mros_topic_publish(mRosTopicConnectorManagerType *mgrp, mRosNodeEnumType type, mRosContainerObjType topic_obj) 10 | { 11 | mRosReturnType ret; 12 | mRosContainerObjType obj; 13 | mRosMemoryListEntryType *topic_data; 14 | mRosTopicIdType topic_id; 15 | 16 | ret = mros_topic_connector_get_topic(topic_obj, &topic_id); 17 | if (ret != MROS_E_OK) { 18 | return; 19 | } 20 | 21 | obj = mros_topic_connector_get_first(mgrp, type, topic_obj); 22 | if (obj == MROS_COBJ_NULL) { 23 | return; 24 | } 25 | while (obj != MROS_COBJ_NULL) { 26 | ret = mros_topic_connector_receive_data(mgrp, obj, &topic_data); 27 | if (ret != MROS_E_OK) { 28 | obj = mros_topic_connector_get_next(mgrp, topic_obj, obj); 29 | continue; 30 | } 31 | ret = mros_topic_add_data(topic_id, topic_data); 32 | if (ret != MROS_E_OK) { 33 | ROS_ERROR("%s %s() %u ret=%d", __FILE__, __FUNCTION__, __LINE__, ret); 34 | (void)mros_mem_free(topic_data->data.mgrp, topic_data); 35 | } 36 | obj = mros_topic_connector_get_next(mgrp, topic_obj, obj); 37 | } 38 | 39 | return; 40 | } 41 | 42 | mRosReturnType mros_topic_data_publisher_init(void) 43 | { 44 | return MROS_E_OK; 45 | } 46 | 47 | void mros_topic_data_publisher_run(void) 48 | { 49 | mRosContainerObjType topic_obj; 50 | mRosTopicConnectorManagerType *mgrp; 51 | 52 | mgrp = mros_topic_connector_factory_get(MROS_TOPIC_CONNECTOR_PUB); 53 | if (mgrp == MROS_NULL) { 54 | return; 55 | } 56 | mros_topic_pub_mgr.count = 0; 57 | 58 | /************************** 59 | * INNER NODE 60 | **************************/ 61 | topic_obj = mros_topic_connector_get_topic_first(mgrp); 62 | while (topic_obj != MROS_COBJ_NULL) { 63 | mros_array_container_add(&mros_topic_pub_mgr, topic_obj); 64 | 65 | mros_topic_publish(mgrp, MROS_NODE_TYPE_INNER, topic_obj); 66 | topic_obj = mros_topic_connector_get_topic_next(mgrp, topic_obj); 67 | } 68 | 69 | /************************** 70 | * OUTER NODE 71 | **************************/ 72 | mros_uint32 i; 73 | for (i = 0; i < mros_topic_pub_mgr.count; i++) { 74 | mros_topic_publish(mgrp, MROS_NODE_TYPE_OUTER, mros_topic_pub_mgr.array[i]); 75 | } 76 | 77 | mros_topic_connector_purge(mgrp); 78 | return; 79 | } 80 | -------------------------------------------------------------------------------- /src/device/peripheral/mros-dev/mros-src/topic/cimpl/mros_topic_connector_factory_cimpl.c: -------------------------------------------------------------------------------- 1 | #include "mros_topic_connector_factory_cimpl.h" 2 | #include "mros_sys_config.h" 3 | 4 | static mros_boolean mros_topic_connector_is_inialized[MROS_TOPIC_CONNECTOR_NUM] = { 5 | MROS_FALSE, 6 | MROS_FALSE, 7 | }; 8 | /* 9 | * topic connector Config APIs 10 | */ 11 | #define MROS_TOPIC_CONNECTOR_CONFIG_DECLARE_MANAGER(manager_name, conn_entry_num) \ 12 | static mRosTopicConnectorListEntryType manager_name##_conn_array [(conn_entry_num)] MROS_MATTR_BSS_NOCLR; \ 13 | static mRosTopicConnectorListEntryRootType manager_name##_topic_array [MROS_TOPIC_MAX_NUM] MROS_MATTR_BSS_NOCLR; \ 14 | static mRosTopicConnectorManagerType manager_name MROS_MATTR_BSS_NOCLR; \ 15 | static mRosTopicConnectorConfigType manager_name##_config = { \ 16 | (conn_entry_num), \ 17 | manager_name##_conn_array, \ 18 | manager_name##_topic_array, \ 19 | }; 20 | 21 | MROS_TOPIC_CONNECTOR_CONFIG_DECLARE_MANAGER(pub_connector_mgr, (MROS_PUB_TOPIC_CONNECTOR_MAX_NUM) ); 22 | MROS_TOPIC_CONNECTOR_CONFIG_DECLARE_MANAGER(sub_connector_mgr, (MROS_SUB_TOPIC_CONNECTOR_MAX_NUM) ); 23 | 24 | mRosTopicConnectorManagerType *mros_topic_connector_factory_create(mRosTopicConnectorEnumType type) 25 | { 26 | mRosTopicConnectorManagerType *mgrp = MROS_NULL; 27 | mRosTopicConnectorConfigType *cfgp = MROS_NULL; 28 | mRosReturnType ret; 29 | 30 | switch (type) { 31 | case MROS_TOPIC_CONNECTOR_PUB: 32 | mgrp = &pub_connector_mgr; 33 | cfgp = &pub_connector_mgr_config; 34 | break; 35 | case MROS_TOPIC_CONNECTOR_SUB: 36 | mgrp = &sub_connector_mgr; 37 | cfgp = &sub_connector_mgr_config; 38 | break; 39 | default: 40 | break; 41 | } 42 | if (mgrp == MROS_NULL) { 43 | return MROS_NULL; 44 | } 45 | if (mros_topic_connector_is_inialized[type] == MROS_TRUE) { 46 | return mgrp; 47 | } 48 | ret = mros_topic_connector_init(cfgp, mgrp); 49 | if (ret != MROS_E_OK) { 50 | return MROS_NULL; 51 | } 52 | mros_topic_connector_is_inialized[type] = MROS_TRUE; 53 | return mgrp; 54 | } 55 | 56 | mRosTopicConnectorManagerType *mros_topic_connector_factory_get(mRosTopicConnectorEnumType type) 57 | { 58 | mRosTopicConnectorManagerType *mgrp = MROS_NULL; 59 | 60 | switch (type) { 61 | case MROS_TOPIC_CONNECTOR_PUB: 62 | mgrp = &pub_connector_mgr; 63 | break; 64 | case MROS_TOPIC_CONNECTOR_SUB: 65 | mgrp = &sub_connector_mgr; 66 | break; 67 | default: 68 | break; 69 | } 70 | if (mgrp == MROS_NULL) { 71 | return MROS_NULL; 72 | } 73 | if (mros_topic_connector_is_inialized[type] == MROS_FALSE) { 74 | return MROS_NULL; 75 | } 76 | return mgrp; 77 | } 78 | -------------------------------------------------------------------------------- /src/lib/dwarf/data_type/elf_dwarf_pointer_type.c: -------------------------------------------------------------------------------- 1 | #include "elf_dwarf_pointer_type.h" 2 | #include "assert.h" 3 | 4 | void elf_dwarf_build_pointer_type(ElfDwarfDieType *die) 5 | { 6 | int i; 7 | uint32 size; 8 | DwarfDataPointerType *obj = dwarf_alloc_data_type(DATA_TYPE_POINTER); 9 | ElfDwarfAttributeType *attr; 10 | ElfDwarfAbbrevType *abbrev; 11 | DwAtType attr_type; 12 | uint32 offset; 13 | Std_ReturnType err; 14 | 15 | obj->info.typename = "*"; 16 | obj->is_valid_ref_debug_info_offset = FALSE; 17 | 18 | //printf("elf_dwarf_build_pointer_type:off=0x%x\n", die->offset); 19 | for (i = 0; i < die->attribute->current_array_size; i++) { 20 | abbrev = (ElfDwarfAbbrevType *)die->abbrev_info; 21 | attr = (ElfDwarfAttributeType*)die->attribute->data[i]; 22 | attr_type = abbrev->attribute_name->data[i]; 23 | switch (attr_type) { 24 | case DW_AT_name: 25 | obj->info.typename = attr->typename; 26 | break; 27 | case DW_AT_byte_size: 28 | obj->info.size = elf_dwarf_info_get_value(abbrev->attribute_form->data[i], attr, &size); 29 | break; 30 | case DW_AT_type: 31 | offset = elf_dwarf_info_get_value(abbrev->attribute_form->data[i], attr, &size); 32 | err = dwarf_get_real_type_offset(offset, &obj->ref_debug_info_offset); 33 | if (err == STD_E_OK) { 34 | obj->is_valid_ref_debug_info_offset = TRUE; 35 | } 36 | //printf("ref_debug_info_offset:off=0x%x\n", obj->ref_debug_info_offset); 37 | break; 38 | default: 39 | printf("die=0x%x attr=0x%x\n", die->offset, attr_type); 40 | ASSERT(0); 41 | } 42 | } 43 | obj->info.die = die; 44 | 45 | dwarf_register_data_type(&obj->info); 46 | 47 | return; 48 | } 49 | 50 | void elf_dwarf_resolve_pointer_type(void) 51 | { 52 | int i; 53 | ElfPointerArrayType *my_types = dwarf_get_data_types(DATA_TYPE_POINTER); 54 | DwarfDataPointerType *obj; 55 | if (my_types == NULL) { 56 | return; 57 | } 58 | for (i = 0; i < my_types->current_array_size; i++) { 59 | obj = (DwarfDataPointerType *)my_types->data[i]; 60 | if (obj->ref != NULL) { 61 | continue; 62 | } 63 | if (obj->is_valid_ref_debug_info_offset == FALSE) { 64 | continue; 65 | } 66 | obj->ref = elf_dwarf_get_data_type(obj->ref_debug_info_offset); 67 | //printf("pointer(0x%x):off=0x%x ref_off=0x%x\n", obj->info.die->offset, obj->ref_debug_info_offset, obj->ref->die->offset); 68 | if (obj->ref == NULL) { 69 | //printf("Not supported:unknown typeref(%s) debug_offset=0x%x\n", obj->info.typename, obj->ref_debug_info_offset); 70 | } 71 | else { 72 | //printf("pointer %s %s\n", obj->ref->typename, obj->info.typename); 73 | } 74 | } 75 | return; 76 | } 77 | -------------------------------------------------------------------------------- /src/debugger/interaction/front/parser/dbg_parser.c: -------------------------------------------------------------------------------- 1 | #include "std_errno.h" 2 | #include "front/parser/dbg_parser.h" 3 | #include "front/parser/dbg_parser_config.h" 4 | #include "concrete_executor/dbg_std_executor.h" 5 | #include "cpu_control/dbg_cpu_control.h" 6 | #include "cui/cui_ops.h" 7 | #include 8 | #include 9 | 10 | static DbgCmdExecutorType *last_command = NULL; 11 | static DbgCmdExecutorType parse_command; 12 | 13 | static bool can_execute(DbgCmdExecutorType *res, DbgModeType *mode) 14 | { 15 | if (cpuctrl_is_debug_mode() == TRUE) { 16 | *mode = DBG_MODE_DEBUG; 17 | if (res->std_id != DBG_CMD_STD_ID_QUIT) { 18 | return TRUE; 19 | } 20 | } 21 | else { //DBG_MODE_CPU 22 | *mode = DBG_MODE_CPU; 23 | if (res->std_id == DBG_CMD_STD_ID_QUIT) { 24 | return TRUE; 25 | } 26 | } 27 | return FALSE; 28 | } 29 | 30 | DbgCmdExecutorType *dbg_parse(uint8 *str, uint32 len) 31 | { 32 | Std_ReturnType err; 33 | uint32 i; 34 | DbgCmdExecutorType *res = NULL; 35 | DbgCmdExecutorType *arg = NULL; 36 | TokenContainerType token_container; 37 | DbgModeType mode; 38 | //printf("dbg_parse:str=%s len=%u\n", str, len); 39 | 40 | //memset(&token_container, 0, sizeof(TokenContainerType)); 41 | if ((len == 0) && (last_command != NULL)) { 42 | /* 43 | * 改行の場合は,最後のコマンドを実行する. 44 | */ 45 | arg = last_command; 46 | return arg; 47 | } 48 | else { 49 | /* 50 | * デフォルトエラーを作成する. 51 | */ 52 | arg = &parse_command; 53 | memcpy(arg->original_str, str, len); 54 | arg->original_str[len] = '\0'; 55 | arg->std_id = DBG_CMD_STD_ID_PARSE_ERROR; 56 | arg->run = dbg_std_executor_parse_error; 57 | memset(arg->parsed_args, 0, sizeof(arg->parsed_args)); 58 | } 59 | 60 | /* 61 | * 文字列をトークン分割する 62 | */ 63 | err = token_split(&token_container, str, len); 64 | if (err != STD_E_OK) { 65 | goto errdone; 66 | } 67 | 68 | 69 | /* 70 | * パースする. 71 | */ 72 | for (i = 0; i < DBG_CMD_STD_ID_NUM; i++) { 73 | res = dbg_cmd_parser_std_table[i].parse(arg, &token_container); 74 | if (res != NULL) { 75 | break; 76 | } 77 | } 78 | if (res == NULL) { 79 | goto errdone; 80 | } 81 | 82 | if (can_execute(res, &mode) == FALSE) { 83 | printf("ERROR:can not execute command on %s\n", (mode == DBG_MODE_DEBUG) ? "DEBUG_MODE" : "CPU_MODE"); 84 | CUI_PRINTF((CPU_PRINT_BUF(), CPU_PRINT_BUF_LEN(), "NG\n")); 85 | return NULL; 86 | } 87 | /* 88 | * 成功の場合は,最後のコマンドを記録する. 89 | */ 90 | last_command = res; 91 | 92 | return res; 93 | errdone: 94 | last_command = NULL; 95 | /* 96 | * ヒットしない場合は,デフォルトエラーを返す. 97 | */ 98 | return &parse_command; 99 | } 100 | -------------------------------------------------------------------------------- /src/device/peripheral/mros-dev/mros-src/inc/mros_types.h: -------------------------------------------------------------------------------- 1 | #ifndef _MROS_TYPES_H_ 2 | #define _MROS_TYPES_H_ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | typedef int mros_int32; 9 | typedef char mros_int8; 10 | typedef unsigned char mros_uint8; 11 | typedef unsigned short mros_uint16; 12 | typedef unsigned int mros_uint32; 13 | typedef unsigned char mros_boolean; 14 | #define MROS_FALSE 0 15 | #define MROS_TRUE 1 16 | 17 | #define MROS_ID_NONE 0 18 | #define MROS_ID(index) ((index) + 1U) 19 | #define MROS_INDEX(id) ((id) - 1U) 20 | 21 | typedef mros_uint32 mRosNodeIdType; 22 | typedef mros_uint32 mRosTopicIdType; 23 | typedef mros_uint32 mRosTopicConnectorIdType; 24 | typedef mros_uint32 mRosPacketIdType; 25 | typedef mros_uint32 mRosIdType; 26 | typedef mros_uint32* mRosFuncIdType; 27 | typedef mros_int8* mRosPtrType; 28 | 29 | typedef mros_uint32* mRosContainerObjType; 30 | #define MROS_NULL (0) 31 | #define MROS_COBJ_NULL ((mRosContainerObjType)MROS_NULL) 32 | 33 | typedef mros_uint32 mRosSizeType; 34 | 35 | #define MROS_E_OK 0 36 | #define MROS_E_NOENT 2 37 | #define MROS_E_NOMEM 12 38 | #define MROS_E_BUSY 13 39 | #define MROS_E_EXIST 17 40 | #define MROS_E_INVAL 22 41 | #define MROS_E_RANGE 34 42 | #define MROS_E_LIMIT 111 43 | #define MROS_E_NOTCONN 112 44 | #define MROS_E_SYSERR -1 45 | typedef mros_int32 mRosReturnType; 46 | 47 | /* 48 | * OS dependent data types 49 | */ 50 | #include "mros_os_target.h" 51 | #define MROS_TASKID_NONE 0U 52 | 53 | /* 54 | * セクション属性マクロ 55 | * 56 | * - MROS_MATTR_BSS_NOCLR: 57 | * ヘッダの extern 宣言で使われる可能性があるため、 58 | * mac(__APPLE__)では空にしてコンパイルエラーを防ぐ。 59 | * 60 | * - MROS_SECTION_DEF: 61 | * 実体定義(.c)側でのみ付ける用。必要に応じて独自セクションへ配置。 62 | */ 63 | #if defined(__APPLE__) 64 | /* macOS (Mach-O): extern で使われる可能性があるので空にする */ 65 | #define MROS_MATTR_BSS_NOCLR 66 | /* 実体定義でセクションを分けたいときはこちらを使用 */ 67 | #define MROS_SECTION_DEF __attribute__((section("__DATA,__nc_bss"))) __attribute__((used)) 68 | #elif defined(__linux__) 69 | /* Linux (ELF) */ 70 | #define MROS_MATTR_BSS_NOCLR __attribute__((section("NC_BSS"))) 71 | #define MROS_SECTION_DEF __attribute__((section("NC_BSS"))) 72 | #elif defined(_WIN32) && defined(_MSC_VER) 73 | /* Windows (MSVC) */ 74 | #define MROS_MATTR_BSS_NOCLR /* ヘッダでは空推奨 */ 75 | #define MROS_SECTION_DEF __declspec(allocate(".nc_bss")) 76 | #else 77 | /* その他環境 */ 78 | #define MROS_MATTR_BSS_NOCLR 79 | #define MROS_SECTION_DEF 80 | #endif 81 | 82 | /* 83 | * Comm dependent data types 84 | */ 85 | #include "mros_comm_target.h" 86 | 87 | #ifdef __cplusplus 88 | } 89 | #endif 90 | 91 | #endif /* _MROS_TYPES_H_ */ 92 | -------------------------------------------------------------------------------- /src/device/peripheral/mros-dev/mros-src/comm/cimpl/mros_comm_socket_cimpl.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2012 mbed.org, MIT License 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 4 | * and associated documentation files (the "Software"), to deal in the Software without restriction, 5 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 6 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 7 | * furnished to do so, subject to the following conditions: 8 | * 9 | * The above copyright notice and this permission notice shall be included in all copies or 10 | * substantial portions of the Software. 11 | * 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 13 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 14 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 17 | */ 18 | #ifndef _MROS_COMM_SOCKET_CIMPL_H_ 19 | #define _MROS_COMM_SOCKET_CIMPL_H_ 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | #include "mros_comm_cimpl.h" 26 | 27 | typedef struct { 28 | mros_int32 sock_fd; 29 | mros_uint32 timeout; 30 | mros_boolean blocking; 31 | mros_int32 comm_type; 32 | } mRosCommSocketType; 33 | 34 | static inline void mros_comm_set_timeval(mros_uint32 tmo_msec, mRosTimeValType *tv) 35 | { 36 | mros_uint32 tv_sec = tmo_msec / 1000; 37 | mros_uint32 tv_usec = (tmo_msec - (tv_sec * 1000)) * 1000; 38 | mros_comm_timeval_set(tv_sec, tv_usec, tv); 39 | return; 40 | } 41 | 42 | typedef enum { 43 | MROS_COMM_SOCKET_TYPE_TCP = 0, 44 | MROS_COMM_SOCKET_TYPE_UDP, 45 | } mRosCommSocketEnumType; 46 | 47 | #define MROS_COMM_DEFAULT_TIMEOUT 1500 48 | 49 | extern mRosReturnType mros_comm_socket_init(mRosCommSocketType *socket, mRosCommSocketEnumType type); 50 | extern mRosReturnType mros_comm_socket_open(mRosCommSocketType *socket); 51 | extern void mros_comm_socket_close(mRosCommSocketType *socket); 52 | extern mRosReturnType mros_comm_socket_set_blocking(mRosCommSocketType *socket, mros_boolean blocking, mros_uint32 timeout); 53 | 54 | extern mRosReturnType mros_comm_socket_wait_readable(mRosCommSocketType *socket, mros_uint32 timeout); 55 | extern mRosReturnType mros_comm_socket_wait_writable(mRosCommSocketType *socket, mros_uint32 timeout); 56 | 57 | #ifdef __cplusplus 58 | } 59 | #endif 60 | 61 | #endif /* _MROS_COMM_SOCKET_CIMPL_H_ */ 62 | -------------------------------------------------------------------------------- /src/lib/target/target_os_api.h: -------------------------------------------------------------------------------- 1 | #ifndef _TARGET_OS_API_H_ 2 | #define _TARGET_OS_API_H_ 3 | 4 | #ifdef OS_LINUX 5 | //#define __USE_GNU 6 | /* 7 | * Sleep 8 | */ 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | #define target_os_api_sleep(arg) usleep((arg)*1000) 20 | #define winsock_init() 21 | #define winsock_fini() 22 | #ifdef OS_MAC 23 | #define PRINT_FMT_UINT64 "%llu" 24 | #define FMT_UINT64 "llu" 25 | #define FMT_SINT64 "lld" 26 | #define PRINT_FMT_SINT64 "%lld" 27 | #ifndef SOCK_NONBLOCK 28 | #define SOCK_NONBLOCK O_NONBLOCK 29 | #endif 30 | #else 31 | #define PRINT_FMT_UINT64 "%Lu" 32 | #define FMT_UINT64 "Lu" 33 | #define FMT_SINT64 "Ld" 34 | #define PRINT_FMT_SINT64 "%Ld" 35 | #endif /* OS_MAC */ 36 | #define target_os_api_sockaddr_type sockaddr_in 37 | #define target_os_api_closesocket close 38 | #define target_os_api_ioctlsock ioctl 39 | 40 | #define target_os_sockaddr_sin_addr s_addr 41 | 42 | #define target_os_api_open_ctw(filepath, mode) open((filepath), O_CREAT | O_TRUNC |O_WRONLY, (mode)) 43 | #define target_os_api_open_aw(filepath) open((filepath), O_APPEND |O_WRONLY) 44 | #define target_os_api_open_w(filepath) open((filepath), O_WRONLY) 45 | #define target_os_api_open_r(filepath) open((filepath), O_RDONLY) 46 | 47 | /* 48 | * Winsock 49 | */ 50 | #define TARGET_OS_SOCKET_TYPE int 51 | #else 52 | #include 53 | #include 54 | /* 55 | * Winsock 56 | */ 57 | #include "winsock_wrapper/winsock_wrapper.h" 58 | #define TARGET_OS_SOCKET_TYPE SOCKET 59 | #define target_os_api_sockaddr_type sockaddr_in 60 | 61 | 62 | /* 63 | * Sleep 64 | */ 65 | #define target_os_api_sleep(arg) Sleep(arg) 66 | #define PRINT_FMT_UINT64 "%I64u" 67 | #define FMT_UINT64 "I64u" 68 | #define PRINT_FMT_SINT64 "%I64d" 69 | #define FMT_SINT64 "I64d" 70 | #define target_os_api_open_ctw(filepath, mode) open((filepath), O_CREAT | O_TRUNC |O_WRONLY | O_BINARY, (mode)) 71 | #define target_os_api_open_aw(filepath) open((filepath), O_APPEND |O_WRONLY | O_BINARY) 72 | #define target_os_api_open_w(filepath) open((filepath), O_WRONLY | O_BINARY) 73 | #define target_os_api_open_r(filepath) open((filepath), O_RDONLY | O_BINARY) 74 | #define target_os_api_closesocket closesocket 75 | #define target_os_sockaddr_sin_addr S_un.S_addr 76 | 77 | //#define target_os_api_ioctlsock ioctlsock 78 | static inline void target_os_api_ioctlsock(SOCKET sock, int flag, unsigned long *valp) 79 | { 80 | ioctlsocket(sock, flag, valp); 81 | } 82 | #endif /* OS_LINUX */ 83 | /* 84 | * File I/O 85 | */ 86 | 87 | 88 | 89 | 90 | #endif /* _TARGET_OS_API_H_ */ 91 | -------------------------------------------------------------------------------- /src/inc/cpuemu_ops.h: -------------------------------------------------------------------------------- 1 | #ifndef _CPUEMU_OPS_H_ 2 | #define _CPUEMU_OPS_H_ 3 | 4 | #include "std_types.h" 5 | #include "cpu_config.h" 6 | #include "target_cpu.h" 7 | #include "cpu_config_ops.h" 8 | #ifdef OS_LINUX 9 | #include 10 | #endif /* OS_LINUX */ 11 | 12 | typedef struct { 13 | uint64 total_clocks; 14 | uint64 intr_clocks; 15 | int core_id_num; 16 | uint64 cpu_clocks[CPU_CONFIG_CORE_NUM]; 17 | #ifdef OS_LINUX 18 | struct timeval elaps_tv; 19 | #endif /* OS_LINUX */ 20 | } CpuEmuElapsType; 21 | extern void cpuemu_init(void *(*cpu_run)(void *), void *opt); 22 | extern void cpuemu_get_elaps(CpuEmuElapsType *elaps); 23 | #ifdef OS_LINUX 24 | extern void cpuemu_start_elaps(void); 25 | extern void cpuemu_end_elaps(void); 26 | #endif /* OS_LINUX */ 27 | extern uint32 cpuemu_get_retaddr(CoreIdType core_id); 28 | extern Std_ReturnType cpuemu_get_addr_pointer(uint32 addr, uint8 **data); 29 | extern void cpuemu_get_register(CoreIdType core_id, TargetCoreType *cpu); 30 | 31 | extern void *cpuemu_thread_run(void* arg); 32 | extern uint64 cpuemu_get_cpu_end_clock(void); 33 | extern void cpuemu_set_cpu_end_clock(uint64 clock); 34 | extern void cpuemu_set_entry_addr(uint32 entry_addr); 35 | 36 | 37 | extern Std_ReturnType cpuemu_set_comm_fifocfg(const char* fifocfg); 38 | extern const char* cpuemu_get_comm_rx_fifo(void); 39 | extern const char* cpuemu_get_comm_tx_fifo(void); 40 | 41 | extern Std_ReturnType cpuemu_symbol_set(void); 42 | 43 | extern void cpuemu_raise_intr(uint32 intno); 44 | 45 | 46 | /* 47 | * the following enum values must be equal MpuAddressGetType(mpu_ops.h). 48 | */ 49 | typedef enum { 50 | MemoryAddressImplType_ROM = 0, 51 | MemoryAddressImplType_RAM, 52 | MemoryAddressImplType_MMAP, 53 | MemoryAddressImplType_MALLOC, 54 | MemoryAddressImplType_DEV, 55 | } MemoryAddressImplType; 56 | 57 | typedef struct { 58 | MemoryAddressImplType type; 59 | uint32 start; /* unit:byte */ 60 | uint32 size; /* unit:KB */ 61 | void *mmap_addr; 62 | void *extdev_handle; 63 | bool region_executable; /* X */ 64 | bool region_elf_load_from_vaddr; /* V */ 65 | } MemoryAddressType; 66 | 67 | typedef struct { 68 | uint32 rom_num; 69 | MemoryAddressType *rom; 70 | uint32 ram_num; 71 | MemoryAddressType *ram; 72 | uint32 dev_num; 73 | MemoryAddressType *dev; 74 | } MemoryAddressMapType; 75 | extern Std_ReturnType cpuemu_load_memmap(const char *path, MemoryAddressMapType *map); 76 | 77 | extern Std_ReturnType cpuemu_load_devcfg(const char *path); 78 | extern Std_ReturnType cpuemu_get_devcfg_value(const char* key, uint32 *value); 79 | extern Std_ReturnType cpuemu_get_devcfg_value_hex(const char* key, uint32 *value); 80 | extern Std_ReturnType cpuemu_get_devcfg_string(const char* key, char **value); 81 | 82 | #endif /* _CPUEMU_OPS_H_ */ 83 | -------------------------------------------------------------------------------- /src/device/peripheral/mros-dev/mros-src/comm/cimpl/mros_comm_tcp_client_factory_cimpl.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2012 mbed.org, MIT License 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 4 | * and associated documentation files (the "Software"), to deal in the Software without restriction, 5 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 6 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 7 | * furnished to do so, subject to the following conditions: 8 | * 9 | * The above copyright notice and this permission notice shall be included in all copies or 10 | * substantial portions of the Software. 11 | * 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 13 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 14 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 17 | */ 18 | #include "mros_comm_tcp_client_factory_cimpl.h" 19 | #include "mros_sys_config.h" 20 | 21 | static mRosCommTcpClientEntryHeadType mros_comm_tcp_client_factory MROS_MATTR_BSS_NOCLR; 22 | static mRosCommTcpClientListReqEntryType mros_comm_tcp_client_entries[MROS_TOPIC_TCP_CLIENT_MAX_NUM] MROS_MATTR_BSS_NOCLR; 23 | 24 | mRosReturnType mros_comm_tcp_client_factory_init(void) 25 | { 26 | 27 | List_Init(&mros_comm_tcp_client_factory, mRosCommTcpClientListReqEntryType, MROS_TOPIC_TCP_CLIENT_MAX_NUM, mros_comm_tcp_client_entries); 28 | return MROS_E_OK; 29 | } 30 | 31 | mRosCommTcpClientListReqEntryType *mros_comm_tcp_client_alloc(void) 32 | { 33 | mRosCommTcpClientListReqEntryType *p; 34 | ListEntry_Alloc(&mros_comm_tcp_client_factory, mRosCommTcpClientListReqEntryType, &p); 35 | if (p == MROS_NULL) { 36 | ROS_ERROR("%s %s() %u ret=%d", __FILE__, __FUNCTION__, __LINE__, MROS_E_NOMEM); 37 | return MROS_NULL; 38 | } 39 | ListEntry_AddEntry(&mros_comm_tcp_client_factory, p); 40 | return p; 41 | } 42 | mRosCommTcpClientListReqEntryType *mros_comm_tcp_client_alloc_copy(mRosCommTcpClientType *client) 43 | { 44 | mRosCommTcpClientListReqEntryType *p; 45 | 46 | p = mros_comm_tcp_client_alloc(); 47 | if (p == MROS_NULL) { 48 | ROS_ERROR("%s %s() %u ret=%d", __FILE__, __FUNCTION__, __LINE__, MROS_E_NOMEM); 49 | return MROS_NULL; 50 | } 51 | p->data.client = *client; 52 | 53 | return p; 54 | } 55 | void mros_comm_tcp_client_free(mRosCommTcpClientListReqEntryType *client) 56 | { 57 | ListEntry_RemoveEntry(&mros_comm_tcp_client_factory, client); 58 | ListEntry_Free(&mros_comm_tcp_client_factory, client); 59 | return; 60 | } 61 | -------------------------------------------------------------------------------- /src/device/peripheral/mros-dev/mros-src/comm/cimpl/mros_comm_tcp_client_cimpl.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2012 mbed.org, MIT License 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 4 | * and associated documentation files (the "Software"), to deal in the Software without restriction, 5 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 6 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 7 | * furnished to do so, subject to the following conditions: 8 | * 9 | * The above copyright notice and this permission notice shall be included in all copies or 10 | * substantial portions of the Software. 11 | * 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 13 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 14 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 17 | */ 18 | #ifndef _MROS_COMM_TCP_CLIENT_CIMPL_H_ 19 | #define _MROS_COMM_TCP_CLIENT_CIMPL_H_ 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | #include "mros_comm_socket_cimpl.h" 26 | 27 | typedef struct { 28 | mRosCommSocketType socket; 29 | mRosSockAddrInType remote; 30 | mros_boolean connected; 31 | } mRosCommTcpClientType; 32 | 33 | 34 | extern mRosReturnType mros_comm_tcp_client_init(mRosCommTcpClientType *client, const char* host, mros_int32 port); 35 | extern mRosReturnType mros_comm_tcp_client_ip32_init(mRosCommTcpClientType *client, mros_uint32 ipaddr, mros_int32 port); 36 | 37 | extern void mros_comm_tcp_client_close(mRosCommTcpClientType *client); 38 | extern mRosReturnType mros_comm_tcp_client_connect(mRosCommTcpClientType *client); 39 | extern mRosReturnType mros_comm_tcp_client_connect_ip32(mRosCommTcpClientType *client, mros_uint32 ipaddr, mros_int32 port); 40 | extern mros_boolean mros_comm_tcp_client_is_connected(mRosCommTcpClientType *client); 41 | extern mRosReturnType mros_comm_tcp_client_send(mRosCommTcpClientType *client, const char* data, mRosSizeType length, mRosSizeType *res); 42 | extern mRosReturnType mros_comm_tcp_client_send_all(mRosCommTcpClientType *client, const char* data, mRosSizeType length, mRosSizeType *res); 43 | extern mRosReturnType mros_comm_tcp_client_receive(mRosCommTcpClientType *client, char* data, mRosSizeType length, mRosSizeType *res); 44 | extern mRosReturnType mros_comm_tcp_client_receive_all(mRosCommTcpClientType *client, char* data, mRosSizeType length, mRosSizeType *res); 45 | 46 | 47 | #ifdef __cplusplus 48 | } 49 | #endif 50 | 51 | #endif /* _MROS_COMM_TCP_CLIENT_CIMPL_H_ */ 52 | -------------------------------------------------------------------------------- /src/device/peripheral/mros-dev/mros-src/comm/cimpl/mros_comm_tcp_client_factory_cimpl.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2012 mbed.org, MIT License 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 4 | * and associated documentation files (the "Software"), to deal in the Software without restriction, 5 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 6 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 7 | * furnished to do so, subject to the following conditions: 8 | * 9 | * The above copyright notice and this permission notice shall be included in all copies or 10 | * substantial portions of the Software. 11 | * 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 13 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 14 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 17 | */ 18 | #ifndef _MROS_COMM_TCP_CLIENT_FACTORY_CIMPL_H_ 19 | #define _MROS_COMM_TCP_CLIENT_FACTORY_CIMPL_H_ 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | #include "mros_comm_tcp_client_cimpl.h" 26 | #include "mros_memory.h" 27 | #include "mros_wait_queue.h" 28 | 29 | typedef struct { 30 | mRosTopicIdType topic_id; 31 | mros_uint32 ipaddr; 32 | mros_int32 port; 33 | void* api_reqp; 34 | mRosWaitListEntryType waitobj; 35 | } mRosRquestObjectType; 36 | 37 | typedef struct { 38 | mRosReturnType (*topic_data_send) (mRosCommTcpClientType *client, const char *data, mRosSizeType datalen); 39 | mRosReturnType (*topic_data_receive) (mRosCommTcpClientType *client, mRosMemoryManagerType *mempool, mRosMemoryListEntryType **retp); 40 | void (*free) (void* reqp); 41 | } mRosCommOperationType; 42 | 43 | typedef struct { 44 | mRosCommTcpClientType client; 45 | mRosCommOperationType op; 46 | mRosRquestObjectType reqobj; 47 | } mRosCommTcpClientReqEntryType; 48 | typedef ListEntryType(mRosCommTcpClientListReqEntryType, mRosCommTcpClientReqEntryType) mRosCommTcpClientListReqEntryType; 49 | typedef ListHeadType(mRosCommTcpClientListReqEntryType) mRosCommTcpClientEntryHeadType; 50 | 51 | extern mRosReturnType mros_comm_tcp_client_factory_init(void); 52 | extern mRosCommTcpClientListReqEntryType *mros_comm_tcp_client_alloc(void); 53 | extern mRosCommTcpClientListReqEntryType *mros_comm_tcp_client_alloc_copy(mRosCommTcpClientType *client); 54 | extern void mros_comm_tcp_client_free(mRosCommTcpClientListReqEntryType *client); 55 | 56 | 57 | #ifdef __cplusplus 58 | } 59 | #endif 60 | 61 | #endif /* _MROS_COMM_TCP_CLIENT_FACTORY_CIMPL_H_ */ 62 | -------------------------------------------------------------------------------- /bin/linux/variable_conflict_check.groovy: -------------------------------------------------------------------------------- 1 | @Grab('com.xlson.groovycsv:groovycsv:0.2') 2 | 3 | import com.xlson.groovycsv.CsvParser 4 | 5 | if (args.length != 2) { 6 | println "Usage: variable_conflict_check.groovy " 7 | return 1; 8 | } 9 | 10 | csv_file = args[0]; 11 | int interval = Integer.parseInt(args[1]); 12 | 13 | class DataAccessInfo { 14 | public String variable; 15 | public String clock; 16 | public String type; 17 | public String core; 18 | public String stack; 19 | public String func; 20 | 21 | public DataAccessInfo(String var, String clock, String type, String core, String stack, String func) { 22 | this.variable = var.trim(); 23 | this.clock = clock.trim(); 24 | this.type = type.trim(); 25 | this.core = core.trim(); 26 | this.stack = stack.trim(); 27 | this.func = func.trim(); 28 | } 29 | 30 | } 31 | 32 | Map> map = new HashMap<>(); 33 | 34 | def csv = new File(csv_file).text 35 | def data = new CsvParser().parse(csv, separator: ',', quoteChar: '"') 36 | data.each { 37 | def info = new DataAccessInfo(it.variable, 38 | it.access_clock, 39 | it.type, 40 | it.core, 41 | it.stack, 42 | it.access_func); 43 | def var = map.get(it.variable); 44 | if (var == null) { 45 | var = new ArrayList<>(); 46 | map.put(it.variable, var); 47 | } 48 | var.add(info); 49 | } 50 | 51 | for (String key : map.keySet()) { 52 | def var = map.get(key); 53 | def readList = var.stream() 54 | .filter { 55 | it.type.equals("READ") 56 | }.collect(); 57 | def writeList = var.stream() 58 | .filter { 59 | it.type.equals("WRITE") 60 | }.collect(); 61 | 62 | for (def writeInfo : writeList) { 63 | if (readList.isEmpty()) { 64 | continue; 65 | } 66 | if (readList.stream() 67 | .every{ writeInfo.stack.equals(it.stack) }) { 68 | continue; 69 | } 70 | 71 | DataAccessInfo readInfo = null; 72 | int wclock = Integer.parseInt(writeInfo.clock); 73 | int min = Integer.MAX_VALUE; 74 | readList.stream() 75 | .filter{ !writeInfo.stack.equals(it.stack) } 76 | .each { 77 | int tmp_clock = Integer.parseInt(it.clock); 78 | if (min > Math.abs(tmp_clock - wclock)) { 79 | min = Math.abs(tmp_clock - wclock); 80 | readInfo = it; 81 | } 82 | } 83 | 84 | if ((interval > 0) && Math.abs(Integer.parseInt(writeInfo.clock) - Integer.parseInt(readInfo.clock)) > interval) { 85 | continue; 86 | } 87 | 88 | println String.format("%d W:%s %s (%s) : %s(%s)", 89 | Integer.parseInt(writeInfo.clock) - Integer.parseInt(readInfo.clock), 90 | key, 91 | writeInfo.clock, 92 | writeInfo.core, 93 | writeInfo.stack, 94 | writeInfo.func); 95 | println String.format(" + R:%s (%s) : %s(%s)>", 96 | readInfo.clock, 97 | readInfo.core, 98 | readInfo.stack, 99 | readInfo.func); 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /src/bus/bus.h: -------------------------------------------------------------------------------- 1 | #ifndef _BUS_H_ 2 | #define _BUS_H_ 3 | 4 | #include "std_types.h" 5 | #include "std_errno.h" 6 | #include "mpu_ops.h" 7 | #include 8 | 9 | typedef enum { 10 | BUS_ACCESS_TYPE_NONE = 0, 11 | BUS_ACCESS_TYPE_READ, 12 | BUS_ACCESS_TYPE_WRITE, 13 | } BusAccessType; 14 | #define BUS_ACCESS_LOG_SIZE 128 15 | 16 | extern void bus_access_set_log(BusAccessType type, uint32 size, uint32 access_addr, uint32 data); 17 | extern Std_ReturnType bus_access_get_log(BusAccessType *type, uint32 *size, uint32 *access_addr, uint32 *data); 18 | 19 | 20 | #ifdef DISABLE_BUS_ACCESS_LOG 21 | #define bus_access_set_log bus_access_set_log_not_use 22 | static inline void bus_access_set_log_not_use(BusAccessType type, uint32 size, uint32 access_addr, uint32 data) 23 | {} 24 | #endif 25 | 26 | /* 27 | * データ取得するための操作関数群 28 | */ 29 | static inline Std_ReturnType bus_get_data8(CoreIdType core_id, uint32 addr, uint8 *data) 30 | { 31 | Std_ReturnType err; 32 | 33 | err = mpu_get_data8(core_id, addr, data); 34 | if (err != STD_E_OK) { 35 | printf("ERROR:can not load data:addr=0x%x size=1byte\n", addr); 36 | } 37 | bus_access_set_log(BUS_ACCESS_TYPE_READ, 1U, addr, *data); 38 | return err; 39 | } 40 | static inline Std_ReturnType bus_get_data16(CoreIdType core_id, uint32 addr, uint16 *data) 41 | { 42 | Std_ReturnType err; 43 | 44 | err = mpu_get_data16(core_id, addr, data); 45 | if (err != STD_E_OK) { 46 | printf("ERROR:can not load data:addr=0x%x size=2byte\n", addr); 47 | } 48 | bus_access_set_log(BUS_ACCESS_TYPE_READ, 2U, addr, *data); 49 | return err; 50 | } 51 | static inline Std_ReturnType bus_get_data32(CoreIdType core_id, uint32 addr, uint32 *data) 52 | { 53 | Std_ReturnType err; 54 | 55 | err = mpu_get_data32(core_id, addr, data); 56 | if (err != STD_E_OK) { 57 | printf("ERROR:can not load data:addr=0x%x size=4byte\n", addr); 58 | } 59 | bus_access_set_log(BUS_ACCESS_TYPE_READ, 4U, addr, *data); 60 | return err; 61 | } 62 | 63 | /* 64 | * データ転送するための操作関数群 65 | */ 66 | static inline Std_ReturnType bus_put_data8(CoreIdType core_id, uint32 addr, uint8 data) 67 | { 68 | bus_access_set_log(BUS_ACCESS_TYPE_WRITE, 1U, addr, data); 69 | return mpu_put_data8(core_id, addr, data); 70 | } 71 | static inline Std_ReturnType bus_put_data16(CoreIdType core_id, uint32 addr, uint16 data) 72 | { 73 | bus_access_set_log(BUS_ACCESS_TYPE_WRITE, 2U, addr, data); 74 | return mpu_put_data16(core_id, addr, data); 75 | } 76 | static inline Std_ReturnType bus_put_data32(CoreIdType core_id, uint32 addr, uint32 data) 77 | { 78 | bus_access_set_log(BUS_ACCESS_TYPE_WRITE, 4U, addr, data); 79 | return mpu_put_data32(core_id, addr, data); 80 | } 81 | 82 | /* 83 | * 注意:本APIは基本的には使用しないこと. 84 | * 85 | * 性能向上を目的として使用する場合は, 86 | * ROM/RAM領域のメモリに限り,当該領域のポインタ変数を本関数を使用して取得する. 87 | */ 88 | static inline Std_ReturnType bus_get_pointer(CoreIdType core_id, uint32 addr, uint8 **data) 89 | { 90 | return mpu_get_pointer(core_id, addr, data); 91 | } 92 | 93 | #endif /* _BUS_H_ */ 94 | -------------------------------------------------------------------------------- /src/lib/cui/udp/cui_ops_udp.c: -------------------------------------------------------------------------------- 1 | #include "cui/cui_ops.h" 2 | #include "cui/udp/cui_ops_udp.h" 3 | #include "udp/udp_comm.h" 4 | #include "cpuemu_config.h" 5 | #include 6 | 7 | typedef struct { 8 | UdpCommConfigType config; 9 | UdpCommType comm; 10 | FileOpType op; 11 | } UdpFileOpType; 12 | 13 | static void cui_close_udp(void); 14 | static int cui_getline_udp(char *line, int size); 15 | static void cui_write_udp(char *line, int size); 16 | 17 | static UdpFileOpType cui_fileop_udp; 18 | 19 | void cui_ops_udp_init(uint16 server_port, uint16 client_port) 20 | { 21 | Std_ReturnType err; 22 | 23 | UdpFileOpType cui_fileop_udp_tmp = { 24 | .config = { 25 | .server_port = server_port, 26 | .client_port = client_port, 27 | .is_wait = TRUE, 28 | }, 29 | .op = { 30 | .cui_getline = cui_getline_udp, 31 | .cui_write = cui_write_udp, 32 | .cui_close = cui_close_udp, 33 | }, 34 | 35 | }; 36 | 37 | cui_fileop_udp = cui_fileop_udp_tmp; 38 | 39 | printf("REMOTE:athrill listen port %u\n", cui_fileop_udp.config.server_port); 40 | printf("REMOTE:client listen port %u\n", cui_fileop_udp.config.client_port); 41 | 42 | err = udp_comm_create(&cui_fileop_udp.config, &cui_fileop_udp.comm); 43 | if (err != STD_E_OK) { 44 | printf("ERROR:internal error:udp_server_create()\n"); 45 | exit(1); 46 | } 47 | 48 | (void)cui_fileop_register(&cui_fileop_udp.op); 49 | return; 50 | } 51 | 52 | static void cui_close_udp(void) 53 | { 54 | Std_ReturnType err; 55 | 56 | udp_server_delete(&cui_fileop_udp.comm); 57 | 58 | err = udp_comm_create(&cui_fileop_udp.config, &cui_fileop_udp.comm); 59 | if (err != STD_E_OK) { 60 | printf("ERROR:internal error:udp_server_create()\n"); 61 | exit(1); 62 | } 63 | return; 64 | } 65 | 66 | static int cui_getline_udp(char *line, int size) 67 | { 68 | Std_ReturnType err; 69 | 70 | //printf("cui_getline_udp:enter\n"); 71 | err = udp_comm_read(&cui_fileop_udp.comm); 72 | if (err != STD_E_OK) { 73 | printf("ERROR:internal error:udp_server_read()\n"); 74 | return -1; 75 | } 76 | if (cui_fileop_udp.comm.read_data.len > size) { 77 | printf("ERROR:internal error:cui_getline_udp():recv size is too large\n"); 78 | return -1; 79 | } 80 | memcpy(line, cui_fileop_udp.comm.read_data.buffer, cui_fileop_udp.comm.read_data.len); 81 | line[cui_fileop_udp.comm.read_data.len] = '\0'; 82 | //printf("cui_getline_udp:exit:%s\n", line); 83 | return cui_fileop_udp.comm.read_data.len; 84 | } 85 | 86 | static void cui_write_udp(char *line, int size) 87 | { 88 | Std_ReturnType err; 89 | 90 | if (size > UDP_BUFFER_LEN) { 91 | return; 92 | } 93 | cui_fileop_udp.comm.write_data.len = size; 94 | memcpy(cui_fileop_udp.comm.write_data.buffer, line, size); 95 | 96 | err = udp_comm_write(&cui_fileop_udp.comm); 97 | if (err != STD_E_OK) { 98 | printf("ERROR:internal error:udp_server_write()\n"); 99 | return; 100 | } 101 | return; 102 | } 103 | -------------------------------------------------------------------------------- /src/device/peripheral/mros-dev/mros-src/protocol/cimpl/mros_protocol_publish_cimpl.c: -------------------------------------------------------------------------------- 1 | #include "mros_protocol_publish_cimpl.h" 2 | #include "mros_protocol_server_proc_cimpl.h" 3 | #include "mros_comm_tcp_client_cimpl.h" 4 | #include "mros_comm_tcp_server_cimpl.h" 5 | #include "mros_exclusive_area.h" 6 | #include "mros_sys_config.h" 7 | 8 | typedef union { 9 | char buffer; 10 | char buffer1[MROS_PACKET_MAXSIZE_REQ_TCPROS]; 11 | char buffer2[MROS_PACKET_MAXSIZE_RES_TCPROS]; 12 | } mRosPublishPacketBufferType; 13 | static mRosPublishPacketBufferType mros_publish_packet_buffer MROS_MATTR_BSS_NOCLR; 14 | 15 | typedef struct { 16 | mRosProtocolPublishStateEnumType state; 17 | mRosPacketType packet; 18 | mRosCommTcpServerType server_comm; 19 | mRosCommTcpClientType client_comm; 20 | } mRosProtocolPublishType; 21 | 22 | static mRosProtocolPublishType mros_protocol_publish MROS_MATTR_BSS_NOCLR; 23 | 24 | mRosReturnType mros_protocol_publish_init(void) 25 | { 26 | mRosReturnType ret = mros_comm_tcp_server_init(&mros_protocol_publish.server_comm); 27 | if (ret != MROS_E_OK) { 28 | ROS_ERROR("%s %s() %u ret=%d", __FILE__, __FUNCTION__, __LINE__, ret); 29 | return ret; 30 | } 31 | mros_protocol_publish.packet.total_size = sizeof(mRosPublishPacketBufferType); 32 | mros_protocol_publish.packet.data = &mros_publish_packet_buffer.buffer; 33 | mros_protocol_publish.state = MROS_PROTOCOL_PUBLISH_STATE_WAITING; 34 | ret = mros_comm_tcp_server_bind(&mros_protocol_publish.server_comm, mros_publisher_port_no); 35 | if (ret != MROS_E_OK) { 36 | ROS_ERROR("%s %s() %u ret=%d", __FILE__, __FUNCTION__, __LINE__, ret); 37 | return ret; 38 | } 39 | ret = mros_comm_tcp_server_listen(&mros_protocol_publish.server_comm, MROS_COMM_TCP_SERVER_LISTEN_MAX_DEFAULT_VALUE); 40 | if (ret != MROS_E_OK) { 41 | ROS_ERROR("%s %s() %u ret=%d", __FILE__, __FUNCTION__, __LINE__, ret); 42 | return ret; 43 | } 44 | return MROS_E_OK; 45 | } 46 | 47 | void mros_protocol_publish_run(void) 48 | { 49 | mRosReturnType ret; 50 | mROsExclusiveUnlockObjType unlck_obj; 51 | 52 | while (MROS_TRUE) { 53 | mros_protocol_publish.state = MROS_PROTOCOL_PUBLISH_STATE_WAITING; 54 | ret = mros_comm_tcp_server_accept(&mros_protocol_publish.server_comm, &mros_protocol_publish.client_comm); 55 | if (ret != MROS_E_OK) { 56 | continue; 57 | } 58 | mros_protocol_publish.state = MROS_PROTOCOL_PUBLISH_STATE_STARTING_PUBLISH_TOPIC; 59 | ret = mros_proc_tcpros_receive(&mros_protocol_publish.client_comm, &mros_protocol_publish.packet); 60 | if (ret != MROS_E_OK) { 61 | ROS_ERROR("%s %s() %u ret=%d", __FILE__, __FUNCTION__, __LINE__, ret); 62 | mros_comm_tcp_client_close(&mros_protocol_publish.client_comm); 63 | continue; 64 | } 65 | mros_exclusive_lock(&mros_exclusive_area, &unlck_obj); 66 | ret = mros_proc_pub_tcpros(&mros_protocol_publish.client_comm, &mros_protocol_publish.packet); 67 | mros_exclusive_unlock(&unlck_obj); 68 | if (ret != MROS_E_OK) { 69 | ROS_ERROR("%s %s() %u ret=%d", __FILE__, __FUNCTION__, __LINE__, ret); 70 | } 71 | } 72 | return; 73 | } 74 | -------------------------------------------------------------------------------- /src/lib/dwarf/data_type/elf_dwarf_variable_type.c: -------------------------------------------------------------------------------- 1 | #include "elf_dwarf_variable_type.h" 2 | #include "assert.h" 3 | 4 | void elf_dwarf_build_variable_type(ElfDwarfDieType *die) 5 | { 6 | int i; 7 | uint32 size; 8 | DwarfDataVariableType *obj = dwarf_alloc_data_type(DATA_TYPE_VARIABLE); 9 | ElfDwarfAttributeType *attr; 10 | ElfDwarfAbbrevType *abbrev; 11 | DwAtType attr_type; 12 | uint32 offset; 13 | Std_ReturnType err; 14 | 15 | //printf("elf_dwarf_build_variable_type:off=0x%x\n", die->offset); 16 | //printf("variable_type\n"); 17 | for (i = 0; i < die->attribute->current_array_size; i++) { 18 | abbrev = (ElfDwarfAbbrevType *)die->abbrev_info; 19 | attr = (ElfDwarfAttributeType*)die->attribute->data[i]; 20 | attr_type = abbrev->attribute_name->data[i]; 21 | //printf("name=0x%x form=%s\n", attr_type, attr->typename); 22 | switch (attr_type) { 23 | case DW_AT_name: 24 | obj->info.typename = attr->encoded.string; 25 | //printf("typename=%s\n", obj->info.typename); 26 | break; 27 | case DW_AT_type: 28 | offset = elf_dwarf_info_get_value(abbrev->attribute_form->data[i], attr, &size); 29 | err = dwarf_get_real_type_offset(offset, &obj->ref_debug_info_offset); 30 | if (err == STD_E_OK) { 31 | obj->is_valid_ref_debug_info_offset = TRUE; 32 | } 33 | break; 34 | case DW_AT_decl_file: 35 | case DW_AT_decl_line: 36 | case DW_AT_decl_column: 37 | case DW_AT_location: 38 | case DW_AT_external: 39 | case DW_AT_abstract_origin: 40 | case DW_AT_declaration: 41 | case DW_AT_const_value: 42 | case DW_AT_artificial: 43 | case DW_AT_specification: 44 | case DW_AT_linkage_name: 45 | case DW_AT_MIPS_linkage_name: 46 | case DW_AT_alignment: 47 | case DW_AT_unknown_0x2137: 48 | break; 49 | default: 50 | printf("die=0x%x attr_type=0x%x\n", die->offset, attr_type); 51 | ASSERT(0); 52 | } 53 | } 54 | obj->info.die = die; 55 | //printf("variable=%s ref_offset=0x%x\n", obj->info.typename, obj->ref_debug_info_offset); 56 | 57 | dwarf_register_data_type(&obj->info); 58 | 59 | return; 60 | } 61 | void elf_dwarf_resolve_variable_type(void) 62 | { 63 | int i; 64 | ElfPointerArrayType *my_types = dwarf_get_data_types(DATA_TYPE_VARIABLE); 65 | DwarfDataVariableType *obj; 66 | if (my_types == NULL) { 67 | return; 68 | } 69 | for (i = 0; i < my_types->current_array_size; i++) { 70 | obj = (DwarfDataVariableType *)my_types->data[i]; 71 | if (obj->ref != NULL) { 72 | continue; 73 | } 74 | if (obj->is_valid_ref_debug_info_offset == FALSE) { 75 | continue; 76 | } 77 | obj->ref = elf_dwarf_get_data_type(obj->ref_debug_info_offset); 78 | //printf("variable =%s type=0x%x ref_off=0x%x\n", obj->info.typename, obj->ref_debug_info_offset, obj->ref->die->offset); 79 | if (obj->ref == NULL) { 80 | //printf("Not supported:unknown typeref(%s) debug_offset=0x%x\n", obj->info.typename, obj->ref_debug_info_offset); 81 | } 82 | else { 83 | //if (strcmp("test_class_data", obj->info.typename) == 0) 84 | // printf("variable(0x%p) %s %s\n", obj, obj->ref->typename, obj->info.typename); 85 | } 86 | } 87 | 88 | return; 89 | } 90 | -------------------------------------------------------------------------------- /src/device/peripheral/mros-dev/mros-src/packet/template/version/kinetic/mros_packet_fmt_xml.h: -------------------------------------------------------------------------------- 1 | #ifndef _MROS_PACKET_FMT_XML_H_ 2 | #define _MROS_PACKET_FMT_XML_H_ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #define MROS_PACKET_XMLRPC_REQ_END_STR "" 9 | #define MROS_PACKET_XMLRPC_RES_END_STR "" 10 | 11 | /* 12 | * ARGS1: method name 13 | * ARGS2: node name 14 | * ARGS3: topic 15 | * ARGS4: type 16 | * ARGS5: uri 17 | */ 18 | #define MROS_PACKET_FMT_XML_REGISTER_REQ \ 19 | "\n" \ 20 | "\n" \ 21 | "%s\n" \ 22 | "\n" \ 23 | "\n" \ 24 | "%s\n" \ 25 | "\n" \ 26 | "\n" \ 27 | "%s\n" \ 28 | "\n" \ 29 | "\n" \ 30 | "%s\n" \ 31 | "\n" \ 32 | "\n" \ 33 | "%s\n" \ 34 | "\n" \ 35 | "" \ 36 | "\n" 37 | 38 | /* 39 | * ARGS1: method name 40 | * ARGS2: node name 41 | * ARGS3: topic 42 | * ARGS4: tcpros 43 | */ 44 | #define MROS_PACKET_FMT_XML_REQUEST_TOPIC_REQ \ 45 | "\n" \ 46 | "\n" \ 47 | "%s\n" \ 48 | "\n" \ 49 | "\n" \ 50 | "%s\n" \ 51 | "\n" \ 52 | "\n" \ 53 | "%s\n" \ 54 | "\n" \ 55 | "\n" \ 56 | "" \ 57 | "\n" \ 58 | "" \ 59 | "" \ 60 | "\n" \ 61 | "" \ 62 | "%s" \ 63 | "\n" \ 64 | "" \ 65 | "" \ 66 | "\n" \ 67 | "" \ 68 | "\n" \ 69 | "\n" \ 70 | "" \ 71 | "\n" \ 72 | 73 | /* 74 | * ARGS1: TCPROS 75 | * ARGS2: ipaddr 76 | * ARGS3: port 77 | */ 78 | #define MROS_PACKET_FMT_XML_REQUEST_TOPIC_RES \ 79 | "\n" \ 80 | "\n" \ 81 | "\n" \ 82 | "\n" \ 83 | "" \ 84 | "" \ 85 | "" \ 86 | "" \ 87 | "1" \ 88 | "\n" \ 89 | "\n" \ 90 | "" \ 91 | "\n" \ 92 | "" \ 93 | "%s\n" \ 94 | "%s\n" \ 95 | "%u\n" \ 96 | "" \ 97 | "" \ 98 | "\n" \ 99 | "" \ 100 | "" \ 101 | "" \ 102 | "\n" \ 103 | "\n" \ 104 | "\n" \ 105 | 106 | 107 | #ifdef __cplusplus 108 | } 109 | #endif 110 | 111 | #endif /* _MROS_PACKET_FMT_XML_H_ */ 112 | -------------------------------------------------------------------------------- /src/lib/tcp/tcp_connection.c: -------------------------------------------------------------------------------- 1 | #include "tcp_connection.h" 2 | #include 3 | #ifdef OS_LINUX 4 | #include 5 | #else 6 | #include 7 | #endif 8 | #include 9 | #include 10 | 11 | Std_ReturnType tcp_connection_send(TcpConnectionType *connection, const char *data, uint32 size, uint32 *res) 12 | { 13 | ssize_t snd_size; 14 | 15 | *res = 0; 16 | snd_size = send(connection->socket.fd, data, size, 0); 17 | if (snd_size < 0) { 18 | printf("ERROR: tcp_connection_send() errno=%d\n", errno); 19 | connection->connected = FALSE; 20 | return STD_E_NOENT; 21 | } 22 | else if (snd_size == 0) { 23 | connection->connected = FALSE; 24 | return STD_E_NOENT; 25 | } 26 | *res = snd_size; 27 | return STD_E_OK; 28 | } 29 | Std_ReturnType tcp_connection_send_nblk(TcpConnectionType *connection, const char *data, uint32 size, uint32 *res) 30 | { 31 | ssize_t snd_size; 32 | 33 | *res = 0; 34 | #ifdef OS_LINUX 35 | snd_size = send(connection->socket.fd, data, size, MSG_DONTWAIT); 36 | #else 37 | snd_size = send(connection->socket.fd, data, size, 0); 38 | #endif 39 | if (snd_size < 0) { 40 | if (errno != EAGAIN) { 41 | printf("ERROR: tcp_connection_send() errno=%d\n", errno); 42 | connection->connected = FALSE; 43 | } 44 | return STD_E_NOENT; 45 | } 46 | else if (snd_size == 0) { 47 | connection->connected = FALSE; 48 | return STD_E_NOENT; 49 | } 50 | *res = snd_size; 51 | return STD_E_OK; 52 | } 53 | 54 | Std_ReturnType tcp_connection_receive_nblk(TcpConnectionType *connection, char *data, uint32 size, uint32 *res) 55 | { 56 | ssize_t rcv_size; 57 | *res = 0; 58 | #ifdef OS_LINUX 59 | rcv_size = recv(connection->socket.fd, data, size, MSG_DONTWAIT); 60 | #else 61 | rcv_size = recv(connection->socket.fd, data, size, 0); 62 | #endif 63 | if (rcv_size < 0) { 64 | if (errno != EAGAIN) { 65 | printf("ERROR: tcp_connection_receive() errno=%d\n", errno); 66 | connection->connected = FALSE; 67 | } 68 | return STD_E_NOENT; 69 | } 70 | else if (rcv_size == 0) { 71 | connection->connected = FALSE; 72 | return STD_E_NOENT; 73 | } 74 | *res = rcv_size; 75 | return STD_E_OK; 76 | } 77 | 78 | Std_ReturnType tcp_connection_receive(TcpConnectionType *connection, char *data, uint32 size, uint32 *res) 79 | { 80 | ssize_t rcv_size; 81 | *res = 0; 82 | rcv_size = recv(connection->socket.fd, data, size, 0); 83 | if (rcv_size < 0) { 84 | printf("ERROR: tcp_connection_receive() errno=%d\n", errno); 85 | connection->connected = FALSE; 86 | return STD_E_NOENT; 87 | } 88 | else if (rcv_size == 0) { 89 | connection->connected = FALSE; 90 | return STD_E_NOENT; 91 | } 92 | *res = rcv_size; 93 | #if 0 94 | { 95 | uint32 i; 96 | for (i = 0; i < rcv_size; i++) { 97 | printf("buf[%u]=%c\n", i, data[i]); 98 | } 99 | } 100 | #endif 101 | return STD_E_OK; 102 | } 103 | 104 | void tcp_connection_close(TcpConnectionType *connection) 105 | { 106 | if (connection != NULL) { 107 | tcp_socket_close(&connection->socket); 108 | } 109 | return; 110 | } 111 | -------------------------------------------------------------------------------- /src/device/peripheral/mros-dev/mros-src/inc/mros_memory.h: -------------------------------------------------------------------------------- 1 | #ifndef _MROS_MEMORY_H_ 2 | #define _MROS_MEMORY_H_ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include "mros_types.h" 9 | #include "mros_list.h" 10 | 11 | typedef mros_uint32 mRosMemorySizeIdType; 12 | 13 | struct mRosMemoryManagerType; 14 | typedef struct { 15 | /* 16 | * manager 17 | */ 18 | struct mRosMemoryManagerType *mgrp; 19 | /* 20 | * id of memory_entries 21 | */ 22 | mRosIdType memory_id; 23 | /* 24 | * id of parent header 25 | */ 26 | mRosMemorySizeIdType header_id; 27 | /* 28 | * preallocation unit size 29 | */ 30 | mRosSizeType memsize; 31 | /* 32 | * real using size 33 | */ 34 | mRosSizeType size; 35 | char *memp; 36 | } mRosMemoryEntryType; 37 | 38 | typedef ListEntryType(mRosMemoryListEntryType, mRosMemoryEntryType) mRosMemoryListEntryType; 39 | typedef ListHeadType(mRosMemoryListEntryType) mRosMemoryListHeadType; 40 | 41 | typedef struct { 42 | /* 43 | * memory list header 44 | */ 45 | mRosMemoryListHeadType head; 46 | /* 47 | * num of preallocation memory 48 | */ 49 | mRosSizeType max_memory_num; 50 | /* 51 | * preallocation unit size 52 | */ 53 | mRosSizeType memsize; 54 | /* 55 | * memory list entry 56 | */ 57 | mRosMemoryListEntryType *memory_entries; 58 | /* 59 | * raw data 60 | */ 61 | char *memory; 62 | } mRosMemoryHeaderType; 63 | 64 | typedef struct mRosMemoryManagerType { 65 | /* 66 | * num of header 67 | */ 68 | mRosSizeType header_num; 69 | /* 70 | * header array 71 | */ 72 | mRosMemoryHeaderType *header_array; 73 | } mRosMemoryManagerType; 74 | 75 | /* 76 | * config memory 77 | */ 78 | typedef struct { 79 | mRosSizeType max_memory_num; 80 | mRosSizeType memsize; 81 | mRosMemoryListEntryType *memory_entries; 82 | char *memory; 83 | } mRosMemoryConfigType; 84 | 85 | extern mRosReturnType mros_mem_init(mRosSizeType config_num, mRosMemoryConfigType **config, mRosMemoryManagerType *mgrp); 86 | extern mRosReturnType mros_mem_alloc(mRosMemoryManagerType *mgrp, mRosSizeType size, mRosMemoryListEntryType **memory); 87 | extern mRosReturnType mros_mem_free(mRosMemoryManagerType *mgrp, mRosMemoryListEntryType *memory); 88 | 89 | /* 90 | * Memory Config APIs 91 | */ 92 | #define MROS_MEMORY_CONFIG_DECLARE_ENTRY(entry_name, max_memory_num, memsize) \ 93 | static mRosMemoryListEntryType entry_name##_entries [(max_memory_num)] MROS_MATTR_BSS_NOCLR; \ 94 | static char entry_name##_memory [(max_memory_num) * (memsize)] MROS_MATTR_BSS_NOCLR; \ 95 | static mRosMemoryConfigType entry_name##_config = { \ 96 | (max_memory_num), \ 97 | (memsize), \ 98 | entry_name##_entries , \ 99 | entry_name##_memory , \ 100 | }; 101 | 102 | #define MROS_MEMORY_CONFIG_DECLARE_MANAGER(mem_manager_name, config_num) \ 103 | static mRosMemoryHeaderType mem_manager_name##_head_array [(config_num)] MROS_MATTR_BSS_NOCLR; \ 104 | mRosMemoryManagerType mem_manager_name = { \ 105 | (config_num), \ 106 | mem_manager_name##_head_array, \ 107 | }; 108 | 109 | 110 | #ifdef __cplusplus 111 | } 112 | #endif 113 | 114 | #endif /* _MROS_MEMORY_H_ */ 115 | -------------------------------------------------------------------------------- /src/lib/dbg_log.h: -------------------------------------------------------------------------------- 1 | #ifndef _DBG_LOG_H_ 2 | #define _DBG_LOG_H_ 3 | 4 | #define DEBUG_EMU 5 | #ifdef DEBUG_EMU 6 | #include "symbol_ops.h" 7 | #include "cpu.h" 8 | #include 9 | #include "std_types.h" 10 | 11 | #define DBG_BUFP_LEN (2048U) 12 | #define DBG_BUFP_MAX_CNT (8192U) 13 | 14 | typedef struct { 15 | int fd; 16 | uint32 pc; 17 | char *funcname; 18 | uint32 funcid; 19 | uint32 funcaddr; 20 | uint32 funcoff; 21 | bool is_view_mode; 22 | bool can_print; 23 | char *filepath; 24 | int count; 25 | struct { 26 | uint32 write_len; 27 | char p[DBG_BUFP_LEN]; 28 | } buf[DBG_BUFP_MAX_CNT]; 29 | } DbgExecOpBufferType; 30 | 31 | extern DbgExecOpBufferType DbgExecOpBuffer; 32 | extern uint32 dbg_tmp_logbuflen; 33 | extern char dbg_tmp_logbuf[DBG_BUFP_LEN]; 34 | #define DBG_EXEC_OP_BUF() (dbg_tmp_logbuf) 35 | #define DBG_EXEC_OP_BUF_LEN() (DBG_BUFP_LEN) 36 | extern void dbg_log_init(char *filepath); 37 | extern void dbg_log_sync(void); 38 | 39 | static inline void dbg_log_set_view_mode(bool on) 40 | { 41 | DbgExecOpBuffer.is_view_mode = on; 42 | } 43 | 44 | static inline bool dbg_log_is_view_mode(void) 45 | { 46 | return DbgExecOpBuffer.is_view_mode; 47 | } 48 | static inline void dbg_log_set_print_mode(bool on) 49 | { 50 | DbgExecOpBuffer.can_print = on; 51 | } 52 | 53 | static inline bool dbg_log_can_print(void) 54 | { 55 | return DbgExecOpBuffer.can_print; 56 | } 57 | static inline void dbg_print_log(void) 58 | { 59 | int err; 60 | err = symbol_pc2funcid(cpu_get_current_core_pc(), &DbgExecOpBuffer.funcaddr); 61 | if (err >= 0) { 62 | DbgExecOpBuffer.funcid = err; 63 | DbgExecOpBuffer.funcname = symbol_funcid2funcname(DbgExecOpBuffer.funcid); 64 | DbgExecOpBuffer.funcoff = cpu_get_current_core_pc() - DbgExecOpBuffer.funcaddr; 65 | DbgExecOpBuffer.buf[DbgExecOpBuffer.count].write_len = snprintf( 66 | DbgExecOpBuffer.buf[DbgExecOpBuffer.count].p, 67 | DBG_BUFP_LEN, 68 | "[DONE> core%u pc=0x%x %s(+%x) %s", 69 | cpu_get_current_core_id(), 70 | cpu_get_current_core_pc(), 71 | DbgExecOpBuffer.funcname, 72 | DbgExecOpBuffer.funcoff, 73 | dbg_tmp_logbuf); 74 | } 75 | else { 76 | DbgExecOpBuffer.buf[DbgExecOpBuffer.count].write_len = snprintf( 77 | DbgExecOpBuffer.buf[DbgExecOpBuffer.count].p, 78 | DBG_BUFP_LEN, 79 | "[DONE> core%u pc=0x%x null(null) %s", 80 | cpu_get_current_core_id(), 81 | cpu_get_current_core_pc(), 82 | dbg_tmp_logbuf); 83 | } 84 | if (dbg_log_can_print() == TRUE) { 85 | printf("%s", DbgExecOpBuffer.buf[DbgExecOpBuffer.count].p); 86 | } 87 | DbgExecOpBuffer.count++; 88 | if (DbgExecOpBuffer.count >= DBG_BUFP_MAX_CNT) { 89 | dbg_log_sync(); 90 | } 91 | return; 92 | } 93 | 94 | 95 | #define DBG_PRINT(arg) \ 96 | do { \ 97 | if (dbg_log_is_view_mode() == TRUE) { \ 98 | dbg_tmp_logbuflen = snprintf arg; \ 99 | dbg_print_log(); \ 100 | } \ 101 | } while (0) 102 | #define DBG_LOG_SET_VIEW(on) dbg_log_set_view_mode(on) 103 | #define DBG_LOG_IS_VIEW_MODE() dbg_log_is_view_mode() 104 | #else 105 | #define DBG_PRINT(arg) 106 | #define DBG_LOG_SET_VIEW(on) 107 | #define DBG_LOG_IS_VIEW_MODE() 108 | #endif 109 | 110 | 111 | #endif /* _DBG_LOG_H_ */ 112 | -------------------------------------------------------------------------------- /src/lib/hash.c: -------------------------------------------------------------------------------- 1 | #include "hash.h" 2 | #include 3 | #include 4 | 5 | struct HashEntry; 6 | typedef struct HashEntry { 7 | struct HashEntry *list; 8 | struct HashEntry *next; 9 | HashValueType value; 10 | } HashEntryType; 11 | 12 | typedef struct { 13 | struct HashEntry *next; 14 | struct HashEntry *last; 15 | } HashHeadType; 16 | 17 | typedef struct { 18 | struct HashEntry *ref; 19 | struct HashEntry *next; 20 | struct HashEntry *last; 21 | } HashListCtrlType; 22 | static HashListCtrlType HashListCtrl[HASHID_NUM]; 23 | static HashHeadType HashTable[HASHID_NUM][HASHSIZE]; 24 | 25 | static uint32 hashValue(uint32 rawdata) 26 | { 27 | return rawdata % HASHSIZE; 28 | } 29 | static HashEntryType *getEntry(void) 30 | { 31 | return malloc(sizeof(HashEntryType)); 32 | } 33 | 34 | void hash_init(void) 35 | { 36 | int i; 37 | int k; 38 | 39 | for (k = 0; k < HASHID_NUM; k++) { 40 | HashListCtrl[k].ref = NULL; 41 | HashListCtrl[k].next = NULL; 42 | HashListCtrl[k].last = NULL; 43 | for (i = 0; i < HASHSIZE; i++) { 44 | HashTable[k][i].next = NULL; 45 | HashTable[k][i].last = NULL; 46 | } 47 | } 48 | return; 49 | } 50 | 51 | HashValueType* hash_search(HashIdType id, HashValueType *value) 52 | { 53 | HashEntryType *entry; 54 | HashHeadType *head; 55 | uint32 hvalue; 56 | 57 | hvalue = hashValue(value->rawdata); 58 | head = &HashTable[id][hvalue]; 59 | 60 | entry = head->next; 61 | while (entry != NULL) { 62 | if (value->rawdata == entry->value.rawdata) { 63 | return &entry->value; 64 | } 65 | entry = entry->next; 66 | } 67 | return NULL; 68 | } 69 | 70 | void hash_add(HashIdType id, HashValueType *value) 71 | { 72 | HashValueType *tmp; 73 | HashEntryType *entry; 74 | HashHeadType *head; 75 | uint32 hvalue; 76 | 77 | tmp = hash_search(id, value); 78 | if (tmp != NULL) { 79 | return; 80 | } 81 | //printf("hash_add:0x%x\n", value->rawdata); 82 | //fflush(stdout); 83 | 84 | hvalue = hashValue(value->rawdata); 85 | head = &HashTable[id][hvalue]; 86 | entry = getEntry(); 87 | entry->value = *value; 88 | entry->next = NULL; 89 | entry->list = NULL; 90 | 91 | /* 92 | * ハッシュリスト登録 93 | */ 94 | if (head->last == NULL) { 95 | head->next = head->last = entry; 96 | } 97 | else { 98 | head->last->next = entry; 99 | head->last = entry; 100 | } 101 | 102 | /* 103 | * 全エントリ管理用リスト登録 104 | */ 105 | if (HashListCtrl[id].last == NULL) { 106 | HashListCtrl[id].next = HashListCtrl[id].last = entry; 107 | } 108 | else { 109 | HashListCtrl[id].last->list = entry; 110 | HashListCtrl[id].last = entry; 111 | } 112 | 113 | return; 114 | } 115 | 116 | HashValueType* hash_first(HashIdType id) 117 | { 118 | HashListCtrl[id].ref = HashListCtrl[id].next; 119 | if (HashListCtrl[id].ref == NULL) { 120 | return NULL; 121 | } 122 | return &HashListCtrl[id].ref->value; 123 | } 124 | 125 | HashValueType* hash_next(HashIdType id) 126 | { 127 | if (HashListCtrl[id].ref == NULL) { 128 | return NULL; 129 | } 130 | if (HashListCtrl[id].ref->list == NULL) { 131 | return NULL; 132 | } 133 | HashListCtrl[id].ref = HashListCtrl[id].ref->list; 134 | return &HashListCtrl[id].ref->value; 135 | } 136 | -------------------------------------------------------------------------------- /src/lib/comm_buffer.c: -------------------------------------------------------------------------------- 1 | #include "comm_buffer.h" 2 | #include 3 | 4 | Std_ReturnType comm_fifo_buffer_create(uint32 size, CommFifoBufferType *fifop) 5 | { 6 | if (fifop == NULL) { 7 | return STD_E_INVALID; 8 | } 9 | fifop->data = malloc(size); 10 | if (fifop->data == NULL) { 11 | return STD_E_LIMIT; 12 | } 13 | fifop->max_size = size; 14 | fifop->count = 0; 15 | fifop->rx_off = 0; 16 | fifop->tx_off = 0; 17 | return STD_E_OK; 18 | } 19 | 20 | static Std_ReturnType fifo_buffer_add(CommFifoBufferType *fifop, char data) 21 | { 22 | if (fifop->count >= fifop->max_size) { 23 | return STD_E_LIMIT; 24 | } 25 | fifop->data[fifop->tx_off] = data; 26 | fifop->tx_off++; 27 | if (fifop->tx_off >= fifop->max_size) { 28 | fifop->tx_off = 0; 29 | } 30 | fifop->count++; 31 | return STD_E_OK; 32 | } 33 | 34 | Std_ReturnType comm_fifo_buffer_add(CommFifoBufferType *fifop, const char* datap, uint32 datalen, uint32 *res) 35 | { 36 | uint32 i; 37 | Std_ReturnType err; 38 | 39 | *res = 0; 40 | if (fifop->count >= fifop->max_size) { 41 | return STD_E_LIMIT; 42 | } 43 | for (i = 0; i < datalen; i++) { 44 | err = fifo_buffer_add(fifop, datap[i]); 45 | if (err != STD_E_OK) { 46 | return err; 47 | } 48 | (*res) = (*res) + 1; 49 | } 50 | return STD_E_OK; 51 | } 52 | static Std_ReturnType fifo_buffer_get(CommFifoBufferType *fifop, char* datap) 53 | { 54 | if (fifop->count == 0) { 55 | return STD_E_NOENT; 56 | } 57 | *datap = fifop->data[fifop->rx_off]; 58 | fifop->rx_off++; 59 | if (fifop->rx_off >= fifop->max_size) { 60 | fifop->rx_off = 0; 61 | } 62 | fifop->count--; 63 | return STD_E_OK; 64 | } 65 | 66 | Std_ReturnType comm_fifo_buffer_get(CommFifoBufferType *fifop, char* datap, uint32 datalen, uint32 *res) 67 | { 68 | uint32 i; 69 | Std_ReturnType err; 70 | 71 | *res = 0; 72 | if (fifop->count == 0) { 73 | return STD_E_NOENT; 74 | } 75 | for (i = 0; i < datalen; i++) { 76 | err = fifo_buffer_get(fifop, &datap[i]); 77 | if (err != STD_E_OK) { 78 | return err; 79 | } 80 | (*res) = (*res) + 1; 81 | } 82 | return STD_E_OK; 83 | } 84 | 85 | void comm_fifo_buffer_close(CommFifoBufferType *fifop) 86 | { 87 | if (fifop != NULL) { 88 | fifop->count = 0; 89 | fifop->rx_off = 0; 90 | fifop->tx_off = 0; 91 | } 92 | return; 93 | } 94 | 95 | void comm_fifo_buffer_destroy(CommFifoBufferType *fifop) 96 | { 97 | if (fifop != NULL) { 98 | if (fifop->data != NULL) { 99 | free(fifop->data); 100 | fifop->data = NULL; 101 | } 102 | fifop->max_size = 0; 103 | fifop->count = 0; 104 | fifop->rx_off = 0; 105 | fifop->tx_off = 0; 106 | } 107 | return; 108 | } 109 | 110 | 111 | Std_ReturnType comm_buffer_create(uint32 size, CommBufferType *bufferp) 112 | { 113 | if (bufferp == NULL) { 114 | return STD_E_INVALID; 115 | } 116 | bufferp->data = malloc(size); 117 | if (bufferp->data == NULL) { 118 | return STD_E_LIMIT; 119 | } 120 | bufferp->max_size = size; 121 | return STD_E_OK; 122 | } 123 | void comm_buffer_destroy(CommBufferType *bufferp) 124 | { 125 | if (bufferp != NULL) { 126 | if (bufferp->data != NULL) { 127 | free(bufferp->data); 128 | bufferp->data = NULL; 129 | } 130 | bufferp->max_size = 0; 131 | } 132 | return; 133 | } 134 | -------------------------------------------------------------------------------- /src/device/peripheral/mros-dev/mros-src/protocol/cimpl/mros_protocol_operation_cimpl.c: -------------------------------------------------------------------------------- 1 | #include "mros_protocol_operation_cimpl.h" 2 | #include "mros_comm_tcp_client_factory_cimpl.h" 3 | #include "mros_packet_decoder_cimpl.h" 4 | #include "mros_packet_encoder_cimpl.h" 5 | #include "mros_sys_config.h" 6 | #include 7 | 8 | mRosSizeType mros_protocol_get_buffersize(mRosSizeType body_size) 9 | { 10 | return (body_size + MROS_TOPIC_RAWDATA_HEADER_SIZE); 11 | } 12 | 13 | char* mros_protocol_get_body(char *buffer) 14 | { 15 | return &buffer[MROS_TOPIC_RAWDATA_HEADER_SIZE]; 16 | } 17 | 18 | 19 | mRosReturnType mros_protocol_topic_data_send(mRosCommTcpClientType *client, const char *data, mRosSizeType datalen) 20 | { 21 | mRosReturnType ret; 22 | mRosSizeType res; 23 | mRosPacketType packet; 24 | mRosEncodeArgType arg; 25 | 26 | packet.total_size = MROS_TOPIC_RAWDATA_HEADER_SIZE; 27 | packet.data_size = 0; 28 | 29 | packet.data = (char*)data; 30 | arg.type = MROS_PACKET_DATA_TOPIC; 31 | arg.args_int = 1; 32 | arg.argi[0] = datalen; 33 | arg.args_char = 0; 34 | ret = mros_packet_encode(&arg, &packet); 35 | if (ret != MROS_E_OK) { 36 | ROS_ERROR("%s %s() %u ret=%d", __FILE__, __FUNCTION__, __LINE__, ret); 37 | return ret; 38 | } 39 | //send header & body 40 | return mros_comm_tcp_client_send_all(client, data, datalen, &res); 41 | } 42 | 43 | mRosReturnType mros_protocol_topic_data_receive(mRosCommTcpClientType *client, mRosMemoryManagerType *mempool, mRosMemoryListEntryType **retp) 44 | { 45 | mRosPacketType packet; 46 | mRosSizeType len; 47 | mRosSizeType res; 48 | mRosReturnType ret; 49 | mRosMemoryListEntryType *mem_entryp; 50 | mros_int8 rawdata[MROS_TOPIC_RAWDATA_HEADER_SIZE]; 51 | *retp = MROS_NULL; 52 | 53 | ret = mros_comm_socket_wait_readable(&client->socket, 0); 54 | if (ret != MROS_E_OK) { 55 | //ROS_ERROR("%s %s() %u ret=%d", __FILE__, __FUNCTION__, __LINE__, ret); 56 | return ret; 57 | } 58 | //receive header 59 | ret = mros_comm_tcp_client_receive_all(client, rawdata, MROS_TOPIC_RAWDATA_HEADER_SIZE, &res); 60 | if (ret != MROS_E_OK) { 61 | //ROS_ERROR("%s %s() %u ret=%d", __FILE__, __FUNCTION__, __LINE__, ret); 62 | return ret; 63 | } 64 | //decode header 65 | packet.total_size = MROS_TOPIC_RAWDATA_HEADER_SIZE; 66 | packet.data_size = MROS_TOPIC_RAWDATA_HEADER_SIZE; 67 | packet.data = rawdata; 68 | ret = mros_topicpacket_get_body_size(&packet, &len); 69 | if (ret != MROS_E_OK) { 70 | ROS_ERROR("%s %s() %u ret=%d", __FILE__, __FUNCTION__, __LINE__, ret); 71 | return ret; 72 | } 73 | //receive body 74 | ret = mros_mem_alloc(mempool, len + MROS_TOPIC_RAWDATA_HEADER_SIZE, &mem_entryp); 75 | if (ret != MROS_E_OK) { 76 | ROS_ERROR("%s %s() %u ret=%d", __FILE__, __FUNCTION__, __LINE__, ret); 77 | return ret; 78 | } 79 | memcpy(&mem_entryp->data.memp[0], rawdata, MROS_TOPIC_RAWDATA_HEADER_SIZE); 80 | 81 | ret = mros_comm_tcp_client_receive_all(client, &mem_entryp->data.memp[MROS_TOPIC_RAWDATA_HEADER_SIZE], len, &res); 82 | if (ret != MROS_E_OK) { 83 | ROS_ERROR("%s %s() %u ret=%d", __FILE__, __FUNCTION__, __LINE__, ret); 84 | return ret; 85 | } 86 | *retp = mem_entryp; 87 | return MROS_E_OK; 88 | } 89 | 90 | void mros_protocol_client_obj_free(void* reqp) 91 | { 92 | mros_comm_tcp_client_free((mRosCommTcpClientListReqEntryType *)reqp); 93 | return; 94 | } 95 | 96 | 97 | -------------------------------------------------------------------------------- /src/lib/dwarf/elf_dwarf_util.c: -------------------------------------------------------------------------------- 1 | #include "elf_dwarf_util.h" 2 | #include "athrill_memory.h" 3 | #include "assert.h" 4 | #include 5 | #include 6 | 7 | uint32 elf_dwarf_decode_uleb128(uint8 *ptr, uint32 *size) 8 | { 9 | uint8 i; 10 | uint8 byte; 11 | uint32 data = 0; 12 | uint32 shift = 0; 13 | 14 | for (i = 0; i < 4; i++) { 15 | byte = ptr[i]; 16 | data |= ((uint32)(byte & 0x7f)) << shift; 17 | shift += 7; 18 | if ((byte & 0x80) == 0) { 19 | break; 20 | } 21 | } 22 | *size = i + 1; 23 | return data; 24 | } 25 | 26 | sint32 elf_dwarf_decode_sleb128(uint8 *ptr, uint32 *size) 27 | { 28 | uint8 i; 29 | uint8 sign = 0; 30 | uint8 byte; 31 | sint32 data = 0; 32 | sint32 shift = 0; 33 | 34 | for (i = 0; i < 5; i++) { 35 | byte = ptr[i]; 36 | sign = byte & 0x40; 37 | data |= ((sint32)(byte & 0x7f)) << shift; 38 | shift += 7; 39 | if ((byte & 0x80) == 0) { 40 | break; 41 | } 42 | } 43 | *size = i + 1; 44 | 45 | if (sign) { 46 | data |= (- (1 << shift)); 47 | } 48 | 49 | return data; 50 | } 51 | 52 | void elf_array_realloc(ElfPointerArrayType *array) 53 | { 54 | void *new_ptr; 55 | if (array->current_array_size >= array->max_array_size) { 56 | array->max_array_size += ELF_POINTER_ARRAY_SIZE_UNIT; 57 | new_ptr = realloc(array->data, (array->max_array_size * sizeof(void*))); 58 | ASSERT(new_ptr != NULL); 59 | array->data = new_ptr; 60 | } 61 | return; 62 | } 63 | extern void elf_array_add_entry(ElfPointerArrayType *array, void *entry) 64 | { 65 | if (array->current_array_size >= array->max_array_size) { 66 | elf_array_realloc(array); 67 | } 68 | array->data[array->current_array_size] = entry; 69 | array->current_array_size++; 70 | return; 71 | } 72 | ElfPointerArrayType *elf_array_alloc(void) 73 | { 74 | ElfPointerArrayType *array = athrill_mem_alloc(sizeof(ElfPointerArrayType)); 75 | ASSERT(array != NULL); 76 | array->current_array_size = 0; 77 | array->max_array_size = 0; 78 | array->data = NULL; 79 | elf_array_realloc(array); 80 | return array; 81 | } 82 | 83 | void *elf_obj_alloc(uint32 size) 84 | { 85 | void *obj; 86 | obj = athrill_mem_alloc(size); 87 | ASSERT(obj != NULL); 88 | memset(obj, 0, size); 89 | return obj; 90 | } 91 | 92 | DwarfUint32ArrayType *dwarf_uint32_array_alloc(void) 93 | { 94 | DwarfUint32ArrayType *array = athrill_mem_alloc(sizeof(DwarfUint32ArrayType)); 95 | ASSERT(array != NULL); 96 | array->current_array_size = 0; 97 | array->max_array_size = 0; 98 | array->data = NULL; 99 | dwarf_uint32_array_realloc(array); 100 | return array; 101 | } 102 | void dwarf_uint32_array_realloc(DwarfUint32ArrayType *array) 103 | { 104 | void *new_ptr; 105 | 106 | if (array->current_array_size >= array->max_array_size) { 107 | array->max_array_size += DWARF_ARRAY_SIZE_UNIT32; 108 | new_ptr = realloc(array->data, (array->max_array_size * sizeof(uint32))); 109 | ASSERT(new_ptr != NULL); 110 | array->data = new_ptr; 111 | } 112 | return; 113 | } 114 | void dwarf_uint32_array_add_entry(DwarfUint32ArrayType *array, uint32 entry) 115 | { 116 | if (array->current_array_size >= array->max_array_size) { 117 | dwarf_uint32_array_realloc(array); 118 | } 119 | array->data[array->current_array_size] = entry; 120 | array->current_array_size++; 121 | return; 122 | } 123 | 124 | -------------------------------------------------------------------------------- /src/device/peripheral/mros-dev/mros-src/protocol/cimpl/mros_protocol_slave_cimpl.c: -------------------------------------------------------------------------------- 1 | #include "mros_protocol_slave_cimpl.h" 2 | #include "mros_protocol_server_proc_cimpl.h" 3 | #include "mros_comm_tcp_client_cimpl.h" 4 | #include "mros_comm_tcp_server_cimpl.h" 5 | #include "mros_packet_encoder_cimpl.h" 6 | #include "mros_exclusive_area.h" 7 | #include "mros_sys_config.h" 8 | 9 | typedef union { 10 | char buffer; 11 | char buffer1[MROS_PACKET_MAXSIZE_REQ_REQUEST_TOPIC]; 12 | char buffer2[MROS_PACKET_MAXSIZE_RES_REQUEST_TOPIC]; 13 | char buffer3[MROS_PACKET_MAXSIZE_REQ_PUBLISHER_UPDATE]; 14 | } mRosSlavePacketBufferType; 15 | static mRosSlavePacketBufferType mros_slave_packet_buffer MROS_MATTR_BSS_NOCLR; 16 | 17 | typedef struct { 18 | mRosProtocolSlaveStateEnumType state; 19 | mRosEncodeArgType arg; 20 | mRosPacketType packet; 21 | mRosCommTcpServerType server_comm; 22 | mRosCommTcpClientType client_comm; 23 | mros_uint32 self_ipaddr; 24 | } mRosProtocolSlaveType; 25 | 26 | static mRosProtocolSlaveType mros_protocol_slave MROS_MATTR_BSS_NOCLR; 27 | 28 | mRosReturnType mros_protocol_slave_init(void) 29 | { 30 | mRosReturnType ret = mros_comm_tcp_server_init(&mros_protocol_slave.server_comm); 31 | if (ret != MROS_E_OK) { 32 | ROS_ERROR("%s %s() %u ret=%d", __FILE__, __FUNCTION__, __LINE__, ret); 33 | return ret; 34 | } 35 | 36 | mros_protocol_slave.packet.total_size = sizeof(mRosSlavePacketBufferType); 37 | mros_protocol_slave.packet.data = &mros_slave_packet_buffer.buffer; 38 | mros_protocol_slave.state = MROS_PROTOCOL_SLAVE_STATE_WAITING; 39 | ret = mros_comm_tcp_server_bind(&mros_protocol_slave.server_comm, mros_slave_port_no); 40 | if (ret != MROS_E_OK) { 41 | ROS_ERROR("%s %s() %u ret=%d", __FILE__, __FUNCTION__, __LINE__, ret); 42 | return ret; 43 | } 44 | ret = mros_comm_tcp_server_listen(&mros_protocol_slave.server_comm, MROS_COMM_TCP_SERVER_LISTEN_MAX_DEFAULT_VALUE); 45 | if (ret != MROS_E_OK) { 46 | ROS_ERROR("%s %s() %u ret=%d", __FILE__, __FUNCTION__, __LINE__, ret); 47 | return ret; 48 | } 49 | ret = mros_comm_inet_get_ipaddr((const char *)mros_node_ipaddr, &mros_protocol_slave.self_ipaddr); 50 | if (ret != MROS_E_OK) { 51 | ROS_ERROR("%s %s() %u ret=%d", __FILE__, __FUNCTION__, __LINE__, ret); 52 | return ret; 53 | } 54 | return MROS_E_OK; 55 | } 56 | 57 | void mros_protocol_slave_run(void) 58 | { 59 | mRosReturnType ret; 60 | mROsExclusiveUnlockObjType unlck_obj; 61 | 62 | while (MROS_TRUE) { 63 | mros_protocol_slave.state = MROS_PROTOCOL_SLAVE_STATE_WAITING; 64 | ret = mros_comm_tcp_server_accept(&mros_protocol_slave.server_comm, &mros_protocol_slave.client_comm); 65 | if (ret != MROS_E_OK) { 66 | continue; 67 | } 68 | mros_protocol_slave.state = MROS_PROTOCOL_SLAVE_STATE_REPLYING_REQUEST_TOPIC; 69 | ret = mros_proc_receive(&mros_protocol_slave.client_comm, &mros_protocol_slave.packet); 70 | if (ret != MROS_E_OK) { 71 | ROS_ERROR("%s %s() %u ret=%d", __FILE__, __FUNCTION__, __LINE__, ret); 72 | mros_comm_tcp_client_close(&mros_protocol_slave.client_comm); 73 | continue; 74 | } 75 | mros_exclusive_lock(&mros_exclusive_area, &unlck_obj); 76 | ret = mros_proc_slave(&mros_protocol_slave.client_comm, &mros_protocol_slave.packet, mros_protocol_slave.self_ipaddr); 77 | mros_exclusive_unlock(&unlck_obj); 78 | if (ret != MROS_E_OK) { 79 | ROS_ERROR("%s %s() %u ret=%d", __FILE__, __FUNCTION__, __LINE__, ret); 80 | continue; 81 | } 82 | mros_comm_tcp_client_close(&mros_protocol_slave.client_comm); 83 | } 84 | return; 85 | } 86 | -------------------------------------------------------------------------------- /src/lib/udp/udp_comm.c: -------------------------------------------------------------------------------- 1 | #include "udp_comm.h" 2 | 3 | #define UDP_COMM_BLOCKING 0 4 | #define UDP_COMM_NONBLOCKING 1 5 | 6 | Std_ReturnType udp_comm_create_ipaddr(const UdpCommConfigType *config, UdpCommType *comm, const char* my_ipaddr) 7 | { 8 | int err; 9 | struct target_os_api_sockaddr_type addr; 10 | u_long val; 11 | 12 | err = socket(AF_INET, SOCK_DGRAM, 0); 13 | if (err < 0) { 14 | return STD_E_INVALID; 15 | } 16 | comm->srv_sock = err; 17 | 18 | #ifdef ENABLE_REUSE_UDP_SOCKET 19 | int yes = 1; 20 | setsockopt(comm->srv_sock, SOL_SOCKET, SO_REUSEADDR, (const char *)&yes, sizeof(yes)); 21 | #endif 22 | 23 | addr.sin_family = AF_INET; 24 | addr.sin_port = htons(config->server_port); 25 | if (my_ipaddr == NULL) { 26 | addr.sin_addr.target_os_sockaddr_sin_addr = INADDR_ANY; 27 | } 28 | else { 29 | addr.sin_addr.target_os_sockaddr_sin_addr = inet_addr(my_ipaddr); 30 | } 31 | 32 | err = bind(comm->srv_sock, (struct sockaddr *)&addr, sizeof(addr)); 33 | if (err < 0) { 34 | return STD_E_INVALID; 35 | } 36 | 37 | if (!(config->is_wait)) { 38 | val = UDP_COMM_NONBLOCKING; 39 | } 40 | else { 41 | val = UDP_COMM_BLOCKING; 42 | } 43 | target_os_api_ioctlsock(comm->srv_sock, FIONBIO, &val); 44 | 45 | comm->client_port = htons(config->client_port); 46 | 47 | return STD_E_OK; 48 | } 49 | Std_ReturnType udp_comm_create(const UdpCommConfigType *config, UdpCommType *comm) 50 | { 51 | return udp_comm_create_ipaddr(config, comm, NULL); 52 | } 53 | 54 | Std_ReturnType udp_comm_read(UdpCommType *comm) 55 | { 56 | int err; 57 | 58 | err = recv(comm->srv_sock, comm->read_data.buffer, sizeof(comm->read_data.buffer), 0); 59 | if (err <= 0) { 60 | return STD_E_INVALID; 61 | } 62 | comm->read_data.len = err; 63 | 64 | return STD_E_OK; 65 | } 66 | 67 | Std_ReturnType udp_comm_write(UdpCommType *comm) 68 | { 69 | int err; 70 | struct target_os_api_sockaddr_type addr; 71 | 72 | err = socket(AF_INET, SOCK_DGRAM, 0); 73 | if (err < 0) { 74 | return STD_E_INVALID; 75 | } 76 | comm->clt_sock = err; 77 | 78 | addr.sin_family = AF_INET; 79 | addr.sin_port = comm->client_port; 80 | addr.sin_addr.target_os_sockaddr_sin_addr = inet_addr("127.0.0.1"); 81 | 82 | err = sendto(comm->clt_sock, comm->write_data.buffer, comm->write_data.len, 0, 83 | (struct sockaddr *)&addr, sizeof(addr)); 84 | if (err != comm->write_data.len) { 85 | return STD_E_INVALID; 86 | } 87 | target_os_api_closesocket(comm->clt_sock); 88 | comm->clt_sock = -1; 89 | 90 | return STD_E_OK; 91 | } 92 | Std_ReturnType udp_comm_remote_write(UdpCommType *comm, const char *remote_ipaddr) 93 | { 94 | int err; 95 | struct target_os_api_sockaddr_type addr; 96 | 97 | err = socket(AF_INET, SOCK_DGRAM, 0); 98 | if (err < 0) { 99 | return STD_E_INVALID; 100 | } 101 | comm->clt_sock = err; 102 | 103 | addr.sin_family = AF_INET; 104 | addr.sin_port = comm->client_port; 105 | addr.sin_addr.target_os_sockaddr_sin_addr = inet_addr(remote_ipaddr); 106 | 107 | err = sendto(comm->clt_sock, comm->write_data.buffer, comm->write_data.len, 0, 108 | (struct sockaddr *)&addr, sizeof(addr)); 109 | if (err != comm->write_data.len) { 110 | return STD_E_INVALID; 111 | } 112 | target_os_api_closesocket(comm->clt_sock); 113 | comm->clt_sock = -1; 114 | 115 | return STD_E_OK; 116 | } 117 | 118 | void udp_server_delete(UdpCommType *comm) 119 | { 120 | target_os_api_closesocket(comm->srv_sock); 121 | comm->srv_sock = -1; 122 | return; 123 | } 124 | -------------------------------------------------------------------------------- /src/debugger/executor/cpu_control/dbg_cpu_thread_control.c: -------------------------------------------------------------------------------- 1 | #include "cpu_control/dbg_cpu_thread_control.h" 2 | #include "std_types.h" 3 | #include "target/target_os_api.h" 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | 15 | typedef enum { 16 | THREAD_STATE_RUNNING, 17 | THREAD_STATE_WAIT, 18 | } DbgCpuThrStateType; 19 | static pthread_mutex_t dbg_mutex; 20 | static pthread_cond_t dbg_cv; 21 | static pthread_cond_t cpu_cv; 22 | static volatile DbgCpuThrStateType dbgthr_state = THREAD_STATE_RUNNING; 23 | static volatile DbgCpuThrStateType cputhr_state = THREAD_STATE_WAIT; 24 | 25 | void cputhr_control_init(void) 26 | { 27 | pthread_mutex_init(&dbg_mutex, NULL); 28 | pthread_cond_init(&dbg_cv, NULL); 29 | pthread_cond_init(&cpu_cv, NULL); 30 | return; 31 | 32 | } 33 | #if 0 /* for test */ 34 | #include "cpu.h" 35 | #include "cpu_control/dbg_cpu_callback.h" 36 | #include 37 | #include 38 | #include 39 | 40 | static void *cpuemu_thread_run(void* arg) 41 | { 42 | TargetCoreType core; 43 | 44 | 45 | core.core_id = 0; 46 | core.reg.pc = 0; 47 | while (TRUE) { 48 | DBG_PRINT((DBG_EXEC_OP_BUF(), DBG_EXEC_OP_BUF_LEN(), "pc=0x%x\n", core.reg.pc)); 49 | fflush(stdout); 50 | 51 | dbg_notify_cpu_clock_supply_start(&core); 52 | 53 | Sleep(100); 54 | 55 | core.reg.pc++; 56 | } 57 | return NULL; 58 | } 59 | #endif 60 | void cputhr_control_start(void *(*cpu_run) (void *)) 61 | { 62 | pthread_t thread; 63 | cputhr_state = THREAD_STATE_RUNNING; 64 | pthread_create(&thread , NULL , cpu_run , NULL); 65 | } 66 | 67 | 68 | void cputhr_control_cpu_wait(void) 69 | { 70 | pthread_mutex_lock(&dbg_mutex); 71 | cputhr_state = THREAD_STATE_WAIT; 72 | pthread_cond_wait(&cpu_cv, &dbg_mutex); 73 | cputhr_state = THREAD_STATE_RUNNING; 74 | pthread_mutex_unlock(&dbg_mutex); 75 | return; 76 | } 77 | void cputhr_control_dbg_wait(void) 78 | { 79 | pthread_mutex_lock(&dbg_mutex); 80 | dbgthr_state = THREAD_STATE_WAIT; 81 | pthread_cond_wait(&dbg_cv, &dbg_mutex); 82 | dbgthr_state = THREAD_STATE_RUNNING; 83 | pthread_mutex_unlock(&dbg_mutex); 84 | return; 85 | } 86 | 87 | void cputhr_control_dbg_wakeup_cpu_and_wait_for_cpu_stopped(void) 88 | { 89 | pthread_mutex_lock(&dbg_mutex); 90 | if (cputhr_state == THREAD_STATE_WAIT) { 91 | cputhr_state = THREAD_STATE_RUNNING; 92 | pthread_cond_signal(&cpu_cv); 93 | } 94 | while (cputhr_state == THREAD_STATE_RUNNING) { 95 | pthread_mutex_unlock(&dbg_mutex); 96 | 97 | target_os_api_sleep(50); 98 | 99 | pthread_mutex_lock(&dbg_mutex); 100 | } 101 | pthread_mutex_unlock(&dbg_mutex); 102 | return; 103 | } 104 | 105 | void cputhr_control_dbg_waitfor_cpu_stopped(void) 106 | { 107 | pthread_mutex_lock(&dbg_mutex); 108 | while (cputhr_state == THREAD_STATE_RUNNING) { 109 | pthread_mutex_unlock(&dbg_mutex); 110 | 111 | target_os_api_sleep(50); 112 | 113 | pthread_mutex_lock(&dbg_mutex); 114 | } 115 | pthread_mutex_unlock(&dbg_mutex); 116 | return; 117 | } 118 | 119 | void cputhr_control_dbg_wakeup_cpu(void) 120 | { 121 | pthread_mutex_lock(&dbg_mutex); 122 | pthread_cond_signal(&cpu_cv); 123 | pthread_mutex_unlock(&dbg_mutex); 124 | } 125 | void cputhr_control_cpu_wakeup_dbg(void) 126 | { 127 | pthread_mutex_lock(&dbg_mutex); 128 | pthread_cond_signal(&dbg_cv); 129 | pthread_mutex_unlock(&dbg_mutex); 130 | } 131 | -------------------------------------------------------------------------------- /src/lib/list.h: -------------------------------------------------------------------------------- 1 | #ifndef _LIST_H_ 2 | #define _LIST_H_ 3 | 4 | #include "std_types.h" 5 | #include "assert.h" 6 | #include 7 | 8 | /* 9 | * PRIVATE 10 | */ 11 | #define ListEntry_Init(entry) \ 12 | do { \ 13 | (entry)->next = (entry); \ 14 | (entry)->prev = (entry); \ 15 | } while (0) 16 | 17 | #define ListEntry_InsertHead(first, elm) \ 18 | do { \ 19 | if ((first) != NULL) { \ 20 | (elm)->next = (first); \ 21 | (elm)->prev = (first)->prev; \ 22 | (first)->prev->next = (elm); \ 23 | (first)->prev = (elm); \ 24 | } \ 25 | (first) = (elm); \ 26 | } while (0) 27 | 28 | #define List_IsEmpty(first) ((first)->next == (first)) 29 | #define ListEntry_First(first) (first) 30 | 31 | #define ListEntry_Remove(first, elm) \ 32 | do { \ 33 | if ((first) != NULL) { \ 34 | if ((first) == (elm)) { \ 35 | if (List_IsEmpty(first)) { \ 36 | (first) = NULL; \ 37 | } \ 38 | else { \ 39 | (first) = (elm)->next; \ 40 | } \ 41 | } \ 42 | (elm)->next->prev = (elm)->prev; \ 43 | (elm)->prev->next = (elm)->next; \ 44 | ListEntry_Init(elm); \ 45 | } \ 46 | } while (0) 47 | 48 | 49 | /* 50 | * PUBLIC 51 | */ 52 | #define ListEntryType(name, dataTypeName) \ 53 | struct name { \ 54 | struct name *next; \ 55 | struct name *prev; \ 56 | dataTypeName data; \ 57 | } 58 | 59 | #define ListHeadType(entry_type) \ 60 | struct { \ 61 | uint32 entry_size; \ 62 | uint32 entry_num; \ 63 | struct entry_type *entries; \ 64 | struct entry_type *free; \ 65 | uint32 free_num; \ 66 | } 67 | 68 | #define List_Init(headp, entry_type, prealloc_size) \ 69 | do { \ 70 | int _i; \ 71 | (headp)->entry_size = sizeof(entry_type); \ 72 | (headp)->entry_num = 0; \ 73 | (headp)->entries = NULL; \ 74 | (headp)->free = NULL; \ 75 | (headp)->free_num = (prealloc_size); \ 76 | for (_i = 0; _i < (prealloc_size); _i++) { \ 77 | entry_type *_tmp = (entry_type*)malloc(sizeof(entry_type)); \ 78 | ASSERT(_tmp != NULL); \ 79 | ListEntry_Init(_tmp); \ 80 | ListEntry_InsertHead((headp)->free, _tmp); \ 81 | } \ 82 | } while (0) 83 | 84 | #define ListEntry_Alloc(headp, entry_type, new_entrypp) \ 85 | do { \ 86 | entry_type *_tmp; \ 87 | if ((headp)->free_num > 0) { \ 88 | _tmp = ListEntry_First((headp)->free); \ 89 | (headp)->free_num--; \ 90 | } \ 91 | else { \ 92 | _tmp = (entry_type*)malloc(sizeof(entry_type)); \ 93 | ASSERT(_tmp != NULL); \ 94 | ListEntry_Init(_tmp); \ 95 | ListEntry_InsertHead((headp)->free, _tmp); \ 96 | } \ 97 | ListEntry_Remove((headp)->free, _tmp); \ 98 | *(new_entrypp) = _tmp; \ 99 | } while (0) 100 | 101 | #define ListEntry_Free(headp, entryp) \ 102 | do { \ 103 | ListEntry_Init(entryp); \ 104 | ListEntry_InsertHead((headp)->free, entryp); \ 105 | (headp)->free_num++; \ 106 | } while (0) 107 | 108 | 109 | #define ListEntry_AddEntry(headp, entryp) \ 110 | do { \ 111 | ListEntry_Init(entryp); \ 112 | ListEntry_InsertHead((headp)->entries, entryp); \ 113 | (headp)->entry_num++; \ 114 | } while (0) 115 | 116 | #define ListEntry_RemoveEntry(headp, entryp) \ 117 | do { \ 118 | ListEntry_Remove((headp)->entries, entryp); \ 119 | (headp)->entry_num--; \ 120 | } while (0) 121 | 122 | #define ListEntry_RemoveAll(headp, entry_type) \ 123 | do { \ 124 | while ((headp)->entry_num > 0) { \ 125 | entry_type _tmp = ListEntry_First((headp)->entries); \ 126 | ListEntry_RemoveEntry(headp, _tmp); \ 127 | } \ 128 | } while (0) 129 | 130 | #define ListEntry_Foreach(headp, var) \ 131 | int _i = 0; \ 132 | for ((var) = (headp)->entries; \ 133 | _i < (headp)->entry_num; \ 134 | (var) = (var)->next, _i++) 135 | 136 | #endif /* _LIST_H_ */ 137 | --------------------------------------------------------------------------------