Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync up with main repo #9

Merged
merged 40 commits into from
May 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
d44a3a9
Merge pull request #1 from intel/master
Weining2019 May 8, 2019
c010d20
Merge pull request #2 from intel/master
Weining2019 May 9, 2019
1f398d3
convert tab to 4 spaces in header files
Weining2019 May 9, 2019
89a13e8
Merge pull request #3 from intel/master
Weining2019 May 9, 2019
5a0089e
test
Weining2019 May 16, 2019
9e3edf7
test
Weining2019 May 16, 2019
57dabc2
test
Weining2019 May 16, 2019
3315c8c
Revert "test"
Weining2019 May 16, 2019
1baddc3
Revert "test"
Weining2019 May 16, 2019
e655f51
Revert "test"
Weining2019 May 16, 2019
b4774a3
aaa
Weining2019 May 16, 2019
c9e7708
Revert "aaa"
Weining2019 May 16, 2019
0d31325
a
Weining2019 May 16, 2019
82786e5
Revert "a"
Weining2019 May 16, 2019
af37fef
aaas
Weining2019 May 16, 2019
94d9a1d
a1
Weining2019 May 16, 2019
0428ff5
a2
Weining2019 May 16, 2019
f45466a
a3
Weining2019 May 16, 2019
d386d44
a4
Weining2019 May 16, 2019
f9929dd
a5
Weining2019 May 16, 2019
e993b07
a6
Weining2019 May 16, 2019
da9064f
Revert "a6"
Weining2019 May 16, 2019
8b9e0b7
Revert "a5"
Weining2019 May 16, 2019
4a6c536
Revert "a4"
Weining2019 May 16, 2019
793661d
Revert "a3"
Weining2019 May 16, 2019
8901c5b
Revert "a2"
Weining2019 May 16, 2019
444dc48
Revert "a1"
Weining2019 May 16, 2019
d033503
Revert "aaas"
Weining2019 May 16, 2019
3238c4f
add simple
Weining2019 May 16, 2019
2da1d4d
Revert "add simple"
Weining2019 May 16, 2019
8cc885f
Merge pull request #4 from intel/master
Weining2019 May 17, 2019
e450e60
Merge pull request #5 from intel/master
Weining2019 May 17, 2019
8deb148
Merge pull request #6 from intel/master
Weining2019 May 17, 2019
eead4f6
Merge pull request #7 from intel/master
Weining2019 May 17, 2019
9da47ed
Update README.md
xwang98 May 18, 2019
b2f9063
Merge pull request #8 from intel/master
Weining2019 May 20, 2019
f64b753
Update README
Weining2019 May 20, 2019
5ab2a7b
Update README.md
wenyongh May 20, 2019
ff49e67
Merge pull request #30 from Weining2019/master
wenyongh May 20, 2019
a66f18e
update README of littlevgl sample (#31)
litian-int May 20, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 55 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ WebAssembly Micro Runtime
=========================
WebAssembly Micro Runtime (WAMR) is a standalone WebAssembly (WASM) runtime designed for a small footprint. It includes:
- A WebAssembly (WASM) VM core
- The supporting APIs for the WASM applications
- The supporting API's for the WASM applications
- A mechanism for dynamic management of the WASM application

Why should you use a WASM runtime out of your browser? There are a few points where this might be meaningful:
Why should you use a WASM runtime out of your browser? There are a few points where this might be meaningful:
1. WASM is already an LLVM official backend target. That means WASM can run any programming languages which can be compiled to LLVM IR. It is a huge advantage compared to language bound runtimes like JS or Lua.
2. WASM is an open standard and it is fast becoming supported by the whole web ecosystem.
2. WASM is an open standard and it is fast becoming supported by the whole web ecosystem.
3. WASM is designed to be very friendly for compiling to native binaries and gaining the native speed.
4. It can potentially change the development practices. Imagine we can do both the WASM application development and validation in a browser, then just download the WASM binary code onto the target device.
4. It can potentially change the development practices. Imagine we can do both the WASM application development and validation in a browser, then just download the WASM binary code onto the target device.
5. WASM can work without garbage collection. It is designed to support execution determinics for the time sensitive requirement.
6. Maintain the safety goals WASM has of providing a sandboxed execution environment for untrusted code. In addition, because WASM is a compilation target, this implies the benefit of being able to target both an execution and security profile that is consistent across popular high-level programming languages.

Expand All @@ -18,8 +18,8 @@ Why should you use a WASM runtime out of your browser? There are a few points wh
Current Features of WAMR
=========================
- WASM interpreter (AOT is planned)
- Provides support for a subset of Lib.
- Supports "side_module=1" EMCC compilation option
- Provides support for a subset of Libc.
- Supports "SIDE_MODULE=1" EMCC compilation option
- Provides API's for embedding runtime into production software
- Provides a mechanism for exporting native API's to WASM applications
- Supports the programming of firmware apps in a large range of languages (C/C++/Java/Rust/Go/TypeScript etc.)
Expand All @@ -31,7 +31,7 @@ Current Features of WAMR

Architecture
=========================
The application manager component handles the packets that the platform receives from external sources through any communication buses such as a socket, serial port or PSI. A packet type can be either a request, response or an event. The app manager will serve the requests with URI "/applet" and call the runtime glue layer interfaces for installing/uninstalling the application. For other URI's, it will filter the resource registration table and route the request to the internal queue of the responsible application.
The application manager component handles the packets that the platform receives from external sources through any communication buses such as a socket, serial port or SPI. A packet type can be either a request, a response or an event. The application manager will serve the requests with URI "/applet" and call the runtime glue layer interfaces for installing/uninstalling the application. For other URI's, it will filter the resource registration table and route the request to the internal queue of the responsible application.

- The WebAssembly runtime provides the execution environment for WASM applications.

Expand Down Expand Up @@ -144,7 +144,7 @@ ninja run

Embed WAMR into software production
=====================================
WAMR can be built into a standalone executable which takes the WASM application file name as input, and then executes it. To use it in the embedded environment you should embed WAMR into your own software product. WASM provides a set of APIs for embedded code to load the WASM module, instantiate the module and invoke a WASM function from a native call.
WAMR can be built into a standalone executable which takes the WASM application file name as input, and then executes it. To use it in the embedded environment you should embed WAMR into your own software product. WASM provides a set of API's for embedded code to load the WASM module, instantiate the module and invoke a WASM function from a native call.

<img src="./doc/pics/embed.PNG" width="60%" height="60%">

Expand Down Expand Up @@ -174,7 +174,7 @@ A typical WAMR API usage is shown below (some return value checks are ignored):
wasm_runtime_clear_exception(inst);
}
/* the return value is stored in argv[0] */
printf(fib function return: %d\n, argv[0]);
printf("fib function return: %d\n", argv[0]);

wasm_runtime_destory_exec_env(env);
wasm_runtime_deinstantiate(inst);
Expand All @@ -194,10 +194,10 @@ In general, there are 3 classes of API's important for the WASM application:

Built-in application library
---------------
Built-in API's include Libc APIs, Base library and Extension library reference.
Built-in API's include Libc API's, Base library and Extension library reference.

**Libc APIs**<br/>
This is a minimal set of Libc APIs for memory allocation, string manipulation and printing. The header file is located at ```lib/app-libs/libc/lib_base.h```. The current supported API set is listed here:
**Libc API's**<br/>
This is a minimal set of Libc API's for memory allocation, string manipulation and printing. The header file is located at ```lib/app-libs/libc/lib_base.h```. The current supported API set is listed here:
``` C
void *malloc(size_t size);
void *calloc(size_t n, size_t size);
Expand All @@ -218,25 +218,25 @@ char *strncpy(char *dest, const char *src, unsigned long n);
```

**Base library**<br/>
Basic support for communication, timers, etc is available. You can refer to the header file ```lib/app-libs/base/wasm_app.h``` which contains the definitions for request and response API's, event pub/sub APIs and timer APIs. Please note that these API's require the native implementations.
Basic support for communication, timers, etc is available. You can refer to the header file ```lib/app-libs/base/wasm_app.h``` which contains the definitions for request and response API's, event pub/sub API's and timer API's. Please note that these API's require the native implementations.
The API set is listed below:
``` C
typedef void(*request_handler_f)(request_t *) ;
typedef void(*response_handler_f)(response_t *, void *) ;

// Request APIs
// Request API's
bool api_register_resource_handler(const char *url, request_handler_f);
void api_send_request(request_t * request, response_handler_f response_handler, void * user_data);
void api_response_send(response_t *response);

// event AP
// Event API's
bool api_publish_event(const char *url, int fmt, void *payload, int payload_len);
bool api_subscribe_event(const char * url, request_handler_f handler);

struct user_timer;
typedef struct user_timer * user_timer_t;

// Timer APIs
// Timer API's
user_timer_t api_timer_create(int interval, bool is_period, bool auto_start, void(*on_user_timer_update)(user_timer_t
));
void api_timer_cancel(user_timer_t timer);
Expand Down Expand Up @@ -286,10 +286,10 @@ Below is a sample of a library extension. All code invoked across WASM and nativ

<img src="./doc/pics/safe.PNG" width="100%" height="100%">

Exporting native API steps
Steps for exporting native API
==========================

WAMR implemented a framework for developers to export API's. Below is the procedure to expose the platform APIs in three steps:
WAMR implemented a framework for developers to export API's. Below is the procedure to expose the platform API's in three steps:

**Step 1. Create a header file**<br/>
Declare the API's for your WASM application source project to include.
Expand All @@ -306,7 +306,7 @@ static NativeSymbol extended_native_symbol_defs[] =
#include "ext_lib_export.h"
```

**Step 3. Register new APIs**<br/>
**Step 3. Register new API's**<br/>
Use the macro `EXPORT_WASM_API` and `EXPORT_WASM_API2` to add exported API's into the array of ```extended_native_symbol_defs```.
The pre-defined MACRO `EXPORT_WASM_API` should be used to declare a function export:
``` c
Expand Down Expand Up @@ -352,7 +352,7 @@ static NativeSymbol extended_native_symbol_defs[] =

Use extended library
------------------------
In the application source project, it will include the WAMR built-in APIs header file and platform extension header files. Assuming the board vendor extends the library which added an API called customized(), the WASM application would be like this:
In the application source project, it will include the WAMR built-in API's header file and platform extension header files. Assuming the board vendor extends the library which added an API called customized(), the WASM application would be like this:
``` C
#include <stdio.h>
#include "lib_export_dec.h" // provided by the platform vendor
Expand Down Expand Up @@ -382,8 +382,6 @@ Below is the reference implementation of the server application. It provides roo
``` C
void on_init()
{
/* register resource uri */
init_resource_register();
api_register_resource_handler("/room_temp", room_temp_handler);
}

Expand Down Expand Up @@ -424,35 +422,20 @@ One WASM application acts as the event publisher. It publishes events to notify
Below is the reference implementation of the pub application. It utilizes a timer to repeatedly publish an overheat alert event to the subscriber applications. Then the subscriber applications receive the events immediately.

``` C
void on_init(
{
api_subscribe_event ("alert/overheat", overheat_handler);
}

void on_destroy()
{
}

void overheat_handler(request_t *event
{
printf(“Event: %s\n", event->url);
}

/* Timer callback */
void timer_update(user_timer_t timer
{
attr_container_t *event;
printf("Timer update %d\n", num++);

event = attr_container_create("event");
attr_container_set_string(&event,
"warning",
"temperature is over high");
"warning",
"temperature is over high");

api_publish_event("alert/overheat",
FMT_ATTR_CONTAINER,
event,
attr_container_get_serialize_length(event));
FMT_ATTR_CONTAINER,
event,
attr_container_get_serialize_length(event));

attr_container_destroy(event);
}
Expand All @@ -462,7 +445,32 @@ void on_init()
user_timer_t timer;
timer = api_timer_create(1000, true, true, timer_update);
}

void on_destroy()
{
}
```

Below is the reference implementation of the sub application.
``` C
void overheat_handler(request_t *event)
{
printf("Event: %s\n", event->url);

if (event->payload != NULL && event->fmt == FMT_ATTR_CONTAINER)
attr_container_dump((attr_container_t *) event->payload);
}

void on_init(
{
api_subscribe_event ("alert/overheat", overheat_handler);
}

void on_destroy()
{
}
```
**Note:** You can also subscribe this event from host side by using host tool. Please refer `samples/simple` project for deail usage.

Samples and demos
=========================
Expand Down Expand Up @@ -496,6 +504,9 @@ The sample also provides the native Linux version of application without the run
<img src="./doc/pics/vgl_linux.PNG">


Submit issues and request
=========================
Submit issues and contact the maintainers
=========================================
[Click here to submit. Your feedback is always welcome!](https://github.com/intel/wasm-micro-runtime/issues/new)


Contact the maintainers: [email protected]
6 changes: 5 additions & 1 deletion samples/littlevgl/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ Zephyr
WASM VM and native extension method can be built into Zephyr, Then we can install wasm app into STM32.</br>
- Build WASM VM into Zephyr system</br>
a. clone zephyr source code</br>
`git clone https://github.com/zephyrproject-rtos/zephyr.git`</br>
Refer to Zephyr getting started.</br>
https://docs.zephyrproject.org/latest/getting_started/index.html</br>
`west init zephyrproject`</br>
`cd zephyrproject`</br>
`west update`</br>
b. copy samples</br>
`cd zephyr/samples/`</br>
`cp -a <wamr_root>samples/littlevgl/vgl-wasm-runtime vgl-wasm-runtime`</br>
Expand Down
2 changes: 1 addition & 1 deletion samples/simple/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Introduction
==============
This project builds out both host tools running on the host side, an application running on the device side. The device application consists of iwasm, application library, application manager, timers and sensors support. The device runs on Linux OS and interacts with host tools.
This project builds out both host tools running on the host side, and an application running on the device side. The device application consists of iwasm, application library, application manager, timers and sensors support. The device runs on Linux OS and interacts with host tools.

It demonstrates an end to end scenario, the wasm applications life cycle management and communication programming models.

Expand Down