Enable AoT and wamr-sdk, and change arguments of call wasm API (#157)

* Implement memory profiler, optimize memory usage, modify code indent

* Implement memory.grow and limit heap space base offset to 1G; modify iwasm build type to Release and 64 bit by default

* Add a new extension library: connection

* Fix bug of reading magic number and version in big endian platform

* Re-org platform APIs: move most platform APIs from iwasm to shared-lib

* Enhance wasm loader to fix some security issues

* Fix issue about illegal load of EXC_RETURN into PC on stm32 board

* Updates that let a restricted version of the interpreter run in SGX

* Enable native/app address validation and conversion for wasm app

* Remove wasm_application_exectue_* APIs from wasm_export.h which makes confused

* Refine binary size and fix several minor issues

Optimize interpreter LOAD/STORE opcodes to decrease the binary size
Fix issues when using iwasm library: _bh_log undefined, bh_memory.h not found
Remove unused _stdin/_stdout/_stderr global variables resolve in libc wrapper
Add macros of global heap size, stack size, heap size for Zephyr main.c
Clear compile warning of wasm_application.c

* Add more strict security checks for libc wrapper API's

* Use one libc wrapper copy for sgx and other platforms; remove bh_printf macro for other platform header files

* Enhance security of libc strcpy/sprintf wrapper function

* Fix issue of call native for x86_64/arm/mips, add module inst parameter for native wrapper functions

* Remove get_module_inst() and fix issue of call native

* Refine wgl lib: remove module_inst parameter from widget functions; move function index check to runtime instantiate

* Refine interpreter call native process, refine memory boudary check

* Fix issues of invokeNative function of arm/mips/general version

* Add a switch to build simple sample without gui support

* Add BUILD_TARGET setting in makefile to replace cpu compiler flags in source code

* Re-org shared lib header files, remove unused info; fix compile issues of vxworks

* Add build target general

* Remove unused files

* Update license header

* test push

* Restore file

* Sync up with internal/feature

* Sync up with internal/feature

* Rename build_wamr_app to build_wasm_app

* Fix small issues of README

* Enhance malformed wasm file checking
Fix issue of print hex int and implement utf8 string check
Fix wasi file read/write right issue
Fix minor issue of build wasm app doc

* Sync up with internal/feature

* Sync up with internal/feature: fix interpreter arm issue, fix read leb issue

* Sync up with internal/feature

* Fix bug of config.h and rename wasi config.h to ssp_config.h

* Sync up with internal/feature

* Import wamr aot

* update document

* update document

* Update document, disable WASI in 32bit

* update document

* remove files

* update document

* Update document

* update document

* update document

* update samples

* Sync up with internal repo
This commit is contained in:
wenyongh
2020-01-21 13:26:14 +08:00
committed by Wang Xin
parent 2a4528c749
commit 46b93b9d22
464 changed files with 25137 additions and 7911 deletions

View File

@ -0,0 +1,114 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#include "wa-inc/sensor.h"
#include "sensor_api.h"
typedef struct _sensor {
struct _sensor * next;
char *name;
uint32 handle;
void (*sensor_callback)(sensor_t, attr_container_t *, void *);
void *user_data;
} sensor;
static sensor_t g_sensors = NULL;
sensor_t sensor_open(const char* name, int index,
sensor_event_handler_f sensor_event_handler,
void *user_data)
{
uint32 id = wasm_sensor_open(name, index);
if (id == -1)
return NULL;
//create local node for holding the user callback
sensor_t sensor = (sensor_t) malloc(sizeof(struct _sensor));
if (sensor == NULL)
return NULL;
memset(sensor, 0, sizeof(struct _sensor));
sensor->handle = id;
sensor->name = strdup(name);
sensor->user_data = user_data;
sensor->sensor_callback = sensor_event_handler;
if (!sensor->name) {
free(sensor);
return NULL;
}
if (g_sensors == NULL) {
g_sensors = sensor;
} else {
sensor->next = g_sensors;
g_sensors = sensor;
}
return sensor;
}
bool sensor_config_with_attr_container(sensor_t sensor, attr_container_t *cfg)
{
char *buffer = (char *)cfg;
int len = attr_container_get_serialize_length(cfg);
return wasm_sensor_config_with_attr_container(sensor->handle, buffer, len);
}
bool sensor_config(sensor_t sensor, int interval, int bit_cfg, int delay)
{
bool ret = wasm_sensor_config(sensor->handle, interval, bit_cfg, delay);
return ret;
}
bool sensor_close(sensor_t sensor)
{
wasm_sensor_close(sensor->handle);
// remove local node
sensor_t s = g_sensors;
sensor_t prev = NULL;
while (s) {
if (s == sensor) {
if (prev == NULL) {
g_sensors = s->next;
} else {
prev->next = s->next;
}
free(s->name);
free(s);
return true;
} else {
prev = s;
s = s->next;
}
}
return false;
}
/*
*
* API for native layer to callback for sensor events
*
*/
void on_sensor_event(uint32 sensor_id, char * buffer, int len)
{
attr_container_t * sensor_data = (attr_container_t *) buffer;
// lookup the sensor and call the handlers
sensor_t s = g_sensors;
sensor_t prev = NULL;
while (s) {
if (s->handle == sensor_id) {
s->sensor_callback(s, sensor_data, s->user_data);
break;
}
s = s->next;
}
}

View File

@ -0,0 +1,32 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#ifndef _SENSOR_API_H_
#define _SENSOR_API_H_
#include "bh_platform.h"
#ifdef __cplusplus
extern "C" {
#endif
uint32
wasm_sensor_open(const char* name, int instance);
bool
wasm_sensor_config(uint32 sensor, int interval, int bit_cfg, int delay);
bool
wasm_sensor_config_with_attr_container(uint32 sensor, char *buffer, int len);
bool
wasm_sensor_close(uint32 sensor);
#ifdef __cplusplus
}
#endif
#endif /* end of _SENSOR_API_H_ */

View File

@ -0,0 +1,92 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#ifndef _AEE_SENSOR_H_
#define _AEE_SENSOR_H_
#include "bi-inc/attr_container.h"
#ifdef __cplusplus
extern "C" {
#endif
/* board producer define sensor */
struct _sensor;
typedef struct _sensor *sensor_t;
/**
* @typedef sensor_event_handler_f
*
* @brief Define the signature of callback function for API
* sensor_open() to handle sensor event.
*
* @param sensor the sensor which the event belong to
* @param sensor_event the sensor event
* @param user_data user data associated with the sensor which is set when
* calling sensor_open().
*
* @see sensor_open
*/
typedef void (*sensor_event_handler_f)(sensor_t sensor,
attr_container_t *sensor_event,
void *user_data);
/*
*****************
* Sensor APIs
*****************
*/
/**
* @brief Open sensor.
*
* @param name sensor name
* @param index sensor index
* @param handler callback function to handle the sensor event
* @param user_data user data
*
* @return the sensor opened if success, NULL otherwise
*/
sensor_t sensor_open(const char* name,
int index,
sensor_event_handler_f handler,
void *user_data);
/**
* @brief Configure sensor with interval/bit_cfg/delay values.
*
* @param sensor the sensor to be configured
* @param interval sensor event interval
* @param bit_cfg sensor bit config
* @param delay sensor delay
*
* @return true if success, false otherwise
*/
bool sensor_config(sensor_t sensor, int interval, int bit_cfg, int delay);
/**
* @brief Configure sensor with attr_container_t object.
*
* @param sensor the sensor to be configured
* @param cfg the configuration
*
* @return true if success, false otherwise
*/
bool sensor_config_with_attr_container(sensor_t sensor, attr_container_t *cfg);
/**
* @brief Close sensor.
*
* @param sensor the sensor to be closed
*
* @return true if success, false otherwise
*/
bool sensor_close(sensor_t sensor);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,11 @@
# Copyright (C) 2019 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
set (WASM_APP_SENSOR_DIR ${CMAKE_CURRENT_LIST_DIR})
include_directories(${WASM_APP_SENSOR_DIR})
file (GLOB_RECURSE source_all ${WASM_APP_SENSOR_DIR}/*.c)
set (WASM_APP_CURRENT_SOURCE ${source_all})