Enable WASI feature, enhance security and add SGX sample (#142)

Change emcc to clang
Refine interpreter to improve perforamnce
This commit is contained in:
Weining
2019-11-20 21:16:36 +08:00
committed by wenyongh
parent 29c7c743e9
commit 27f246b5f3
159 changed files with 9543 additions and 3789 deletions

View File

@ -14,7 +14,7 @@ endif ()
# Set BUILD_TARGET, currently values supported:
# "X86_64", "AMD_64", "X86_32", "ARM_32", "MIPS_32", "XTENSA_32"
if (NOT BUILD_TARGET)
if (NOT DEFINED BUILD_TARGET)
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
# Build as X86_64 by default in 64-bit platform
set (BUILD_TARGET "X86_64")

View File

@ -22,8 +22,6 @@ void monitor_sdl_clean_up(void);
static uint32_t tft_fb[MONITOR_HOR_RES * MONITOR_VER_RES];
int
time_get_ms(wasm_module_inst_t module_inst)
{
@ -42,7 +40,7 @@ static volatile bool sdl_refr_qry = false;
static volatile bool sdl_quit_qry = false;
void monitor_flush(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
const lv_color_t * color_p)
const lv_color_t * color_p)
{
/*Return if the area is out the screen*/
if (x2 < 0 || y2 < 0 || x1 > MONITOR_HOR_RES - 1
@ -52,16 +50,16 @@ void monitor_flush(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
int32_t y;
uint32_t w = x2 - x1 + 1;
for (y = y1; y <= y2; y++) {
memcpy(&tft_fb[y * MONITOR_HOR_RES + x1], color_p,
w * sizeof(lv_color_t));
w * sizeof(lv_color_t));
color_p += w;
}
sdl_refr_qry = true;
/*IMPORTANT! It must be called to tell the system the flush is ready*/
}
/**
@ -73,7 +71,7 @@ void monitor_flush(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
* @param color fill color
*/
void monitor_fill(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
lv_color_t color)
lv_color_t color)
{
/*Return if the area is out the screen*/
if (x2 < 0)
@ -113,7 +111,7 @@ void monitor_fill(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
* @param color_p an array of colors
*/
void monitor_map(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
const lv_color_t * color_p)
const lv_color_t * color_p)
{
/*Return if the area is out the screen*/
if (x2 < 0)

View File

@ -15,10 +15,10 @@ zephyr_compile_definitions (-DNVALGRIND
-Dattr_container_malloc=bh_malloc
-Dattr_container_free=bh_free)
# Build as ARM_32 by default, change to "X86_32", "MIPS_32" or "XTENSA_32"
# if we want to support x86, mips or xtensa
if (NOT BUILD_TARGET)
set (BUILD_TARGET "ARM_32")
# Build as General by default, change to "ARM_32", "X86_32", "MIPS_32" or "XTENSA_32"
# if we want to support arm_32, x86, mips or xtensa
if (NOT DEFINED BUILD_TARGET)
set (BUILD_TARGET "General")
endif ()
string(TOUPPER ${BUILD_TARGET} BUILD_TARGET)
@ -31,101 +31,70 @@ elseif (BUILD_TARGET STREQUAL "MIPS_32")
add_definitions(-DBUILD_TARGET_MIPS_32)
elseif (BUILD_TARGET STREQUAL "XTENSA_32")
add_definitions(-DBUILD_TARGET_XTENSA_32)
elseif (BUILD_TARGET STREQUAL "GENERAL")
# Will use invokeNative_general.c instead of assembly code,
# but the maximum number of native arguments is limited to 20,
# and there are possible issues when passing arguments to
# native function for some cpus, e.g. int64 and double arguments
# in arm and mips need to be 8-bytes aligned, and some arguments
# of x86_64 are passed by registers but not stack
else ()
message (FATAL_ERROR "-- Build target isn't set")
endif ()
message ("-- Build as target ${BUILD_TARGET}")
set (IWASM_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/core/iwasm)
set (APP_MGR_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/core/app-mgr)
set (SHARED_LIB_ROOT ${IWASM_ROOT}/../shared-lib)
set (WASM_DIR ${CMAKE_CURRENT_SOURCE_DIR}/core/iwasm)
set (APP_MGR_DIR ${CMAKE_CURRENT_SOURCE_DIR}/core/app-mgr)
set (SHARED_DIR ${WASM_DIR}/../shared-lib)
target_include_directories(app PRIVATE ${IWASM_ROOT}/runtime/include
${IWASM_ROOT}/runtime/platform/zephyr
${IWASM_ROOT}/runtime/platform/include
${IWASM_ROOT}/runtime/utils
${IWASM_ROOT}/runtime/vmcore-wasm
${IWASM_ROOT}/lib/native/base
${IWASM_ROOT}/lib/native/libc
${IWASM_ROOT}/lib/native/extension/sensor
${IWASM_ROOT}/lib/native/extension/connection
${IWASM_ROOT}/lib/native-interface
${APP_MGR_ROOT}/app-manager
${APP_MGR_ROOT}/app-mgr-shared
${SHARED_LIB_ROOT}/include
${SHARED_LIB_ROOT}/platform/include
${SHARED_LIB_ROOT}/platform/zephyr
${SHARED_LIB_ROOT}/mem-alloc/ems
${SHARED_LIB_ROOT}/utils
${SHARED_LIB_ROOT}/coap/er-coap
${SHARED_LIB_ROOT}/coap/extension
${CMAKE_CURRENT_SOURCE_DIR}/../src
${CMAKE_CURRENT_SOURCE_DIR}/../src/platform/zephyr
)
set (TARGET_PLATFORM "zephyr")
set (IWASM_SRCS
${IWASM_ROOT}/runtime/platform/zephyr/wasm_native.c
${IWASM_ROOT}/runtime/utils/wasm_dlfcn.c
${IWASM_ROOT}/runtime/utils/wasm_hashmap.c
${IWASM_ROOT}/runtime/utils/wasm_log.c
${IWASM_ROOT}/runtime/utils/wasm_vector.c
${IWASM_ROOT}/runtime/vmcore-wasm/wasm_application.c
${IWASM_ROOT}/runtime/vmcore-wasm/wasm_interp.c
${IWASM_ROOT}/runtime/vmcore-wasm/wasm_loader.c
${IWASM_ROOT}/runtime/vmcore-wasm/wasm_runtime.c
${IWASM_ROOT}/runtime/vmcore-wasm/invokeNative_general.c
${IWASM_ROOT}/lib/native/base/base_lib_export.c
${IWASM_ROOT}/lib/native/base/request_response.c
${IWASM_ROOT}/lib/native/base/timer_wrapper.c
${IWASM_ROOT}/lib/native/libc/libc_wrapper.c
${IWASM_ROOT}/lib/native/extension/sensor/runtime_sensor.c
${IWASM_ROOT}/lib/native/extension/connection/connection_wrapper.c
${IWASM_ROOT}/lib/native/extension/connection/zephyr/connection_lib_impl.c
${IWASM_ROOT}/lib/native-interface/attr_container.c
${IWASM_ROOT}/lib/native-interface/restful_utils.c
${APP_MGR_ROOT}/app-manager/app_manager.c
${APP_MGR_ROOT}/app-manager/app_manager_host.c
${APP_MGR_ROOT}/app-manager/ble_msg.c
${APP_MGR_ROOT}/app-manager/event.c
${APP_MGR_ROOT}/app-manager/message.c
${APP_MGR_ROOT}/app-manager/module_jeff.c
${APP_MGR_ROOT}/app-manager/module_utils.c
${APP_MGR_ROOT}/app-manager/module_wasm_app.c
${APP_MGR_ROOT}/app-manager/module_wasm_lib.c
${APP_MGR_ROOT}/app-manager/resource_reg.c
${APP_MGR_ROOT}/app-manager/watchdog.c
${APP_MGR_ROOT}/app-manager/platform/zephyr/app_mgr_zephyr.c
${SHARED_LIB_ROOT}/platform/zephyr/bh_assert.c
${SHARED_LIB_ROOT}/platform/zephyr/bh_definition.c
${SHARED_LIB_ROOT}/platform/zephyr/bh_platform.c
${SHARED_LIB_ROOT}/platform/zephyr/bh_platform_log.c
${SHARED_LIB_ROOT}/platform/zephyr/bh_thread.c
${SHARED_LIB_ROOT}/platform/zephyr/bh_time.c
${SHARED_LIB_ROOT}/platform/zephyr/bh_math.c
${SHARED_LIB_ROOT}/mem-alloc/bh_memory.c
${SHARED_LIB_ROOT}/mem-alloc/mem_alloc.c
${SHARED_LIB_ROOT}/mem-alloc/ems/ems_alloc.c
${SHARED_LIB_ROOT}/mem-alloc/ems/ems_hmu.c
${SHARED_LIB_ROOT}/mem-alloc/ems/ems_kfc.c
${SHARED_LIB_ROOT}/mem-alloc/tlsf/tlsf.c
${SHARED_LIB_ROOT}/utils/bh_list.c
${SHARED_LIB_ROOT}/utils/bh_log.c
${SHARED_LIB_ROOT}/utils/bh_queue.c
${SHARED_LIB_ROOT}/utils/runtime_timer.c
${SHARED_LIB_ROOT}/coap/er-coap/er-coap.c
${SHARED_LIB_ROOT}/coap/extension/coap_conversion.c
${SHARED_LIB_ROOT}/coap/extension/coap_over_tcp.c
)
include (${WASM_DIR}/runtime/platform/${TARGET_PLATFORM}/platform.cmake)
include (${WASM_DIR}/runtime/utils/utils.cmake)
include (${WASM_DIR}/runtime/vmcore-wasm/vmcore.cmake)
include (${WASM_DIR}/lib/native/base/wasm_lib_base.cmake)
include (${WASM_DIR}/lib/native/libc/wasm_libc.cmake)
include (${WASM_DIR}/lib/native/extension/sensor/wasm_lib_sensor.cmake)
include (${WASM_DIR}/lib/native/extension/connection/wasm_lib_conn.cmake)
include (${WASM_DIR}/lib/native/extension/connection/${TARGET_PLATFORM}/connection_mgr.cmake)
include (${WASM_DIR}/lib/native-interface/native_interface.cmake)
include (${APP_MGR_DIR}/app-manager/app_mgr.cmake)
include (${APP_MGR_DIR}/app-mgr-shared/app_mgr_shared.cmake)
include (${SHARED_DIR}/platform/${TARGET_PLATFORM}/shared_platform.cmake)
include (${SHARED_DIR}/utils/shared_utils.cmake)
include (${SHARED_DIR}/mem-alloc/mem_alloc.cmake)
include (${SHARED_DIR}/coap/lib_coap.cmake)
set (LVGL_DRV_SRCS
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../src)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../src/platform/zephyr)
set (LVGL_DRV_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/../src/platform/zephyr/display_ili9340_adafruit_1480.c
${CMAKE_CURRENT_SOURCE_DIR}/../src/platform/zephyr/display_ili9340.c
${CMAKE_CURRENT_SOURCE_DIR}/../src/platform/zephyr/display_indev.c
${CMAKE_CURRENT_SOURCE_DIR}/../src/platform/zephyr/XPT2046.c
)
target_sources(app PRIVATE ${IWASM_SRCS}
${LVGL_DRV_SRCS}
${CMAKE_CURRENT_SOURCE_DIR}/../src/platform/zephyr/main.c
${CMAKE_CURRENT_SOURCE_DIR}/../src/platform/zephyr/iwasm_main.c
${CMAKE_CURRENT_SOURCE_DIR}/../src/ext_lib_export.c)
set (IWASM_SRCS
${WASM_PLATFORM_LIB_SOURCE}
${WASM_UTILS_LIB_SOURCE}
${VMCORE_LIB_SOURCE}
${WASM_LIBC_SOURCE}
${APP_MGR_SOURCE}
${WASM_LIB_BASE_SOURCE}
${WASM_LIB_EXT_SOURCE}
${WASM_LIB_SENSOR_SOURCE}
${WASM_LIB_CONN_SOURCE}
${WASM_LIB_CONN_MGR_SOURCE}
${PLATFORM_SHARED_SOURCE}
${UTILS_SHARED_SOURCE}
${MEM_ALLOC_SHARED_SOURCE}
${NATIVE_INTERFACE_SOURCE}
)
target_sources(app PRIVATE
${IWASM_SRCS}
${LVGL_DRV_SRCS}
${CMAKE_CURRENT_SOURCE_DIR}/../src/platform/zephyr/main.c
${CMAKE_CURRENT_SOURCE_DIR}/../src/platform/zephyr/iwasm_main.c
${CMAKE_CURRENT_SOURCE_DIR}/../src/ext_lib_export.c
)