Implement native function pointer check, addr conversion and register, update documents (#185)

Modified WASM runtime API:
- wasm_runtime_module_malloc()
- wasm_runtime_lookup_function()
Introduced runtime API
- wasm_runtime_register_natives()
This commit is contained in:
wenyongh
2020-03-04 20:12:38 +08:00
committed by GitHub
parent 2e36149e32
commit 0d3f304191
96 changed files with 2293 additions and 2317 deletions

View File

@ -15,6 +15,9 @@
#include "bi-inc/attr_container.h"
#include "module_wasm_app.h"
#include "wasm_export.h"
#include "sensor_native_api.h"
#include "connection_native_api.h"
#include "display_indev.h"
#include <zephyr.h>
#include <drivers/uart.h>
@ -30,7 +33,6 @@ int uart_char_cnt = 0;
static void uart_irq_callback(struct device *dev)
{
unsigned char ch;
int size = 0;
while (uart_poll_in(dev, &ch) == 0) {
uart_char_cnt++;
@ -77,11 +79,21 @@ timer_ctx_t timer_ctx;
static char global_heap_buf[370 * 1024] = { 0 };
extern void display_init(void);
static NativeSymbol native_symbols[] = {
#include "runtime_sensor.inl"
#include "connection.inl"
EXPORT_WASM_API_WITH_SIG(display_input_read, "(*)i"),
EXPORT_WASM_API_WITH_SIG(display_flush, "(iiii*)"),
EXPORT_WASM_API_WITH_SIG(display_fill, "(iiii*)"),
EXPORT_WASM_API_WITH_SIG(display_vdb_write, "(*iii*i)"),
EXPORT_WASM_API_WITH_SIG(display_map, "(iiii*)"),
EXPORT_WASM_API_WITH_SIG(time_get_ms, "()i")
};
int iwasm_main()
{
korp_thread tid, tm_tid;
uint32 n_native_symbols;
host_init();
@ -95,6 +107,13 @@ int iwasm_main()
goto fail1;
}
/* Register native functions */
n_native_symbols = sizeof(native_symbols) / sizeof(NativeSymbol);
if (!wasm_runtime_register_natives("env",
native_symbols, n_native_symbols)) {
goto fail1;
}
display_init();
// timer manager