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

@ -1,4 +1,18 @@
WebAssembly Micro Runtime Attributions
======================================
WAMR project reused some components from other open source project:
- **wasmtime**: for the wasi libc implementation
- **cJson**: used in the host_tool for remotely managing wasm applications
- **contiki-ng**: for the coap protocol implementation
- **freebsd libm**: used in core/shared/platform/alios/bh_math.c
- **littlevgl**: for the gui samples and wrapped the wasm graphic layer.
## Licenses
### wasmtime
```
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
@ -217,4 +231,98 @@ conflicts with the conditions of the GPLv2, you may retroactively and
prospectively choose to deem waived or otherwise exclude such Section(s) of
the License, but only in their entirety and only with respect to the Combined
Software.
```
### cJson
```
Copyright (c) 2009-2017 Dave Gamble and cJSON contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
```
### contiki-ng
```
Copyright (c) (Year), (Name of copyright holder) All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
```
### freebsd libm
```
Copyright 1992-2011 The FreeBSD Project. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE FREEBSD PROJECT ``AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FREEBSD PROJECT OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation
are those of the authors and should not be interpreted as representing
official policies, either expressed or implied, of the FreeBSD
Project.
```
### littlevgl
```
MIT licence
Copyright (c) 2016 Gábor Kiss-Vámosi
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
```

220
README.md
View File

@ -1,84 +1,83 @@
WebAssembly Micro Runtime
=========================
[Building WAMR VM core](./doc/build_wamr.md) | [Embedding WAMR VM core](./doc/embed_wamr.md) | [Building WASM applications](./doc/build_wasm_app.md) | [Samples and demos](https://github.com/bytecodealliance/wasm-micro-runtime#samples-and-demos)
**A [Bytecode Alliance][BA] project**
[BA]: https://bytecodealliance.org/
WebAssembly Micro Runtime (WAMR) is a standalone WebAssembly (WASM) runtime with small footprint. It includes a few parts as below:
- A WebAssembly VM core (namely iwasm)
- The supporting API's for the WASM applications
- A mechanism for dynamic management of the WASM application
- The "iwasm" VM core, supporting WebAssembly interpreter, ahead of time compilation (AoT) and Just-in-Time compilation (JIT)
- The application framework and the supporting API's for the WASM applications
- The dynamic management of the WASM applications
Current Features of WAMR
iwasm VM core
=========================
- WASM interpreter (AOT is planned)
- Provides embedding C API
- Provides a mechanism for exporting native API's to WASM applications
- Supports libc for WASM applications in two modes: the built-in libc subset for embedded environment and [WASI](https://github.com/WebAssembly/WASI) for standard libc
- The WASM application framework and asynchronized app programming model
- Supports for micro-service and pub-sub event inter-app communication models
- Supports remote WASM application management from either host or cloud
- Menu configuration for easy integration of application libraries
Application framework architecture
### key features
- Embeddable with the supporting C API's
- Small runtime binary size (85K for interpreter and 50K for AoT) and low memory usage
- Near to native speed by AoT
- AoT module loader works for both embedded OS and Linux system
- Choices of WASM application libc support: the built-in libc subset for embedded environment or [WASI](https://github.com/WebAssembly/WASI) for standard libc
- The mechanism for exporting native API's to WASM applications
### Supported architectures and platforms
The iwasm supports following architectures:
- X86-64, X86-32
- ARM, THUMB
- MIPS
- XTENSA
Following platforms are supported:
- [Linux](./doc/build_wamr.md#linux)
- [Zephyr](./doc/build_wamr.md#zephyr)
- [MacOS](./doc/build_wamr.md#macos)
- [VxWorks](./doc/build_wamr.md#vxworks)
- [AliOS-Things](./doc/build_wamr.md#alios-things)
- [Intel Software Guard Extention (Linux)](./doc/build_wamr.md#linux-sgx-intel-software-guard-extention)
Refer to [WAMR porting guide](./doc/port_wamr.md) for how to port WAMR to a new platform.
### Build wamrc AoT compiler
Execute following commands to build **wamrc** compiler:
```shell
cd wamr-compiler
./build_llvm.sh
mkdir build
cd build
cmake ..
make
```
After build is completed, create a symbolic link **/usr/bin/wamrc** to the generated wamrc.
### Build the mini product
WAMR supports building the iwasm VM core only (no app framework) to the mini product. The WAMR mini product takes the WASM application file name as input, and then executes it. For the detailed procedure, see **[build WAMR VM core](./doc/build_wamr.md)** and **[build and run WASM application](./doc/build_wasm_app.md)**.
### Embed WAMR VM core
WAMR provides a set of C API for loading the WASM module, instantiating the module and invoking a WASM function from a native call. For the details, see [embed WAMR VM core](./doc/embed_wamr.md).
Application framework
===================================
By using the iwasm VM core, we are flexible to build different application frameworks for the specific domains.
By using the iwasm VM core, we are flexible to build different application frameworks for the specific domains, although it would take quite some efforts.
The WAMR has offered a comprehensive application framework for device and IoT usages. The framework solves many common requirements for building a real project:
- Modular design for more language runtimes support
- Inter application communication
- Remote application management
- WASM APP programming model and API extension mechanism
<img src="./doc/pics/wamr-arch.JPG" width="80%">
Build WAMR
==========
## Build WAMR VM core
WAMR VM core (iwasm) can support building for different target platforms:
- Linux
- Zephyr
- MacOS
- VxWorks
- AliOS-Things
- Intel Software Guard Extention (SGX)
See [Build WAMR VM core](./doc/build_wamr.md) for the detailed instructions.
## Libc building options
WAMR supports WASI for standard libc library as well as a [built-in libc subset](./doc/wamr_api.md) for tiny footprint.
WASI is supported for following platforms and enabled by default building:
- Linux
## Embed WAMR VM core
WAMR can be built into a standalone executable which takes the WASM application file name as input, and then executes it. In some other situations, the WAMR source code is embedded the product code and built into the final product.
WAMR provides a set of C API for loading the WASM module, instantiating the module and invoking a WASM function from a native call. See [Embed WAMR VM core](./doc/embed_wamr.md) for the details.
The WAMR application framework supports dynamically installing WASM application remotely by embedding the WAMR VM core. It can be used as reference for how to use the embedding API's.
## Integrate WAMR application library
The WAMR provides an application framework which supports event driven programming model as below:
- Single thread per WASM app instance
- App must implement system callbacks: on_init, on_destroy
Application programming API sets are available as below:
The WAMR has offered a comprehensive framework for programming WASM applications for device and IoT usages. The framework supports running multiple applications, which are based on the event driven programming model. Here are the supporting API sets by the [WAMR application library](./doc/wamr_api.md) :
- Timer
- Micro service (Request/Response) and Pub/Sub inter-app communication
@ -86,51 +85,82 @@ Application programming API sets are available as below:
- Connectivity and data transmission
- 2D graphic UI (based on littlevgl)
See [WAMR application library](./doc/wamr_api.md) for the details.
One WAMR build can select a subset from the WAMR application library. Refer to the sample "simple" for how to integrate API sets into WAMR building.
Every subfolder under [WAMR application framework](./core/app-framework) folder is a compilation configurable component. The developers can copy the template folder to create new components to the application framework. If a component needs to export native functions to the WASM application, refer to the [export_native_api.md](./doc/export_native_api.md) .
## Build WAMR with customized application library
# Remote application management
When WAMR is integrated into a specific project, it probably includes additional project specific applications APIs which can be either expansion or modification to the standard WAMR application library.
The extended application library should be created in the folder [core/iwasm/lib/app-libs](./core/iwasm/lib/app-libs/). See the [doc/export_native_api.md](./doc/export_native_api.md) for the details.
The WAMR application manager supports remote application management from host environment or the cloud through any physical communications such as TCP, UPD, UART, BLE, etc. Its modular design makes it able to support application management for different managed runtimes.
# Create WASM application SDK
<img src="./doc/pics/wamr-arch.JPG" width="80%">
When a customized WAMR runtime is shipped with the products, an associated WASM application SDK should be distributed to the application developers in order to develop WASM applications for the product. At the most time, the WASM application SDK should match the version of the runtime distribution.
Typically a WASM APP SDK package contains following components:
* **WASI-SDK**: only needed when WASI is enabled in the runtime. It can be a link to the WASI-SDK GitHub or the full offline copy.
* **sysroot** folder: only needed when WASI is not enabled in the runtime. copied from [test-tools/toolchain/sysroot](./test-tools/toolchain/sysroot)
* **app-lib** folder: copied from [core/iwasm/lib/app-libs](./core/iwasm/lib/app-libs/)
* **cmake toolchain** file: copied from [test-tools/toolchain/wamr_toolchain.cmake](./test-tools/toolchain/wamr_toolchain.cmake)
* optionally with some guide documents and samples
The tool [host_agent](./test-tools/host-tool) communicates to the WAMR app manager for installing/uninstalling the WASM applications on companion chip from host system. And the [IoT App Store Demo](./test-tools/IoT-APP-Store-Demo/) shows the conception of remotely managing the device applications from cloud.
Build WASM applications
===================================
WAMR SDK
==========
The **wamr-sdk** tools build the WAMR to both **runtime SDK** for embedding by your native codes and **APP SDK** for developing the WASM applications. A SDK profile presents a configuration of build parameters for the selection of CPU arch, software platforms, execution mode, libc and application framework components.
**Note**: [WASI-SDK](https://github.com/CraneStation/wasi-sdk/releases) version 7 and above should be installed before building the WAMR SDK.
### Menu configuration for building SDK
Menu configuration is supported for easy integration of runtime components and application libraries for the target architecture and platform.
```
cd wamr-sdk
./menuconfig.sh
```
<img src="./doc/pics/wamr_menu_config.png" alt="wamr build menu configuration" style="zoom:80%;" />
After the menu configuration is finished, the building process is automatically started. When the building gets successful, the SDK package is generated under folder $wamr-sdk/out/{profile}, and the header files of configured components were copied into the SDK package.
The directory structure of a SDK package with profile name "simple":
```
simple/
├── app-sdk
│   ├── libc-builtin-sysroot
│   │   ├── include
│   │   └── share
│   └── wamr-app-framework
│   ├── include
│   │   ├── bi-inc
│   │   └── wa-inc
│   ├── lib
│   └── share
└── runtime-sdk
├── include
│   └── bi-inc
└── lib
```
The tool **build_sdk.sh** can be also directly executed by passing the configuration arguments, which is how each WAMR sample project builds the WAMR SDK for its own building profile.
### Use Runtime SDK
The folder "**runtime-sdk**" contains all the header files and library files for integration with project native code.
### Build WASM applications with APP-SDK
The folder “**app-sdk**” contains all the header files and WASM library for developing the WASM application. For C/C++ based WASM applications, the developers can use conventional cross-compilation procedure to build the WASM application. Refer to [build WASM applications](./doc/build_wasm_app.md) for the details.
WebAssembly as a new binary instruction can be viewed as a virtual architecture. If the WASM application is developed in C/C++ language, developers can use conventional cross-compilation procedure to build the WASM application. cmake is the recommended building tool and Clang is the preferred compiler. While emcc may still work but it is not guaranteed.
Refer to [Build WASM applications](doc/build_wasm_app.md) for details.
Samples and demos
=================
The WAMR samples are located in folder [./samples](./samples). A sample usually contains the WAMR runtime build, WASM applications and test tools. The WARM provides following samples:
- [Simple](./samples/simple/README.md): The runtime is integrated with most of the WAMR APP libaries and multiple WASM applications are provided for using different WASM API set.
- [littlevgl](./samples/littlevgl/README.md): Demostrating the graphic user interface application usage on WAMR. The whole [LittlevGL](https://github.com/littlevgl/) 2D user graphic library and the UI application is built into WASM application.
- [gui](./samples/gui/README.md): Moved the [LittlevGL](https://github.com/littlevgl/) library into the runtime and defined a WASM application interface by wrapping the littlevgl API.
- [IoT-APP-Store-Demo](./test-tools/IoT-APP-Store-Demo/README.md): A web site for demostrating a WASM APP store usage where we can remotely install and uninstall WASM application on remote devices.
The WAMR samples integrate the iwasm VM core, application manager and selected application framework components. The samples are located in folder [samples](./samples):
- **[Simple](./samples/simple/README.md)**: The runtime is integrated with most of the WAMR APP libraries, and a few WASM applications are provided for testing the WAMR APP API set. It uses **built-in libc** and executes apps in **interpreter** mode by default.
- **[littlevgl](./samples/littlevgl/README.md)**: Demonstrating the graphic user interface application usage on WAMR. The whole [LittlevGL](https://github.com/littlevgl/) 2D user graphic library and the UI application is built into WASM application. It uses **WASI libc** and executes apps in **AoT mode** by default.
- **[gui](./samples/gui/README.md)**: Moved the [LittlevGL](https://github.com/littlevgl/) library into the runtime and defined a WASM application interface by wrapping the littlevgl API. It uses **WASI libc** and executes apps in **interpreter** mode by default.
The graphic user interface demo photo:
@ -138,12 +168,10 @@ The graphic user interface demo photo:
![WAMR samples diagram](./doc/pics/vgl_demo.png "WAMR samples diagram")
Releases and acknowledgments
============================
WAMR is a community efforts. Since Intel Corp contributed the first release of this open source project, this project has received many good contributions from the community.
WAMR is a community effort. Since Intel Corp contributed the first release of this open source project, this project has received many good contributions from the community.
See the [major features releasing history and contributor names](./doc/release_ack.md)

View File

@ -0,0 +1,128 @@
# Copyright (C) 2019 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
string(TOUPPER ${WAMR_BUILD_TARGET} WAMR_BUILD_TARGET)
# Add definitions for the build platform
if (WAMR_BUILD_PLATFORM STREQUAL "linux")
add_definitions(-DBH_PLATFORM_LINUX)
elseif (WAMR_BUILD_PLATFORM STREQUAL "linux-sgx")
add_definitions(-DBH_PLATFORM_LINUX_SGX)
elseif (WAMR_BUILD_PLATFORM STREQUAL "zephyr")
add_definitions(-DBH_PLATFORM_ZEPHYR)
elseif (WAMR_BUILD_PLATFORM STREQUAL "vxworks")
add_definitions(-DBH_PLATFORM_VXWORKS)
elseif (WAMR_BUILD_PLATFORM STREQUAL "darwin")
add_definitions(-DBH_PLATFORM_DARWIN)
elseif (WAMR_BUILD_PLATFORM STREQUAL "alios-things")
add_definitions(-DBH_PLATFORM_ALIOS_THINGS)
else ()
message (WARNING "-- WAMR build platform isn't set")
endif ()
# Add definitions for the build target
if (WAMR_BUILD_TARGET STREQUAL "X86_64")
add_definitions(-DBUILD_TARGET_X86_64)
elseif (WAMR_BUILD_TARGET STREQUAL "AMD_64")
add_definitions(-DBUILD_TARGET_AMD_64)
elseif (WAMR_BUILD_TARGET STREQUAL "X86_32")
add_definitions(-DBUILD_TARGET_X86_32)
elseif (WAMR_BUILD_TARGET MATCHES "ARM.*")
if (WAMR_BUILD_TARGET MATCHES "(ARM.*)_VFP")
add_definitions(-DBUILD_TARGET_ARM_VFP)
add_definitions(-DBUILD_TARGET="${CMAKE_MATCH_1}")
else ()
add_definitions(-DBUILD_TARGET_ARM)
add_definitions(-DBUILD_TARGET="${WAMR_BUILD_TARGET}")
endif ()
elseif (WAMR_BUILD_TARGET MATCHES "THUMB.*")
if (WAMR_BUILD_TARGET MATCHES "(THUMB.*)_VFP")
add_definitions(-DBUILD_TARGET_THUMB_VFP)
add_definitions(-DBUILD_TARGET="${CMAKE_MATCH_1}")
else ()
add_definitions(-DBUILD_TARGET_THUMB)
add_definitions(-DBUILD_TARGET="${WAMR_BUILD_TARGET}")
endif ()
elseif (WAMR_BUILD_TARGET STREQUAL "MIPS")
add_definitions(-DBUILD_TARGET_MIPS)
elseif (WAMR_BUILD_TARGET STREQUAL "XTENSA")
add_definitions(-DBUILD_TARGET_XTENSA)
else ()
message (FATAL_ERROR "-- WAMR build target isn't set")
endif ()
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
if (WAMR_BUILD_TARGET STREQUAL "X86_64" OR WAMR_BUILD_TARGET STREQUAL "AMD_64")
# Add -fPIC flag if build as 64-bit
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_C_FLAGS} -fPIC")
else ()
add_definitions (-m32)
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m32")
set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -m32")
endif ()
endif ()
if (WAMR_BUILD_TARGET MATCHES "ARM.*")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -marm")
elseif (WAMR_BUILD_TARGET MATCHES "THUMB.*")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mthumb")
set (CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -Wa,-mthumb")
endif ()
if (NOT WAMR_BUILD_INTERP EQUAL 1)
if (NOT WAMR_BUILD_AOT EQUAL 1)
message (FATAL_ERROR "-- WAMR Interpreter and AOT must be enabled at least one")
endif ()
endif ()
if (WAMR_BUILD_JIT EQUAL 1)
if (WAMR_BUILD_AOT EQUAL 1)
add_definitions("-DWASM_ENABLE_JIT=1")
set (LLVM_SRC_ROOT "${WAMR_ROOT_DIR}/core/deps/llvm")
if (NOT EXISTS "${LLVM_SRC_ROOT}/build")
message (FATAL_ERROR "Cannot find LLVM dir: ${LLVM_SRC_ROOT}/build")
endif ()
set (CMAKE_PREFIX_PATH "${LLVM_SRC_ROOT}/build;${CMAKE_PREFIX_PATH}")
find_package(LLVM REQUIRED CONFIG)
include_directories(${LLVM_INCLUDE_DIRS})
add_definitions(${LLVM_DEFINITIONS})
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
else ()
set (WAMR_BUILD_JIT 0)
message ("-- WAMR JIT disabled due to WAMR AOT is disabled")
endif ()
else ()
unset (LLVM_AVAILABLE_LIBS)
endif ()
message ("-- Build Configurations:")
message (" Build as target ${WAMR_BUILD_TARGET}")
message (" CMAKE_BUILD_TYPE " ${CMAKE_BUILD_TYPE})
if (WAMR_BUILD_INTERP EQUAL 1)
message (" WAMR Interpreter enabled")
else ()
message (" WAMR Interpreter disbled")
endif ()
if (WAMR_BUILD_AOT EQUAL 1)
message (" WAMR AOT enabled")
else ()
message (" WAMR AOT disbled")
endif ()
if (WAMR_BUILD_JIT EQUAL 1)
message (" WAMR JIT enabled")
else ()
message (" WAMR JIT disbled")
endif ()
if (WAMR_BUILD_LIBC_BUILTIN EQUAL 1)
message (" Libc builtin enabled")
else ()
message (" Libc builtin disbled")
endif ()
if (WAMR_BUILD_LIBC_WASI EQUAL 1)
message (" Libc WASI enabled")
else ()
message (" Libc WASI disbled")
endif ()

View File

@ -0,0 +1,111 @@
# Copyright (C) 2019 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
if (NOT DEFINED WAMR_ROOT_DIR)
set (WAMR_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../)
endif ()
if (NOT DEFINED SHARED_DIR)
set (SHARED_DIR ${WAMR_ROOT_DIR}/core/shared)
endif ()
if (NOT DEFINED IWASM_DIR)
set (IWASM_DIR ${WAMR_ROOT_DIR}/core/iwasm)
endif ()
if (NOT DEFINED APP_MGR_DIR)
set (APP_MGR_DIR ${WAMR_ROOT_DIR}/core/app-mgr)
endif ()
if (NOT DEFINED APP_FRAMEWORK_DIR)
set (APP_FRAMEWORK_DIR ${WAMR_ROOT_DIR}/core/app-framework)
endif ()
if (NOT DEFINED DEPS_DIR)
set (DEPS_DIR ${WAMR_ROOT_DIR}/core/deps)
endif ()
if (DEFINED EXTRA_SDK_INCLUDE_PATH)
message(STATUS, "EXTRA_SDK_INCLUDE_PATH = ${EXTRA_SDK_INCLUDE_PATH} ")
include_directories (
${EXTRA_SDK_INCLUDE_PATH}
)
endif ()
# Set default options
# Set WAMR_BUILD_TARGET, currently values supported:
# "X86_64", "AMD_64", "X86_32", "ARM[sub]", "THUMB[sub]", "MIPS", "XTENSA"
if (NOT DEFINED WAMR_BUILD_TARGET)
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
# Build as X86_64 by default in 64-bit platform
set (WAMR_BUILD_TARGET "X86_64")
else ()
# Build as X86_32 by default in 32-bit platform
set (WAMR_BUILD_TARGET "X86_32")
endif ()
endif ()
################ optional according to settings ################
if (WAMR_BUILD_INTERP EQUAL 1 OR WAMR_BUILD_JIT EQUAL 1)
include (${IWASM_DIR}/interpreter/iwasm_interp.cmake)
endif ()
if (WAMR_BUILD_AOT EQUAL 1)
include (${IWASM_DIR}/aot/iwasm_aot.cmake)
if (WAMR_BUILD_JIT EQUAL 1)
include (${IWASM_DIR}/compilation/iwasm_compl.cmake)
endif ()
endif ()
if (WAMR_BUILD_APP_FRAMEWORK EQUAL 1)
include (${APP_FRAMEWORK_DIR}/app_framework.cmake)
include (${SHARED_DIR}/coap/lib_coap.cmake)
include (${APP_MGR_DIR}/app-manager/app_mgr.cmake)
include (${APP_MGR_DIR}/app-mgr-shared/app_mgr_shared.cmake)
endif ()
if (WAMR_BUILD_LIBC_BUILTIN EQUAL 1)
include (${IWASM_DIR}/libraries/libc-builtin/libc_builtin.cmake)
endif ()
if (WAMR_BUILD_LIBC_WASI EQUAL 1)
include (${IWASM_DIR}/libraries/libc-wasi/libc_wasi.cmake)
endif ()
####################### Common sources #######################
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -ffunction-sections -fdata-sections \
-Wall -Wno-unused-parameter -Wno-pedantic")
# include the build config template file
include (${CMAKE_CURRENT_LIST_DIR}/config_common.cmake)
include_directories (${SHARED_DIR}/include
${IWASM_DIR}/include)
file (GLOB header
${SHARED_DIR}/include/*.h
${IWASM_DIR}/include/*.h
)
LIST (APPEND RUNTIME_LIB_HEADER_LIST ${header})
enable_language (ASM)
include (${SHARED_DIR}/platform/${WAMR_BUILD_PLATFORM}/shared_platform.cmake)
include (${SHARED_DIR}/mem-alloc/mem_alloc.cmake)
include (${IWASM_DIR}/common/iwasm_common.cmake)
include (${SHARED_DIR}/utils/shared_utils.cmake)
set (source_all
${PLATFORM_SHARED_SOURCE}
${MEM_ALLOC_SHARED_SOURCE}
${UTILS_SHARED_SOURCE}
${LIBC_BUILTIN_SOURCE}
${LIBC_WASI_SOURCE}
${IWASM_COMMON_SOURCE}
${IWASM_INTERP_SOURCE}
${IWASM_AOT_SOURCE}
${IWASM_COMPL_SOURCE}
${WASM_APP_LIB_SOURCE_ALL}
${NATIVE_INTERFACE_SOURCE}
${APP_MGR_SOURCE}
)
set (WAMR_RUNTIME_LIB_SOURCE ${source_all})

View File

@ -0,0 +1,11 @@
Notes:
=======
This folder is for the source files shared by both WASM APP and native runtime
- The c files in this directory are compiled into both the WASM APP and runtime.
- The header files for distributing to SDK are placed in the "bi-inc" folder.

View File

@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#include "attr_container.h"
#include "bi-inc/attr_container.h"
typedef union jvalue {
bool z;

View File

@ -145,9 +145,7 @@ unpack_response(char * packet, int size, response_t * response);
void
free_req_resp_packet(char * packet);
#if WASM_ENABLE_GUI != 0
#include "wgl_shared_utils.h"
#endif
#ifdef __cplusplus
}

View File

@ -6,15 +6,19 @@
#ifndef WAMR_GRAPHIC_LIBRARY_SHARED_UTILS_H
#define WAMR_GRAPHIC_LIBRARY_SHARED_UTILS_H
#include "bh_platform.h"
#ifdef __cplusplus
extern "C" {
#endif
#include <stdbool.h>
#include "../3rdparty/lv_conf.h"
#include "lv_conf.h"
typedef lv_coord_t wgl_coord_t; /* lv_coord_t is defined in lv_conf.h */
typedef void * wgl_font_user_data_t;
/**
* Represents a point on the screen.

View File

@ -10,3 +10,6 @@ file (GLOB_RECURSE source_all ${NATIVE_INTERFACE_DIR}/*.c)
set (NATIVE_INTERFACE_SOURCE ${source_all})
set (WASM_APP_BI_INC_DIR "${NATIVE_INTERFACE_DIR}/bi-inc")
LIST (APPEND RUNTIME_LIB_HEADER_LIST "${NATIVE_INTERFACE_DIR}/native_interface.h")

View File

@ -11,6 +11,9 @@
#include "bh_platform.h"
#include "wasm_export.h"
#define get_module_inst(exec_env) \
wasm_runtime_get_module_inst(exec_env)
#define validate_app_addr(offset, size) \
wasm_runtime_validate_app_addr(module_inst, offset, size)
@ -36,16 +39,16 @@
*/
bool
wasm_response_send(wasm_module_inst_t module_inst,
wasm_response_send(wasm_exec_env_t exec_env,
int32 buffer_offset, int size);
void
wasm_register_resource(wasm_module_inst_t module_inst,
wasm_register_resource(wasm_exec_env_t exec_env,
int32 url_offset);
void
wasm_post_request(wasm_module_inst_t module_inst,
wasm_post_request(wasm_exec_env_t exec_env,
int32 buffer_offset, int size);
void
wasm_sub_event(wasm_module_inst_t module_inst,
wasm_sub_event(wasm_exec_env_t exec_env,
int32 url_offset);
/*
@ -53,17 +56,17 @@ wasm_sub_event(wasm_module_inst_t module_inst,
*/
bool
wasm_sensor_config(wasm_module_inst_t module_inst,
wasm_sensor_config(wasm_exec_env_t exec_env,
uint32 sensor, int interval, int bit_cfg, int delay);
uint32
wasm_sensor_open(wasm_module_inst_t module_inst,
wasm_sensor_open(wasm_exec_env_t exec_env,
int32 name_offset, int instance);
bool
wasm_sensor_config_with_attr_container(wasm_module_inst_t module_inst,
wasm_sensor_config_with_attr_container(wasm_exec_env_t exec_env,
uint32 sensor,
int32 buffer_offset, int len);
bool
wasm_sensor_close(wasm_module_inst_t module_inst,
wasm_sensor_close(wasm_exec_env_t exec_env,
uint32 sensor);
/*
@ -73,33 +76,33 @@ wasm_sensor_close(wasm_module_inst_t module_inst,
typedef unsigned int timer_id_t;
timer_id_t
wasm_create_timer(wasm_module_inst_t module_inst,
wasm_create_timer(wasm_exec_env_t exec_env,
int interval, bool is_period, bool auto_start);
void
wasm_timer_destroy(wasm_module_inst_t module_inst, timer_id_t timer_id);
wasm_timer_destroy(wasm_exec_env_t exec_env, timer_id_t timer_id);
void
wasm_timer_cancel(wasm_module_inst_t module_inst, timer_id_t timer_id);
wasm_timer_cancel(wasm_exec_env_t exec_env, timer_id_t timer_id);
void
wasm_timer_restart(wasm_module_inst_t module_inst,
wasm_timer_restart(wasm_exec_env_t exec_env,
timer_id_t timer_id, int interval);
uint32
wasm_get_sys_tick_ms(wasm_module_inst_t module_inst);
wasm_get_sys_tick_ms(wasm_exec_env_t exec_env);
/*
* connection interfaces
*/
uint32
wasm_open_connection(wasm_module_inst_t module_inst,
wasm_open_connection(wasm_exec_env_t exec_env,
int32 name_offset, int32 args_offset, uint32 len);
void
wasm_close_connection(wasm_module_inst_t module_inst,
wasm_close_connection(wasm_exec_env_t exec_env,
uint32 handle);
int
wasm_send_on_connection(wasm_module_inst_t module_inst,
wasm_send_on_connection(wasm_exec_env_t exec_env,
uint32 handle, int32 data_offset, uint32 len);
bool
wasm_config_connection(wasm_module_inst_t module_inst,
wasm_config_connection(wasm_exec_env_t exec_env,
uint32 handle, int32 cfg_offset, uint32 len);
/**
@ -107,23 +110,23 @@ wasm_config_connection(wasm_module_inst_t module_inst,
*/
void
wasm_obj_native_call(wasm_module_inst_t module_inst,
wasm_obj_native_call(wasm_exec_env_t exec_env,
int32 func_id, uint32 argv_offset, uint32 argc);
void
wasm_btn_native_call(wasm_module_inst_t module_inst,
wasm_btn_native_call(wasm_exec_env_t exec_env,
int32 func_id, uint32 argv_offset, uint32 argc);
void
wasm_label_native_call(wasm_module_inst_t module_inst,
wasm_label_native_call(wasm_exec_env_t exec_env,
int32 func_id, uint32 argv_offset, uint32 argc);
void
wasm_cb_native_call(wasm_module_inst_t module_inst,
wasm_cb_native_call(wasm_exec_env_t exec_env,
int32 func_id, uint32 argv_offset, uint32 argc);
void
wasm_list_native_call(wasm_module_inst_t module_inst,
wasm_list_native_call(wasm_exec_env_t exec_env,
int32 func_id, uint32 argv_offset, uint32 argc);
#endif /* end of _NATIVE_INTERFACE_H */

View File

@ -8,7 +8,7 @@
#include <stdbool.h>
#include <stdio.h>
#include "shared_utils.h"
#include "bi-inc/shared_utils.h"
/* Serialization of request and response message
*

View File

@ -0,0 +1,86 @@
# Copyright (C) 2019 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
set (APP_FRAMEWORK_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR})
# app-native-shared and base are required
include (${APP_FRAMEWORK_ROOT_DIR}/app-native-shared/native_interface.cmake)
LIST (APPEND WASM_APP_SOURCE_ALL ${NATIVE_INTERFACE_SOURCE})
MACRO(SUBDIRLIST result curdir)
FILE(GLOB children RELATIVE ${curdir} ${curdir}/*)
SET(dirlist "")
FOREACH(child ${children})
IF(IS_DIRECTORY ${curdir}/${child})
LIST(APPEND dirlist ${child})
ENDIF()
ENDFOREACH()
SET(${result} ${dirlist})
ENDMACRO()
function (add_module_native arg)
message ("Add native module ${ARGV0}")
include (${APP_FRAMEWORK_ROOT_DIR}/${ARGV0}/native/wasm_lib.cmake)
file (GLOB header
${APP_FRAMEWORK_ROOT_DIR}/${ARGV0}/native/*.h
${APP_FRAMEWORK_ROOT_DIR}/${ARGV0}/native/*.inl
)
LIST (APPEND RUNTIME_LIB_HEADER_LIST ${header})
set (RUNTIME_LIB_HEADER_LIST ${RUNTIME_LIB_HEADER_LIST} PARENT_SCOPE)
LIST (APPEND WASM_APP_LIB_SOURCE_ALL ${WASM_APP_LIB_CURRENT_SOURCE})
set (WASM_APP_LIB_SOURCE_ALL ${WASM_APP_LIB_SOURCE_ALL} PARENT_SCOPE)
# VARIABLES in function are only used in this scope,
# set PARENT_SCOPE to pass to top CMakeLists
set (WASM_LIB_BASE_SOURCE ${WASM_LIB_BASE_SOURCE} PARENT_SCOPE)
endfunction ()
function (add_module_app arg)
message ("Add app module ${ARGV0}")
include (${APP_FRAMEWORK_ROOT_DIR}/${ARGV0}/app/wasm_app.cmake)
LIST (APPEND WASM_APP_WA_INC_DIR_LIST "${APP_FRAMEWORK_ROOT_DIR}/${ARGV0}/app/wa-inc")
set (WASM_APP_WA_INC_DIR_LIST ${WASM_APP_WA_INC_DIR_LIST} PARENT_SCOPE)
LIST (APPEND WASM_APP_NAME ${ARGV0})
set (WASM_APP_NAME ${WASM_APP_NAME} PARENT_SCOPE)
LIST (APPEND WASM_APP_SOURCE_ALL ${WASM_APP_CURRENT_SOURCE})
set (WASM_APP_SOURCE_ALL ${WASM_APP_SOURCE_ALL} PARENT_SCOPE)
endfunction ()
if ("${WAMR_BUILD_APP_LIST}" STREQUAL "WAMR_APP_BUILD_ALL")
# add all modules under this folder
SUBDIRLIST(SUBDIRS ${APP_FRAMEWORK_ROOT_DIR})
FOREACH(subdir ${SUBDIRS})
if ("${subdir}" STREQUAL "app-native-shared")
continue()
endif ()
if ("${subdir}" STREQUAL "template")
continue()
endif ()
if ( NOT DEFINED APP_FRAMEWORK_INCLUDE_TYPE )
add_module_native (${subdir})
else ()
add_module_app (${subdir})
endif ()
ENDFOREACH()
else ()
# add each module in the list
FOREACH (dir IN LISTS WAMR_BUILD_APP_LIST)
string(REPLACE "WAMR_APP_BUILD_" "" dir ${dir})
string(TOLOWER ${dir} dir)
if ( NOT DEFINED APP_FRAMEWORK_INCLUDE_TYPE )
add_module_native (${dir})
else ()
add_module_app (${dir})
endif ()
ENDFOREACH (dir)
endif()

View File

@ -3,9 +3,10 @@
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#include "attr_container.h"
#include "request.h"
#include "shared_utils.h"
#include "bi-inc/attr_container.h"
#include "wa-inc/request.h"
#include "wa-inc/timer_wasm_app.h"
#include "bi-inc/shared_utils.h"
#include "wasm_app.h"
#include "req_resp_api.h"
#include "timer_api.h"

View File

@ -6,7 +6,7 @@
#include <stdlib.h>
#include <string.h>
#include "timer_wasm_app.h"
#include "wa-inc/timer_wasm_app.h"
#include "timer_api.h"
#if 1

View File

@ -6,12 +6,59 @@
#ifndef _AEE_REQUEST_H_
#define _AEE_REQUEST_H_
#include "shared_utils.h"
#include "bi-inc/shared_utils.h"
#ifdef __cplusplus
extern "C" {
#endif
/* CoAP request method codes */
typedef enum {
COAP_GET = 1,
COAP_POST,
COAP_PUT,
COAP_DELETE,
COAP_EVENT = (COAP_DELETE + 2)
} coap_method_t;
/* CoAP response codes */
typedef enum {
NO_ERROR = 0,
CREATED_2_01 = 65, /* CREATED */
DELETED_2_02 = 66, /* DELETED */
VALID_2_03 = 67, /* NOT_MODIFIED */
CHANGED_2_04 = 68, /* CHANGED */
CONTENT_2_05 = 69, /* OK */
CONTINUE_2_31 = 95, /* CONTINUE */
BAD_REQUEST_4_00 = 128, /* BAD_REQUEST */
UNAUTHORIZED_4_01 = 129, /* UNAUTHORIZED */
BAD_OPTION_4_02 = 130, /* BAD_OPTION */
FORBIDDEN_4_03 = 131, /* FORBIDDEN */
NOT_FOUND_4_04 = 132, /* NOT_FOUND */
METHOD_NOT_ALLOWED_4_05 = 133, /* METHOD_NOT_ALLOWED */
NOT_ACCEPTABLE_4_06 = 134, /* NOT_ACCEPTABLE */
PRECONDITION_FAILED_4_12 = 140, /* BAD_REQUEST */
REQUEST_ENTITY_TOO_LARGE_4_13 = 141, /* REQUEST_ENTITY_TOO_LARGE */
UNSUPPORTED_MEDIA_TYPE_4_15 = 143, /* UNSUPPORTED_MEDIA_TYPE */
INTERNAL_SERVER_ERROR_5_00 = 160, /* INTERNAL_SERVER_ERROR */
NOT_IMPLEMENTED_5_01 = 161, /* NOT_IMPLEMENTED */
BAD_GATEWAY_5_02 = 162, /* BAD_GATEWAY */
SERVICE_UNAVAILABLE_5_03 = 163, /* SERVICE_UNAVAILABLE */
GATEWAY_TIMEOUT_5_04 = 164, /* GATEWAY_TIMEOUT */
PROXYING_NOT_SUPPORTED_5_05 = 165, /* PROXYING_NOT_SUPPORTED */
/* Erbium errors */
MEMORY_ALLOCATION_ERROR = 192, PACKET_SERIALIZATION_ERROR,
/* Erbium hooks */
MANUAL_RESPONSE, PING_RESPONSE
} coap_status_t;
/**
* @typedef request_handler_f
*

View File

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

View File

@ -3,19 +3,19 @@
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#ifndef _WASM_DLFCN_H
#define _WASM_DLFCN_H
#ifndef _LIB_AEE_H_
#define _LIB_AEE_H_
#include "bi-inc/shared_utils.h"
#include "bi-inc/attr_container.h"
#ifdef __cplusplus
extern "C" {
#endif
void *
wasm_dlsym(void *handle, const char *symbol);
#ifdef __cplusplus
}
#endif
#endif /* end of _WASM_DLFCN_H */
#endif /* end of _LIB_AEE_H_ */

View File

@ -7,16 +7,11 @@
#include <stdlib.h>
#include <string.h>
#include "lib_export.h"
#ifdef WASM_ENABLE_BASE_LIB
#include "base_lib_export.h"
#endif
static NativeSymbol extended_native_symbol_defs[] = {
/* TODO: use macro EXPORT_WASM_API() or EXPORT_WASM_API2() to
add functions to register. */
#ifdef WASM_ENABLE_BASE_LIB
EXPORT_WASM_API(wasm_register_resource),
EXPORT_WASM_API(wasm_response_send),
EXPORT_WASM_API(wasm_post_request),
@ -26,7 +21,6 @@ static NativeSymbol extended_native_symbol_defs[] = {
EXPORT_WASM_API(wasm_timer_cancel),
EXPORT_WASM_API(wasm_timer_restart),
EXPORT_WASM_API(wasm_get_sys_tick_ms),
#endif
};
int get_base_lib_export_apis(NativeSymbol **p_base_lib_apis)

View File

@ -6,7 +6,7 @@
#ifndef _BASE_LIB_EXPORT_H_
#define _BASE_LIB_EXPORT_H_
#include "attr_container.h"
#include "bi-inc/attr_container.h"
#include "native_interface.h"
#endif /* end of _BASE_LIB_EXPORT_H_ */

View File

@ -0,0 +1,32 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#ifndef _REQ_RESP_API_H_
#define _REQ_RESP_API_H_
#include "bh_platform.h"
#ifdef __cplusplus
extern "C" {
#endif
bool
wasm_response_send(int32 buf_offset, int size);
void
wasm_register_resource(int32 url_offset);
void
wasm_post_request(int32 buf_offset, int size);
void
wasm_sub_event(int32 url_offset);
#ifdef __cplusplus
}
#endif
#endif /* end of _REQ_RESP_API_H_ */

View File

@ -11,9 +11,10 @@
extern void module_request_handler(request_t *request, void *user_data);
bool
wasm_response_send(wasm_module_inst_t module_inst,
wasm_response_send(wasm_exec_env_t exec_env,
int32 buffer_offset, int size)
{
wasm_module_inst_t module_inst = get_module_inst(exec_env);
char *buffer = NULL;
if (!validate_app_addr(buffer_offset, size))
@ -36,8 +37,9 @@ wasm_response_send(wasm_module_inst_t module_inst,
}
void
wasm_register_resource(wasm_module_inst_t module_inst, int32 url_offset)
wasm_register_resource(wasm_exec_env_t exec_env, int32 url_offset)
{
wasm_module_inst_t module_inst = get_module_inst(exec_env);
char *url = NULL;
if (!validate_app_str_addr(url_offset))
@ -54,9 +56,10 @@ wasm_register_resource(wasm_module_inst_t module_inst, int32 url_offset)
}
void
wasm_post_request(wasm_module_inst_t module_inst,
wasm_post_request(wasm_exec_env_t exec_env,
int32 buffer_offset, int size)
{
wasm_module_inst_t module_inst = get_module_inst(exec_env);
char *buffer = NULL;
if (!validate_app_addr(buffer_offset, size))
@ -88,8 +91,9 @@ wasm_post_request(wasm_module_inst_t module_inst,
}
void
wasm_sub_event(wasm_module_inst_t module_inst, int32 url_offset)
wasm_sub_event(wasm_exec_env_t exec_env, int32 url_offset)
{
wasm_module_inst_t module_inst = get_module_inst(exec_env);
char *url = NULL;
if (!validate_app_str_addr(url_offset))

View File

@ -0,0 +1,37 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#ifndef _TIMER_API_H_
#define _TIMER_API_H_
#include "bh_platform.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef unsigned int timer_id_t;
timer_id_t
wasm_create_timer(int interval, bool is_period, bool auto_start);
void
wasm_timer_destroy(timer_id_t timer_id);
void
wasm_timer_cancel(timer_id_t timer_id);
void
wasm_timer_restart(timer_id_t timer_id, int interval);
uint32
wasm_get_sys_tick_ms(void);
#ifdef __cplusplus
}
#endif
#endif /* end of _TIMER_API_H_ */

View File

@ -149,34 +149,38 @@ timer_ctx_t get_wasm_timer_ctx(wasm_module_inst_t module_inst)
}
timer_id_t
wasm_create_timer(wasm_module_inst_t module_inst,
wasm_create_timer(wasm_exec_env_t exec_env,
int interval, bool is_period, bool auto_start)
{
wasm_module_inst_t module_inst = get_module_inst(exec_env);
timer_ctx_t timer_ctx = get_wasm_timer_ctx(module_inst);
bh_assert(timer_ctx);
return sys_create_timer(timer_ctx, interval, is_period, auto_start);
}
void
wasm_timer_destroy(wasm_module_inst_t module_inst, timer_id_t timer_id)
wasm_timer_destroy(wasm_exec_env_t exec_env, timer_id_t timer_id)
{
wasm_module_inst_t module_inst = get_module_inst(exec_env);
timer_ctx_t timer_ctx = get_wasm_timer_ctx(module_inst);
bh_assert(timer_ctx);
sys_timer_destroy(timer_ctx, timer_id);
}
void
wasm_timer_cancel(wasm_module_inst_t module_inst, timer_id_t timer_id)
wasm_timer_cancel(wasm_exec_env_t exec_env, timer_id_t timer_id)
{
wasm_module_inst_t module_inst = get_module_inst(exec_env);
timer_ctx_t timer_ctx = get_wasm_timer_ctx(module_inst);
bh_assert(timer_ctx);
sys_timer_cancel(timer_ctx, timer_id);
}
void
wasm_timer_restart(wasm_module_inst_t module_inst,
wasm_timer_restart(wasm_exec_env_t exec_env,
timer_id_t timer_id, int interval)
{
wasm_module_inst_t module_inst = get_module_inst(exec_env);
timer_ctx_t timer_ctx = get_wasm_timer_ctx(module_inst);
bh_assert(timer_ctx);
sys_timer_restart(timer_ctx, timer_id, interval);
@ -185,7 +189,7 @@ wasm_timer_restart(wasm_module_inst_t module_inst,
extern uint32 get_sys_tick_ms();
uint32
wasm_get_sys_tick_ms(wasm_module_inst_t module_inst)
wasm_get_sys_tick_ms(wasm_exec_env_t exec_env)
{
return (uint32) bh_get_tick_ms();
}

View File

@ -3,10 +3,11 @@
set (WASM_LIB_BASE_DIR ${CMAKE_CURRENT_LIST_DIR})
include_directories(${WASM_LIB_BASE_DIR})
add_definitions (-DWASM_ENABLE_BASE_LIB)
include_directories(${WASM_LIB_BASE_DIR})
file (GLOB_RECURSE source_all ${WASM_LIB_BASE_DIR}/*.c)
set (WASM_LIB_BASE_SOURCE ${source_all})
set (WASM_APP_LIB_CURRENT_SOURCE ${source_all})

View File

@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#include "connection.h"
#include "wa-inc/connection.h"
#include "connection_api.h"
/* Raw connection structure */

View File

@ -6,7 +6,7 @@
#ifndef _CONNECTION_H_
#define _CONNECTION_H_
#include "attr_container.h"
#include "bi-inc/attr_container.h"
#ifdef __cplusplus
extern "C" {

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_CONN_DIR ${CMAKE_CURRENT_LIST_DIR})
include_directories(${WASM_APP_CONN_DIR})
file (GLOB source_all ${WASM_APP_CONN_DIR}/*.c)
set (WASM_APP_CURRENT_SOURCE ${source_all})

View File

@ -0,0 +1,32 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#ifndef CONNECTION_API_H_
#define CONNECTION_API_H_
#include "bh_platform.h"
#ifdef __cplusplus
extern "C" {
#endif
uint32
wasm_open_connection(int32 name_offset, int32 args_buf_offset, uint32 args_buf_len);
void
wasm_close_connection(uint32 handle);
int
wasm_send_on_connection(uint32 handle, int32 data_offset, uint32 data_len);
bool
wasm_config_connection(uint32 handle, int32 cfg_buf_offset, uint32 cfg_buf_len);
#ifdef __cplusplus
}
#endif
#endif /* end of CONNECTION_API_H_ */

View File

@ -6,7 +6,7 @@
#ifndef CONNECTION_LIB_H_
#define CONNECTION_LIB_H_
#include "attr_container.h"
#include "bi-inc/attr_container.h"
#include "wasm_export.h"
#ifdef __cplusplus

View File

@ -13,9 +13,10 @@
*/
uint32
wasm_open_connection(wasm_module_inst_t module_inst,
wasm_open_connection(wasm_exec_env_t exec_env,
int32 name_offset, int32 args_offset, uint32 len)
{
wasm_module_inst_t module_inst = get_module_inst(exec_env);
attr_container_t *args;
char *name, *args_buf;
@ -34,16 +35,17 @@ wasm_open_connection(wasm_module_inst_t module_inst,
}
void
wasm_close_connection(wasm_module_inst_t module_inst, uint32 handle)
wasm_close_connection(wasm_exec_env_t exec_env, uint32 handle)
{
if (connection_impl._close != NULL)
connection_impl._close(handle);
}
int
wasm_send_on_connection(wasm_module_inst_t module_inst,
wasm_send_on_connection(wasm_exec_env_t exec_env,
uint32 handle, int32 data_offset, uint32 len)
{
wasm_module_inst_t module_inst = get_module_inst(exec_env);
char *data;
if (!validate_app_addr(data_offset, len) ||
@ -57,9 +59,10 @@ wasm_send_on_connection(wasm_module_inst_t module_inst,
}
bool
wasm_config_connection(wasm_module_inst_t module_inst,
wasm_config_connection(wasm_exec_env_t exec_env,
uint32 handle, int32 cfg_offset, uint32 len)
{
wasm_module_inst_t module_inst = get_module_inst(exec_env);
char *cfg_buf;
attr_container_t *cfg;

View File

@ -480,7 +480,7 @@ void app_mgr_connection_event_callback(module_data *m_data, bh_message_t msg)
uint32 argv[3];
wasm_function_inst_t func_on_conn_data;
bh_assert(CONNECTION_EVENT_WASM == bh_message_type(msg));
wasm_data *wasm_app_data = (wasm_data*) m_data->internal_data;
wasm_data *wasm_app_data = (wasm_data*)m_data->internal_data;
wasm_module_inst_t inst = wasm_app_data->wasm_module_inst;
connection_event_t *conn_event
= (connection_event_t *)bh_message_payload(msg);
@ -491,8 +491,11 @@ void app_mgr_connection_event_callback(module_data *m_data, bh_message_t msg)
func_on_conn_data = wasm_runtime_lookup_function(inst, "_on_connection_data",
"(i32i32i32)");
if (!func_on_conn_data)
func_on_conn_data = wasm_runtime_lookup_function(inst, "on_connection_data",
"(i32i32i32)");
if (!func_on_conn_data) {
printf("Cannot find function _on_connection_data\n");
printf("Cannot find function on_connection_data\n");
return;
}
@ -501,7 +504,8 @@ void app_mgr_connection_event_callback(module_data *m_data, bh_message_t msg)
argv[0] = conn_event->handle;
argv[1] = 0;
argv[2] = 0;
if (!wasm_runtime_call_wasm(inst, NULL, func_on_conn_data, 3, argv)) {
if (!wasm_runtime_call_wasm(wasm_app_data->exec_env, func_on_conn_data,
3, argv)) {
const char *exception = wasm_runtime_get_exception(inst);
bh_assert(exception);
printf(":Got exception running wasm code: %s\n",
@ -526,7 +530,8 @@ void app_mgr_connection_event_callback(module_data *m_data, bh_message_t msg)
argv[0] = conn_event->handle;
argv[1] = (uint32) data_offset;
argv[2] = conn_event->len;
if (!wasm_runtime_call_wasm(inst, NULL, func_on_conn_data, 3, argv)) {
if (!wasm_runtime_call_wasm(wasm_app_data->exec_env, func_on_conn_data,
3, argv)) {
const char *exception = wasm_runtime_get_exception(inst);
bh_assert(exception);
printf(":Got exception running wasm code: %s\n",

View File

@ -5,8 +5,11 @@ set (WASM_LIB_CONN_DIR ${CMAKE_CURRENT_LIST_DIR})
include_directories(${WASM_LIB_CONN_DIR})
include (${CMAKE_CURRENT_LIST_DIR}/${WAMR_BUILD_PLATFORM}/connection_mgr.cmake)
file (GLOB source_all ${WASM_LIB_CONN_DIR}/*.c)
set (WASM_LIB_CONN_SOURCE ${source_all})
file (GLOB source_all
${WASM_LIB_CONN_MGR_SOURCE}
${WASM_LIB_CONN_DIR}/*.c
)
set (WASM_APP_LIB_CURRENT_SOURCE ${source_all})

View File

@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#include "sensor.h"
#include "wa-inc/sensor.h"
#include "sensor_api.h"
typedef struct _sensor {

View File

@ -6,7 +6,7 @@
#ifndef _AEE_SENSOR_H_
#define _AEE_SENSOR_H_
#include "attr_container.h"
#include "bi-inc/attr_container.h"
#ifdef __cplusplus
extern "C" {

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})

View File

@ -88,10 +88,11 @@ wasm_sensor_callback(void *client, uint32 sensor_id, void *user_data)
}
bool
wasm_sensor_config(wasm_module_inst_t module_inst,
wasm_sensor_config(wasm_exec_env_t exec_env,
uint32 sensor, int interval,
int bit_cfg, int delay)
{
wasm_module_inst_t module_inst = get_module_inst(exec_env);
attr_container_t * attr_cont;
sensor_client_t * c;
sensor_obj_t s = find_sys_sensor_id(sensor);
@ -133,9 +134,10 @@ wasm_sensor_config(wasm_module_inst_t module_inst,
}
uint32
wasm_sensor_open(wasm_module_inst_t module_inst,
wasm_sensor_open(wasm_exec_env_t exec_env,
int32 name_offset, int instance)
{
wasm_module_inst_t module_inst = get_module_inst(exec_env);
char *name = NULL;
if (!validate_app_str_addr(name_offset))
@ -189,10 +191,11 @@ wasm_sensor_open(wasm_module_inst_t module_inst,
}
bool
wasm_sensor_config_with_attr_container(wasm_module_inst_t module_inst,
wasm_sensor_config_with_attr_container(wasm_exec_env_t exec_env,
uint32 sensor, int32 buffer_offset,
int len)
{
wasm_module_inst_t module_inst = get_module_inst(exec_env);
char *buffer = NULL;
if (!validate_app_addr(buffer_offset, len))
@ -216,8 +219,9 @@ wasm_sensor_config_with_attr_container(wasm_module_inst_t module_inst,
}
bool
wasm_sensor_close(wasm_module_inst_t module_inst, uint32 sensor)
wasm_sensor_close(wasm_exec_env_t exec_env, uint32 sensor)
{
wasm_module_inst_t module_inst = get_module_inst(exec_env);
unsigned int mod_id = app_manager_get_module_id(Module_WASM_App,
module_inst);
unsigned int client_id = mod_id;

View File

@ -7,7 +7,7 @@
#define LIB_EXTENSION_RUNTIME_SENSOR_H_
#include "bh_platform.h"
#include "attr_container.h"
#include "bi-inc/attr_container.h"
#include "wasm_export.h"
struct _sys_sensor;
@ -51,19 +51,19 @@ int check_sensor_timers();
void reschedule_sensor_read();
uint32
wasm_sensor_open(wasm_module_inst_t module_inst,
wasm_sensor_open(wasm_exec_env_t exec_env,
int32 name_offset, int instance);
bool
wasm_sensor_config(wasm_module_inst_t module_inst,
wasm_sensor_config(wasm_exec_env_t exec_env,
uint32 sensor, int interval, int bit_cfg, int delay);
bool
wasm_sensor_config_with_attr_container(wasm_module_inst_t module_inst,
wasm_sensor_config_with_attr_container(wasm_exec_env_t exec_env,
uint32 sensor, int32 buffer_offset,
int len);
bool
wasm_sensor_close(wasm_module_inst_t module_inst, uint32 sensor);
wasm_sensor_close(wasm_exec_env_t exec_env, uint32 sensor);
#endif /* LIB_EXTENSION_RUNTIME_SENSOR_H_ */

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(int32 name_offset, int instance);
bool
wasm_sensor_config(uint32 sensor, int interval, int bit_cfg, int delay);
bool
wasm_sensor_config_with_attr_container(uint32 sensor, int32 buffer_offset, int len);
bool
wasm_sensor_close(uint32 sensor);
#ifdef __cplusplus
}
#endif
#endif /* end of _SENSOR_API_H_ */

View File

@ -7,7 +7,7 @@
#include "bh_queue.h"
#include "bh_thread.h"
#include "runtime_sensor.h"
#include "attr_container.h"
#include "bi-inc/attr_container.h"
#include "module_wasm_app.h"
#include "wasm_export.h"
@ -27,7 +27,7 @@ void app_mgr_sensor_event_callback(module_data *m_data, bh_message_t msg)
wasm_function_inst_t func_onSensorEvent;
bh_assert(SENSOR_EVENT_WASM == bh_message_type(msg));
wasm_data *wasm_app_data = (wasm_data*) m_data->internal_data;
wasm_data *wasm_app_data = (wasm_data*)m_data->internal_data;
wasm_module_inst_t inst = wasm_app_data->wasm_module_inst;
sensor_event_data_t *payload = (sensor_event_data_t*)
@ -37,8 +37,11 @@ void app_mgr_sensor_event_callback(module_data *m_data, bh_message_t msg)
func_onSensorEvent = wasm_runtime_lookup_function(inst, "_on_sensor_event",
"(i32i32i32)");
if (!func_onSensorEvent)
func_onSensorEvent = wasm_runtime_lookup_function(inst, "on_sensor_event",
"(i32i32i32)");
if (!func_onSensorEvent) {
printf("Cannot find function onRequest\n");
printf("Cannot find function on_sensor_event\n");
} else {
int32 sensor_data_offset;
uint32 sensor_data_len;
@ -66,7 +69,8 @@ void app_mgr_sensor_event_callback(module_data *m_data, bh_message_t msg)
argv[1] = (uint32) sensor_data_offset;
argv[2] = sensor_data_len;
if (!wasm_runtime_call_wasm(inst, NULL, func_onSensorEvent, 3, argv)) {
if (!wasm_runtime_call_wasm(wasm_app_data->exec_env, func_onSensorEvent,
3, argv)) {
const char *exception = wasm_runtime_get_exception(inst);
bh_assert(exception);
printf(":Got exception running wasm code: %s\n",

View File

@ -8,5 +8,5 @@ include_directories(${WASM_LIB_SENSOR_DIR})
file (GLOB_RECURSE source_all ${WASM_LIB_SENSOR_DIR}/*.c)
set (WASM_LIB_SENSOR_SOURCE ${source_all})
set (WASM_APP_LIB_CURRENT_SOURCE ${source_all})

View File

@ -3,10 +3,6 @@
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#ifndef _WASM_CONFIG_H
#define _WASM_CONFIG_H
#include "config.h"
#endif /* end of _WASM_CONFIG_H */
/*
header file for wasm application
*/

View File

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

View File

@ -0,0 +1,6 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
/* EXPORT_WASM_API(your_api_here), */

View File

@ -0,0 +1,17 @@
# Copyright (C) 2019 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
set (WASM_LIB_CURRENT_DIR ${CMAKE_CURRENT_LIST_DIR})
include_directories(
${WASM_LIB_CURRENT_DIR}
# Add your include dir here
)
file (GLOB_RECURSE source_all
${WASM_LIB_CURRENT_DIR}/*.c
# Add your source file here
)
set (WASM_APP_LIB_CURRENT_SOURCE ${source_all})

View File

@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#include "wgl.h"
#include "wa-inc/wgl.h"
#include "bh_platform.h"
#include "gui_api.h"

View File

@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#include "wgl.h"
#include "wa-inc/wgl.h"
#include "gui_api.h"
#include <string.h>

View File

@ -4,7 +4,7 @@
*/
#include "wgl.h"
#include "wa-inc/wgl.h"
#include "gui_api.h"
#include <string.h>

View File

@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#include "wgl.h"
#include "wa-inc/wgl.h"
#include "gui_api.h"
#include <string.h>

View File

@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#include "wgl.h"
#include "wa-inc/wgl.h"
#include "gui_api.h"
#include <stdlib.h>
#include <string.h>

View File

@ -10,7 +10,7 @@
extern "C" {
#endif
#include "wgl_shared_utils.h" /* shared types between app and native */
#include "bi-inc/wgl_shared_utils.h" /* shared types between app and native */
#include "lvgl-compatible/lv_types.h"
#include "lvgl-compatible/lv_obj.h"
#include "lvgl-compatible/lv_btn.h"

View File

@ -10,7 +10,7 @@
extern "C" {
#endif
#include "wgl_shared_utils.h" /* shared types between app and native */
#include "bi-inc/wgl_shared_utils.h" /* shared types between app and native */
#include "inc/wgl_types.h"
#include "inc/wgl_obj.h"

View File

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

View File

@ -0,0 +1,36 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#ifndef _GUI_API_H_
#define _GUI_API_H_
#include "bh_platform.h"
#ifdef __cplusplus
extern "C" {
#endif
void
wasm_obj_native_call(int32 func_id, int32 argv_offset, uint32 argc);
void
wasm_btn_native_call(int32 func_id, int32 argv_offset, uint32 argc);
void
wasm_label_native_call(int32 func_id, int32 argv_offset, uint32 argc);
void
wasm_cb_native_call(int32 func_id, int32 argv_offset, uint32 argc);
void
wasm_list_native_call(int32 func_id, int32 argv_offset, uint32 argc);
#ifdef __cplusplus
}
#endif
#endif /* end of _GUI_API_H_ */

View File

@ -0,0 +1,18 @@
# Copyright (C) 2019 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
set (WASM_LIB_GUI_DIR ${CMAKE_CURRENT_LIST_DIR})
set (DEPS_DIR ${WASM_LIB_GUI_DIR}/../../../deps)
add_definitions(-DLV_CONF_INCLUDE_SIMPLE)
include_directories(${WASM_LIB_GUI_DIR}
${DEPS_DIR}
${DEPS_DIR}/lvgl
${DEPS_DIR}/lvgl/src)
file (GLOB_RECURSE lvgl_source ${DEPS_DIR}/lvgl/*.c)
file (GLOB_RECURSE wrapper_source ${WASM_LIB_GUI_DIR}/*.c)
set (WASM_APP_LIB_CURRENT_SOURCE ${wrapper_source} ${lvgl_source})

View File

@ -125,9 +125,10 @@ static WGLNativeFuncDef btn_native_func_defs[] = {
/*************** Native Interface to Wasm App ***********/
void
wasm_btn_native_call(wasm_module_inst_t module_inst,
wasm_btn_native_call(wasm_exec_env_t exec_env,
int32 func_id, uint32 argv_offset, uint32 argc)
{
wasm_module_inst_t module_inst = get_module_inst(exec_env);
uint32 size = sizeof(btn_native_func_defs) / sizeof(WGLNativeFuncDef);
wgl_native_func_call(module_inst,

View File

@ -72,9 +72,10 @@ static WGLNativeFuncDef cb_native_func_defs[] = {
/*************** Native Interface to Wasm App ***********/
void
wasm_cb_native_call(wasm_module_inst_t module_inst,
wasm_cb_native_call(wasm_exec_env_t exec_env,
int32 func_id, uint32 argv_offset, uint32 argc)
{
wasm_module_inst_t module_inst = get_module_inst(exec_env);
uint32 size = sizeof(cb_native_func_defs) / sizeof(WGLNativeFuncDef);
wgl_native_func_call(module_inst,

View File

@ -63,9 +63,10 @@ static WGLNativeFuncDef label_native_func_defs[] = {
/*************** Native Interface to Wasm App ***********/
void
wasm_label_native_call(wasm_module_inst_t module_inst,
wasm_label_native_call(wasm_exec_env_t exec_env,
int32 func_id, uint32 argv_offset, uint32 argc)
{
wasm_module_inst_t module_inst = get_module_inst(exec_env);
uint32 size = sizeof(label_native_func_defs) / sizeof(WGLNativeFuncDef);
wgl_native_func_call(module_inst,

View File

@ -48,9 +48,10 @@ static WGLNativeFuncDef list_native_func_defs[] = {
/*************** Native Interface to Wasm App ***********/
void
wasm_list_native_call(wasm_module_inst_t module_inst,
wasm_list_native_call(wasm_exec_env_t exec_env,
int32 func_id, uint32 argv_offset, uint32 argc)
{
wasm_module_inst_t module_inst = get_module_inst(exec_env);
uint32 size = sizeof(list_native_func_defs) / sizeof(WGLNativeFuncDef);
wgl_native_func_call(module_inst,

View File

@ -13,6 +13,7 @@ extern "C" {
#include "bh_platform.h"
#include "lvgl.h"
#include "wasm_export.h"
#include "bi-inc/wgl_shared_utils.h"
#define OBJ_ARG_NUM_MAX 4
#define PTR_ARG_NUM_MAX 4

View File

@ -44,7 +44,7 @@ static void app_mgr_object_event_callback(module_data *m_data, bh_message_t msg)
uint32 argv[2];
wasm_function_inst_t func_on_object_event;
bh_assert(WIDGET_EVENT_WASM == bh_message_type(msg));
wasm_data *wasm_app_data = (wasm_data*) m_data->internal_data;
wasm_data *wasm_app_data = (wasm_data*)m_data->internal_data;
wasm_module_inst_t inst = wasm_app_data->wasm_module_inst;
object_event_t *object_event
= (object_event_t *)bh_message_payload(msg);
@ -58,13 +58,14 @@ static void app_mgr_object_event_callback(module_data *m_data, bh_message_t msg)
func_on_object_event = wasm_runtime_lookup_function(inst, "on_widget_event",
"(i32i32)");
if (!func_on_object_event) {
printf("Cannot find function _on_object_event\n");
printf("Cannot find function on_widget_event\n");
return;
}
argv[0] = object_event->obj_id;
argv[1] = object_event->event;
if (!wasm_runtime_call_wasm(inst, NULL, func_on_object_event, 2, argv)) {
if (!wasm_runtime_call_wasm(wasm_app_data->exec_env, func_on_object_event,
2, argv)) {
const char *exception = wasm_runtime_get_exception(inst);
bh_assert(exception);
printf(":Got exception running wasm code: %s\n",
@ -373,9 +374,10 @@ static WGLNativeFuncDef obj_native_func_defs[] = {
/*************** Native Interface to Wasm App ***********/
void
wasm_obj_native_call(wasm_module_inst_t module_inst,
wasm_obj_native_call(wasm_exec_env_t exec_env,
int32 func_id, uint32 argv_offset, uint32 argc)
{
wasm_module_inst_t module_inst = get_module_inst(exec_env);
uint32 size = sizeof(obj_native_func_defs) / sizeof(WGLNativeFuncDef);
wgl_native_func_call(module_inst,

View File

@ -8,7 +8,7 @@
#include "bh_queue.h"
#include "bh_memory.h"
#include "bh_thread.h"
#include "attr_container.h"
#include "bi-inc/attr_container.h"
#include "event.h"
#include "watchdog.h"
#include "coap_ext.h"
@ -214,7 +214,7 @@ void applet_mgt_reqeust_handler(request_t *request, void *unused)
static int get_module_type(char *kv_str)
{
int module_type = -1;
char type_str[8] = { 0 };
char type_str[16] = { 0 };
find_key_value(kv_str, strlen(kv_str), "type", type_str,
sizeof(type_str) - 1, '&');

Some files were not shown because too many files have changed in this diff Show More