Add parameter module inst for native wrapper functions (#117)
And add asm code of em64/arm/mips version to call native wrapper functions; Fix some issues of calling wrapper functions;
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
#include "lib_export.h"
|
||||
#include "native_interface.h"
|
||||
#include "sensor_api.h"
|
||||
#include "connection_api.h"
|
||||
#include "gui_api.h"
|
||||
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
#ifndef DISPLAY_INDEV_H_
|
||||
#define DISPLAY_INDEV_H_
|
||||
#include <stdio.h>
|
||||
#include "bh_platform.h"
|
||||
#include <stdbool.h>
|
||||
#include <inttypes.h>
|
||||
#include "bh_platform.h"
|
||||
#include "wasm_export.h"
|
||||
|
||||
#define USE_MOUSE 1
|
||||
typedef union {
|
||||
@ -54,21 +55,37 @@ enum {
|
||||
LV_OPA_100 = 255,
|
||||
LV_OPA_COVER = 255,
|
||||
};
|
||||
extern void display_init(void);
|
||||
extern void display_deinit(void);
|
||||
extern int time_get_ms();
|
||||
extern bool touchscreen_read(lv_indev_data_t * data);
|
||||
|
||||
extern void xpt2046_init(void);
|
||||
extern void display_flush(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
int32 color_p_offset);
|
||||
extern void display_fill(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
lv_color_t color_p);
|
||||
extern void display_map(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
const lv_color_t * color_p);
|
||||
extern bool display_input_read(int32 data_offset);
|
||||
void display_vdb_write(int32 buf_offset, lv_coord_t buf_w, lv_coord_t x,
|
||||
lv_coord_t y, int32 color_p_offset, lv_opa_t opa);
|
||||
|
||||
extern bool touchscreen_read(lv_indev_data_t * data);
|
||||
|
||||
extern bool mouse_read(lv_indev_data_t * data);
|
||||
|
||||
extern void display_init(wasm_module_inst_t module_inst);
|
||||
|
||||
extern void display_deinit(wasm_module_inst_t module_inst);
|
||||
|
||||
extern int time_get_ms(wasm_module_inst_t module_inst);
|
||||
|
||||
extern void display_flush(wasm_module_inst_t module_inst,
|
||||
int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
int32 color_p_offset);
|
||||
|
||||
extern void display_fill(wasm_module_inst_t module_inst,
|
||||
int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
lv_color_t color_p);
|
||||
|
||||
extern void display_map(wasm_module_inst_t module_inst,
|
||||
int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
const lv_color_t * color_p);
|
||||
|
||||
extern bool display_input_read(wasm_module_inst_t module_inst,
|
||||
int32 data_offset);
|
||||
|
||||
void display_vdb_write(wasm_module_inst_t module_inst,
|
||||
int32 buf_offset, lv_coord_t buf_w, lv_coord_t x,
|
||||
lv_coord_t y, int32 color_p_offset, lv_opa_t opa);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#include "lib_export.h"
|
||||
#include "native_interface.h"
|
||||
#include "sensor_api.h"
|
||||
#include "connection_api.h"
|
||||
#include "display_indev.h"
|
||||
|
||||
@ -12,6 +12,7 @@ static NativeSymbol extended_native_symbol_defs[] = {
|
||||
EXPORT_WASM_API(display_fill),
|
||||
EXPORT_WASM_API(display_vdb_write),
|
||||
EXPORT_WASM_API(display_map),
|
||||
EXPORT_WASM_API(time_get_ms), };
|
||||
EXPORT_WASM_API(time_get_ms)
|
||||
};
|
||||
|
||||
#include "ext_lib_export.h"
|
||||
|
||||
@ -35,7 +35,8 @@ static uint32_t tft_fb[MONITOR_HOR_RES * MONITOR_VER_RES];
|
||||
|
||||
|
||||
|
||||
int time_get_ms()
|
||||
int
|
||||
time_get_ms(wasm_module_inst_t module_inst)
|
||||
{
|
||||
static struct timeval tv;
|
||||
gettimeofday(&tv, NULL);
|
||||
@ -157,15 +158,16 @@ void monitor_map(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
}
|
||||
|
||||
|
||||
void display_init(void)
|
||||
void
|
||||
display_init(wasm_module_inst_t module_inst)
|
||||
{
|
||||
}
|
||||
|
||||
void display_flush(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
int32 color_p_offset)
|
||||
void
|
||||
display_flush(wasm_module_inst_t module_inst,
|
||||
int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
int32 color_p_offset)
|
||||
{
|
||||
|
||||
wasm_module_inst_t module_inst = wasm_runtime_get_current_module_inst();
|
||||
if (!wasm_runtime_validate_app_addr(module_inst, color_p_offset, 1))
|
||||
return;
|
||||
lv_color_t * color_p = wasm_runtime_addr_app_to_native(module_inst,
|
||||
@ -173,21 +175,28 @@ void display_flush(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
|
||||
monitor_flush(x1, y1, x2, y2, color_p);
|
||||
}
|
||||
void display_fill(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
lv_color_t color_p)
|
||||
|
||||
void
|
||||
display_fill(wasm_module_inst_t module_inst,
|
||||
int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
lv_color_t color_p)
|
||||
{
|
||||
monitor_fill(x1, y1, x2, y2, color_p);
|
||||
}
|
||||
void display_map(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
const lv_color_t * color_p)
|
||||
|
||||
void
|
||||
display_map(wasm_module_inst_t module_inst,
|
||||
int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
const lv_color_t * color_p)
|
||||
{
|
||||
monitor_map(x1, y1, x2, y2, color_p);
|
||||
}
|
||||
|
||||
bool display_input_read(int32 data_p_offset)
|
||||
bool
|
||||
display_input_read(wasm_module_inst_t module_inst,
|
||||
int32 data_p_offset)
|
||||
{
|
||||
bool ret;
|
||||
wasm_module_inst_t module_inst = wasm_runtime_get_current_module_inst();
|
||||
if (!wasm_runtime_validate_app_addr(module_inst, data_p_offset, 1))
|
||||
return false;
|
||||
|
||||
@ -205,21 +214,23 @@ bool display_input_read(int32 data_p_offset)
|
||||
data_p_offset);
|
||||
|
||||
data_app->point = data.point;
|
||||
data_app->user_data_offset = (int32_t)data.user_data;
|
||||
data_app->user_data_offset =
|
||||
wasm_runtime_addr_native_to_app(module_inst, data.user_data);
|
||||
data_app->state = data.state;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void display_deinit(void)
|
||||
void
|
||||
display_deinit(wasm_module_inst_t module_inst)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void display_vdb_write(int32 buf_offset, lv_coord_t buf_w, lv_coord_t x,
|
||||
lv_coord_t y, int32 color_p_offset, lv_opa_t opa)
|
||||
void
|
||||
display_vdb_write(wasm_module_inst_t module_inst,
|
||||
int32 buf_offset, lv_coord_t buf_w, lv_coord_t x,
|
||||
lv_coord_t y, int32 color_p_offset, lv_opa_t opa)
|
||||
{
|
||||
wasm_module_inst_t module_inst = wasm_runtime_get_current_module_inst();
|
||||
if (!wasm_runtime_validate_app_addr(module_inst, color_p_offset, 1))
|
||||
return;
|
||||
lv_color_t *color = wasm_runtime_addr_app_to_native(module_inst,
|
||||
|
||||
@ -24,8 +24,11 @@
|
||||
#ifndef MONITOR_ZOOM
|
||||
#define MONITOR_ZOOM 1
|
||||
#endif
|
||||
int lcd_initialized = 0;
|
||||
void display_init(void)
|
||||
|
||||
static int lcd_initialized = 0;
|
||||
|
||||
void
|
||||
display_init(wasm_module_inst_t module_inst)
|
||||
{
|
||||
if (lcd_initialized != 0) {
|
||||
return;
|
||||
@ -36,10 +39,11 @@ void display_init(void)
|
||||
display_blanking_off(NULL);
|
||||
}
|
||||
|
||||
void display_flush(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
int32 color_p_offset)
|
||||
void
|
||||
display_flush(wasm_module_inst_t module_inst,
|
||||
int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
int32 color_p_offset)
|
||||
{
|
||||
wasm_module_inst_t module_inst = wasm_runtime_get_current_module_inst();
|
||||
if (!wasm_runtime_validate_app_addr(module_inst, color_p_offset, 1))
|
||||
return;
|
||||
lv_color_t * color_p = wasm_runtime_addr_app_to_native(module_inst,
|
||||
@ -57,20 +61,24 @@ void display_flush(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
|
||||
/*lv_flush_ready();*/
|
||||
}
|
||||
void display_fill(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
lv_color_t color_p)
|
||||
{
|
||||
|
||||
}
|
||||
void display_map(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
const lv_color_t * color_p)
|
||||
void
|
||||
display_fill(wasm_module_inst_t module_inst,
|
||||
int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
lv_color_t color_p)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool display_input_read(int32 data_p_offset)
|
||||
void
|
||||
display_map(wasm_module_inst_t module_inst,
|
||||
int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
const lv_color_t * color_p)
|
||||
{
|
||||
}
|
||||
|
||||
bool
|
||||
display_input_read(wasm_module_inst_t module_inst, int32 data_p_offset)
|
||||
{
|
||||
wasm_module_inst_t module_inst = wasm_runtime_get_current_module_inst();
|
||||
if (!wasm_runtime_validate_app_addr(module_inst, data_p_offset, 1))
|
||||
return false;
|
||||
lv_indev_data_t * data = wasm_runtime_addr_app_to_native(module_inst,
|
||||
@ -80,15 +88,17 @@ bool display_input_read(int32 data_p_offset)
|
||||
|
||||
}
|
||||
|
||||
void display_deinit(void)
|
||||
void
|
||||
display_deinit(wasm_module_inst_t module_inst)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void display_vdb_write(int32 buf_offset, lv_coord_t buf_w, lv_coord_t x,
|
||||
lv_coord_t y, int32 color_p_offset, lv_opa_t opa)
|
||||
void
|
||||
display_vdb_write(wasm_module_inst_t module_inst,
|
||||
int32 buf_offset, lv_coord_t buf_w, lv_coord_t x,
|
||||
lv_coord_t y, int32 color_p_offset, lv_opa_t opa)
|
||||
{
|
||||
wasm_module_inst_t module_inst = wasm_runtime_get_current_module_inst();
|
||||
if (!wasm_runtime_validate_app_addr(module_inst, color_p_offset, 1))
|
||||
return;
|
||||
lv_color_t *color = wasm_runtime_addr_app_to_native(module_inst,
|
||||
@ -112,7 +122,8 @@ void display_vdb_write(int32 buf_offset, lv_coord_t buf_w, lv_coord_t x,
|
||||
*(buf_xy + 2) = color->blue;
|
||||
}
|
||||
|
||||
int time_get_ms()
|
||||
int
|
||||
time_get_ms(wasm_module_inst_t module_inst)
|
||||
{
|
||||
return k_uptime_get_32();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user