native_interface.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /*
  2. * Copyright (C) 2019 Intel Corporation. All rights reserved.
  3. * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. */
  5. #ifndef _NATIVE_INTERFACE_H_
  6. #define _NATIVE_INTERFACE_H_
  7. /* Note: the bh_plaform.h is the only head file separately
  8. implemented by both [app] and [native] worlds */
  9. #include "bh_platform.h"
  10. #include "wasm_export.h"
  11. #define validate_app_addr(offset, size) \
  12. wasm_runtime_validate_app_addr(module_inst, offset, size)
  13. #define validate_app_str_addr(offset) \
  14. wasm_runtime_validate_app_str_addr(module_inst, offset)
  15. #define addr_app_to_native(offset) \
  16. wasm_runtime_addr_app_to_native(module_inst, offset)
  17. #define addr_native_to_app(ptr) \
  18. wasm_runtime_addr_native_to_app(module_inst, ptr)
  19. #define module_malloc(size) \
  20. wasm_runtime_module_malloc(module_inst, size)
  21. #define module_free(offset) \
  22. wasm_runtime_module_free(module_inst, offset)
  23. /*char *wa_strdup(const char *);*/
  24. /*
  25. * request/response interfaces
  26. */
  27. bool
  28. wasm_response_send(wasm_module_inst_t module_inst,
  29. int32 buffer_offset, int size);
  30. void
  31. wasm_register_resource(wasm_module_inst_t module_inst,
  32. int32 url_offset);
  33. void
  34. wasm_post_request(wasm_module_inst_t module_inst,
  35. int32 buffer_offset, int size);
  36. void
  37. wasm_sub_event(wasm_module_inst_t module_inst,
  38. int32 url_offset);
  39. /*
  40. * sensor interfaces
  41. */
  42. bool
  43. wasm_sensor_config(wasm_module_inst_t module_inst,
  44. uint32 sensor, int interval, int bit_cfg, int delay);
  45. uint32
  46. wasm_sensor_open(wasm_module_inst_t module_inst,
  47. int32 name_offset, int instance);
  48. bool
  49. wasm_sensor_config_with_attr_container(wasm_module_inst_t module_inst,
  50. uint32 sensor,
  51. int32 buffer_offset, int len);
  52. bool
  53. wasm_sensor_close(wasm_module_inst_t module_inst,
  54. uint32 sensor);
  55. /*
  56. * timer interfaces
  57. */
  58. typedef unsigned int timer_id_t;
  59. timer_id_t
  60. wasm_create_timer(wasm_module_inst_t module_inst,
  61. int interval, bool is_period, bool auto_start);
  62. void
  63. wasm_timer_destroy(wasm_module_inst_t module_inst, timer_id_t timer_id);
  64. void
  65. wasm_timer_cancel(wasm_module_inst_t module_inst, timer_id_t timer_id);
  66. void
  67. wasm_timer_restart(wasm_module_inst_t module_inst,
  68. timer_id_t timer_id, int interval);
  69. uint32
  70. wasm_get_sys_tick_ms(wasm_module_inst_t module_inst);
  71. /*
  72. * connection interfaces
  73. */
  74. uint32
  75. wasm_open_connection(wasm_module_inst_t module_inst,
  76. int32 name_offset, int32 args_offset, uint32 len);
  77. void
  78. wasm_close_connection(wasm_module_inst_t module_inst,
  79. uint32 handle);
  80. int
  81. wasm_send_on_connection(wasm_module_inst_t module_inst,
  82. uint32 handle, int32 data_offset, uint32 len);
  83. bool
  84. wasm_config_connection(wasm_module_inst_t module_inst,
  85. uint32 handle, int32 cfg_offset, uint32 len);
  86. /**
  87. * gui interfaces
  88. */
  89. void
  90. wasm_obj_native_call(wasm_module_inst_t module_inst,
  91. int32 func_id, uint32 argv_offset, uint32 argc);
  92. void
  93. wasm_btn_native_call(wasm_module_inst_t module_inst,
  94. int32 func_id, uint32 argv_offset, uint32 argc);
  95. void
  96. wasm_label_native_call(wasm_module_inst_t module_inst,
  97. int32 func_id, uint32 argv_offset, uint32 argc);
  98. void
  99. wasm_cb_native_call(wasm_module_inst_t module_inst,
  100. int32 func_id, uint32 argv_offset, uint32 argc);
  101. void
  102. wasm_list_native_call(wasm_module_inst_t module_inst,
  103. int32 func_id, uint32 argv_offset, uint32 argc);
  104. #endif /* end of _NATIVE_INTERFACE_H */