Enhance wasm loader and interpreter, enhance code security and update document (#149)
This commit is contained in:
@ -5,6 +5,16 @@ WAMR_DIR=${PWD}/../..
|
||||
OUT_DIR=${PWD}/out
|
||||
BUILD_DIR=${PWD}/build
|
||||
|
||||
if [ -z $KW_BUILD ] || [ -z $KW_OUT_FILE ];then
|
||||
echo "Local Build Env"
|
||||
cmakewrap="cmake"
|
||||
makewrap="make"
|
||||
else
|
||||
echo "Klocwork Build Env"
|
||||
cmakewrap="cmake -DCMAKE_BUILD_TYPE=Debug"
|
||||
makewrap="kwinject -o $KW_OUT_FILE make"
|
||||
fi
|
||||
|
||||
if [ ! -d $BUILD_DIR ]; then
|
||||
mkdir ${BUILD_DIR}
|
||||
fi
|
||||
@ -30,8 +40,8 @@ echo "##################### 1. build native-ui-app start#####################"
|
||||
cd $BUILD_DIR
|
||||
mkdir -p lvgl-native-ui-app
|
||||
cd lvgl-native-ui-app
|
||||
cmake ${PROJECT_DIR}/lvgl-native-ui-app
|
||||
make
|
||||
$cmakewrap ${PROJECT_DIR}/lvgl-native-ui-app
|
||||
$makewrap
|
||||
if [ $? != 0 ];then
|
||||
echo "BUILD_FAIL native-ui-app $?\n"
|
||||
exit 2
|
||||
@ -45,8 +55,8 @@ echo "##################### 2. build littlevgl wasm runtime start###############
|
||||
cd $BUILD_DIR
|
||||
mkdir -p wasm-runtime-wgl
|
||||
cd wasm-runtime-wgl
|
||||
cmake ${PROJECT_DIR}/wasm-runtime-wgl/linux-build
|
||||
make
|
||||
$cmakewrap ${PROJECT_DIR}/wasm-runtime-wgl/linux-build
|
||||
$makewrap
|
||||
cp wasm_runtime_wgl ${OUT_DIR}/
|
||||
|
||||
echo "##################### build littlevgl wasm runtime end#####################"
|
||||
@ -55,8 +65,8 @@ echo "#####################build host-tool"
|
||||
cd $BUILD_DIR
|
||||
mkdir -p host-tool
|
||||
cd host-tool
|
||||
cmake ${WAMR_DIR}/test-tools/host-tool
|
||||
make
|
||||
$cmakewrap ${WAMR_DIR}/test-tools/host-tool
|
||||
$makewrap
|
||||
if [ $? != 0 ];then
|
||||
echo "BUILD_FAIL host tool exit as $?\n"
|
||||
exit 2
|
||||
@ -67,9 +77,9 @@ echo "#####################build host-tool success"
|
||||
|
||||
echo "##################### 3. build wasm ui app start#####################"
|
||||
cd ${PROJECT_DIR}/wasm-apps/wgl
|
||||
make
|
||||
$makewrap
|
||||
cp ui_app.wasm ${OUT_DIR}/
|
||||
cd ${PROJECT_DIR}/wasm-apps/lvgl-compatible
|
||||
make
|
||||
$makewrap
|
||||
cp ui_app_lvgl_compatible.wasm ${OUT_DIR}/
|
||||
echo "##################### build wasm ui app end#####################"
|
||||
|
||||
@ -58,7 +58,10 @@ void on_init()
|
||||
/* set up a timer */
|
||||
user_timer_t timer;
|
||||
timer = api_timer_create(10, true, false, timer1_update);
|
||||
api_timer_restart(timer, 10);
|
||||
if (timer)
|
||||
api_timer_restart(timer, 10);
|
||||
else
|
||||
printf("Fail to create timer.\n");
|
||||
}
|
||||
|
||||
static void btn_event_cb(lv_obj_t *btn, lv_event_t event)
|
||||
|
||||
@ -51,7 +51,10 @@ void on_init()
|
||||
/* set up a timer */
|
||||
user_timer_t timer;
|
||||
timer = api_timer_create(10, true, false, timer1_update);
|
||||
api_timer_restart(timer, 10);
|
||||
if (timer)
|
||||
api_timer_restart(timer, 10);
|
||||
else
|
||||
printf("Fail to create timer.\n");
|
||||
}
|
||||
|
||||
static void btn_event_cb(wgl_obj_t btn, wgl_event_t event)
|
||||
|
||||
@ -32,6 +32,7 @@
|
||||
#include "attr_container.h"
|
||||
#include "module_wasm_app.h"
|
||||
#include "wasm_export.h"
|
||||
#include "wgl.h"
|
||||
|
||||
#include "lv_drivers/display/monitor.h"
|
||||
#include "lv_drivers/indev/mouse.h"
|
||||
@ -47,11 +48,11 @@ static char *uart_device = "/dev/ttyS2";
|
||||
static int baudrate = B115200;
|
||||
#endif
|
||||
|
||||
extern void * thread_timer_check(void *);
|
||||
extern void init_sensor_framework();
|
||||
extern void exit_sensor_framework();
|
||||
extern void exit_connection_framework();
|
||||
extern int aee_host_msg_callback(void *msg, uint16_t msg_len);
|
||||
extern bool init_connection_framework();
|
||||
extern void wgl_init();
|
||||
|
||||
#ifndef CONNECTION_UART
|
||||
int listenfd = -1;
|
||||
@ -504,9 +505,15 @@ int iwasm_main(int argc, char *argv[])
|
||||
vm_thread_create(&tid, func_uart_mode, NULL, BH_APPLET_PRESERVED_STACK_SIZE);
|
||||
#endif
|
||||
|
||||
// TODO:
|
||||
app_manager_startup(&interface);
|
||||
|
||||
fail1: bh_memory_destroy();
|
||||
exit_wasm_timer();
|
||||
exit_sensor_framework();
|
||||
wgl_exit();
|
||||
exit_connection_framework();
|
||||
|
||||
fail1:
|
||||
bh_memory_destroy();
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -2,8 +2,8 @@
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
extern void iwasm_main(int argc, char *argv[]);
|
||||
extern int iwasm_main(int argc, char *argv[]);
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
iwasm_main(argc,argv);
|
||||
return iwasm_main(argc,argv);
|
||||
}
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
#define LOG_WRN printf
|
||||
|
||||
#include <gpio.h>
|
||||
#include <misc/byteorder.h>
|
||||
#include <sys/byteorder.h>
|
||||
#include <spi.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
@ -18,8 +18,8 @@
|
||||
#include "display.h"
|
||||
#include "lvgl.h"
|
||||
|
||||
extern void * thread_timer_check(void *);
|
||||
extern void init_sensor_framework();
|
||||
extern void exit_sensor_framework();
|
||||
extern int aee_host_msg_callback(void *msg, uint16_t msg_len);
|
||||
extern bool touchscreen_read(lv_indev_data_t * data);
|
||||
extern int ili9340_init();
|
||||
|
||||
@ -5,6 +5,16 @@ WAMR_DIR=${PWD}/../..
|
||||
OUT_DIR=${PWD}/out
|
||||
BUILD_DIR=${PWD}/build
|
||||
|
||||
if [ -z $KW_BUILD ] || [ -z $KW_OUT_FILE ];then
|
||||
echo "Local Build Env"
|
||||
cmakewrap="cmake"
|
||||
makewrap="make"
|
||||
else
|
||||
echo "Klocwork Build Env"
|
||||
cmakewrap="cmake -DCMAKE_BUILD_TYPE=Debug"
|
||||
makewrap="kwinject -o $KW_OUT_FILE make"
|
||||
fi
|
||||
|
||||
if [ ! -d $BUILD_DIR ]; then
|
||||
mkdir ${BUILD_DIR}
|
||||
fi
|
||||
@ -28,8 +38,8 @@ echo "##################### 1. build native-ui-app start#####################"
|
||||
cd $BUILD_DIR
|
||||
mkdir -p vgl-native-ui-app
|
||||
cd vgl-native-ui-app
|
||||
cmake ${PROJECT_DIR}/vgl-native-ui-app
|
||||
make
|
||||
$cmakewrap ${PROJECT_DIR}/vgl-native-ui-app
|
||||
$makewrap
|
||||
if [ $? != 0 ];then
|
||||
echo "BUILD_FAIL native-ui-app $?\n"
|
||||
exit 2
|
||||
@ -43,8 +53,8 @@ echo "##################### 2. build littlevgl wasm runtime start###############
|
||||
cd $BUILD_DIR
|
||||
mkdir -p vgl-wasm-runtime
|
||||
cd vgl-wasm-runtime
|
||||
cmake ${PROJECT_DIR}/vgl-wasm-runtime
|
||||
make
|
||||
$cmakewrap ${PROJECT_DIR}/vgl-wasm-runtime
|
||||
$makewrap
|
||||
cp vgl_wasm_runtime ${OUT_DIR}/
|
||||
|
||||
echo "##################### build littlevgl wasm runtime end#####################"
|
||||
@ -53,8 +63,8 @@ echo "#####################build host-tool"
|
||||
cd $BUILD_DIR
|
||||
mkdir -p host-tool
|
||||
cd host-tool
|
||||
cmake ${WAMR_DIR}/test-tools/host-tool
|
||||
make
|
||||
$cmakewrap ${WAMR_DIR}/test-tools/host-tool
|
||||
$makewrap
|
||||
if [ $? != 0 ];then
|
||||
echo "BUILD_FAIL host tool exit as $?\n"
|
||||
exit 2
|
||||
|
||||
@ -193,7 +193,7 @@ display_input_read(wasm_module_inst_t module_inst,
|
||||
uint8 state;
|
||||
} *data_app;
|
||||
|
||||
lv_indev_data_t data;
|
||||
lv_indev_data_t data = {0};
|
||||
|
||||
ret = mouse_read(&data);
|
||||
|
||||
|
||||
@ -43,8 +43,9 @@ static char *uart_device = "/dev/ttyS2";
|
||||
static int baudrate = B115200;
|
||||
#endif
|
||||
|
||||
extern void * thread_timer_check(void *);
|
||||
extern void init_sensor_framework();
|
||||
extern void exit_sensor_framework();
|
||||
extern void exit_connection_framework();
|
||||
extern int aee_host_msg_callback(void *msg, uint16_t msg_len);
|
||||
extern bool init_connection_framework();
|
||||
|
||||
@ -470,9 +471,14 @@ int iwasm_main(int argc, char *argv[])
|
||||
vm_thread_create(&tid, func_uart_mode, NULL, BH_APPLET_PRESERVED_STACK_SIZE);
|
||||
#endif
|
||||
|
||||
// TODO:
|
||||
app_manager_startup(&interface);
|
||||
|
||||
fail1: bh_memory_destroy();
|
||||
exit_wasm_timer();
|
||||
exit_sensor_framework();
|
||||
exit_connection_framework();
|
||||
|
||||
fail1:
|
||||
bh_memory_destroy();
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -2,8 +2,8 @@
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
extern void iwasm_main(int argc, char *argv[]);
|
||||
extern int iwasm_main(int argc, char *argv[]);
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
iwasm_main(argc,argv);
|
||||
return iwasm_main(argc,argv);
|
||||
}
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
#define LOG_WRN printf
|
||||
|
||||
#include <gpio.h>
|
||||
#include <misc/byteorder.h>
|
||||
#include <sys/byteorder.h>
|
||||
#include <spi.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
@ -16,8 +16,8 @@
|
||||
#include "module_wasm_app.h"
|
||||
#include "wasm_export.h"
|
||||
|
||||
extern void * thread_timer_check(void *);
|
||||
extern void init_sensor_framework();
|
||||
extern void exit_sensor_framework();
|
||||
extern int aee_host_msg_callback(void *msg, uint16_t msg_len);
|
||||
|
||||
#include <zephyr.h>
|
||||
|
||||
@ -2,8 +2,19 @@
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
#!/bin/sh
|
||||
|
||||
WAMR_DIR=${PWD}/../../..
|
||||
|
||||
if [ -z $KW_BUILD ] || [ -z $KW_OUT_FILE ];then
|
||||
echo "Local Build Env"
|
||||
makewrap="make"
|
||||
else
|
||||
echo "Klocwork Build Env"
|
||||
makewrap="kwinject -o $KW_OUT_FILE make"
|
||||
fi
|
||||
|
||||
if [ ! -d "lvgl" ]; then
|
||||
git clone https://github.com/littlevgl/lvgl.git --branch v5.3
|
||||
fi
|
||||
make -f Makefile_wasm_app
|
||||
$makewrap -f Makefile_wasm_app
|
||||
|
||||
|
||||
@ -104,7 +104,10 @@ void on_init()
|
||||
/* set up a timer */
|
||||
user_timer_t timer;
|
||||
timer = api_timer_create(10, true, false, timer1_update);
|
||||
api_timer_restart(timer, 10);
|
||||
if (timer)
|
||||
api_timer_restart(timer, 10);
|
||||
else
|
||||
printf("Fail to create timer.\n");
|
||||
}
|
||||
|
||||
/**********************
|
||||
|
||||
@ -11,6 +11,16 @@ NATIVE_LIBS=${IWASM_ROOT}/lib/native-interface
|
||||
APP_LIB_SRC="${APP_LIBS}/base/*.c ${APP_LIBS}/extension/sensor/*.c ${APP_LIBS}/extension/connection/*.c ${APP_LIBS}/extension/gui/src/*.c ${NATIVE_LIBS}/*.c"
|
||||
WASM_APPS=${PWD}/wasm-apps
|
||||
|
||||
if [ -z $KW_BUILD ] || [ -z $KW_OUT_FILE ];then
|
||||
echo "Local Build Env"
|
||||
cmakewrap="cmake"
|
||||
makewrap="make"
|
||||
else
|
||||
echo "Klocwork Build Env"
|
||||
cmakewrap="cmake -DCMAKE_BUILD_TYPE=Debug"
|
||||
makewrap="kwinject -o $KW_OUT_FILE make"
|
||||
fi
|
||||
|
||||
rm -rf ${OUT_DIR}
|
||||
mkdir ${OUT_DIR}
|
||||
mkdir ${OUT_DIR}/wasm-apps
|
||||
@ -32,8 +42,8 @@ echo "#####################build simple project"
|
||||
cd ${CURR_DIR}
|
||||
mkdir -p cmake_build
|
||||
cd cmake_build
|
||||
cmake -DENABLE_GUI=YES ..
|
||||
make
|
||||
$cmakewrap -DENABLE_GUI=YES ..
|
||||
$makewrap
|
||||
if [ $? != 0 ];then
|
||||
echo "BUILD_FAIL simple exit as $?\n"
|
||||
exit 2
|
||||
@ -45,8 +55,8 @@ echo "#####################build host-tool"
|
||||
cd ${WAMR_DIR}/test-tools/host-tool
|
||||
mkdir -p bin
|
||||
cd bin
|
||||
cmake ..
|
||||
make
|
||||
$cmakewrap ..
|
||||
$makewrap
|
||||
if [ $? != 0 ];then
|
||||
echo "BUILD_FAIL host tool exit as $?\n"
|
||||
exit 2
|
||||
|
||||
@ -32,6 +32,9 @@
|
||||
#include "attr_container.h"
|
||||
#include "module_wasm_app.h"
|
||||
#include "wasm_export.h"
|
||||
#if WASM_ENABLE_GUI != 0
|
||||
#include "wgl.h"
|
||||
#endif
|
||||
|
||||
#if WASM_ENABLE_GUI != 0
|
||||
#include "lv_drivers/display/monitor.h"
|
||||
@ -49,11 +52,11 @@ static char *uart_device = "/dev/ttyS2";
|
||||
static int baudrate = B115200;
|
||||
#endif
|
||||
|
||||
extern void * thread_timer_check(void *);
|
||||
extern void init_sensor_framework();
|
||||
extern void exit_sensor_framework();
|
||||
extern void exit_connection_framework();
|
||||
extern int aee_host_msg_callback(void *msg, uint16_t msg_len);
|
||||
extern bool init_connection_framework();
|
||||
extern void wgl_init();
|
||||
|
||||
#ifndef CONNECTION_UART
|
||||
int listenfd = -1;
|
||||
@ -159,6 +162,9 @@ host_interface interface = {
|
||||
.destroy = host_destroy
|
||||
};
|
||||
|
||||
/* Change it to 1 when fuzzing test */
|
||||
#define WASM_ENABLE_FUZZ_TEST 0
|
||||
|
||||
void* func_server_mode(void* arg)
|
||||
{
|
||||
int clilent;
|
||||
@ -227,6 +233,12 @@ void* func_server_mode(void* arg)
|
||||
|
||||
aee_host_msg_callback(buff, n);
|
||||
}
|
||||
#if WASM_ENABLE_FUZZ_TEST != 0
|
||||
/* Exit the process when host disconnect.
|
||||
* This is helpful for reproducing failure case. */
|
||||
close(sockfd);
|
||||
exit(1);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -509,9 +521,17 @@ int iwasm_main(int argc, char *argv[])
|
||||
vm_thread_create(&tid, func_uart_mode, NULL, BH_APPLET_PRESERVED_STACK_SIZE);
|
||||
#endif
|
||||
|
||||
// TODO:
|
||||
app_manager_startup(&interface);
|
||||
|
||||
fail1: bh_memory_destroy();
|
||||
exit_wasm_timer();
|
||||
exit_sensor_framework();
|
||||
#if WASM_ENABLE_GUI != 0
|
||||
wgl_exit();
|
||||
#endif
|
||||
exit_connection_framework();
|
||||
|
||||
fail1:
|
||||
bh_memory_destroy();
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user