native_interface.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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 get_module_inst(exec_env) \
  12. wasm_runtime_get_module_inst(exec_env)
  13. #define validate_app_addr(offset, size) \
  14. wasm_runtime_validate_app_addr(module_inst, offset, size)
  15. #define validate_app_str_addr(offset) \
  16. wasm_runtime_validate_app_str_addr(module_inst, offset)
  17. #define addr_app_to_native(offset) \
  18. wasm_runtime_addr_app_to_native(module_inst, offset)
  19. #define addr_native_to_app(ptr) \
  20. wasm_runtime_addr_native_to_app(module_inst, ptr)
  21. #define module_malloc(size) \
  22. wasm_runtime_module_malloc(module_inst, size)
  23. #define module_free(offset) \
  24. wasm_runtime_module_free(module_inst, offset)
  25. /*char *wa_strdup(const char *);*/
  26. /*
  27. * request/response interfaces
  28. */
  29. bool
  30. wasm_response_send(wasm_exec_env_t exec_env,
  31. int32 buffer_offset, int size);
  32. void
  33. wasm_register_resource(wasm_exec_env_t exec_env,
  34. int32 url_offset);
  35. void
  36. wasm_post_request(wasm_exec_env_t exec_env,
  37. int32 buffer_offset, int size);
  38. void
  39. wasm_sub_event(wasm_exec_env_t exec_env,
  40. int32 url_offset);
  41. /*
  42. * sensor interfaces
  43. */
  44. bool
  45. wasm_sensor_config(wasm_exec_env_t exec_env,
  46. uint32 sensor, int interval, int bit_cfg, int delay);
  47. uint32
  48. wasm_sensor_open(wasm_exec_env_t exec_env,
  49. int32 name_offset, int instance);
  50. bool
  51. wasm_sensor_config_with_attr_container(wasm_exec_env_t exec_env,
  52. uint32 sensor,
  53. int32 buffer_offset, int len);
  54. bool
  55. wasm_sensor_close(wasm_exec_env_t exec_env,
  56. uint32 sensor);
  57. /*
  58. * timer interfaces
  59. */
  60. typedef unsigned int timer_id_t;
  61. timer_id_t
  62. wasm_create_timer(wasm_exec_env_t exec_env,
  63. int interval, bool is_period, bool auto_start);
  64. void
  65. wasm_timer_destroy(wasm_exec_env_t exec_env, timer_id_t timer_id);
  66. void
  67. wasm_timer_cancel(wasm_exec_env_t exec_env, timer_id_t timer_id);
  68. void
  69. wasm_timer_restart(wasm_exec_env_t exec_env,
  70. timer_id_t timer_id, int interval);
  71. uint32
  72. wasm_get_sys_tick_ms(wasm_exec_env_t exec_env);
  73. /*
  74. * connection interfaces
  75. */
  76. uint32
  77. wasm_open_connection(wasm_exec_env_t exec_env,
  78. int32 name_offset, int32 args_offset, uint32 len);
  79. void
  80. wasm_close_connection(wasm_exec_env_t exec_env,
  81. uint32 handle);
  82. int
  83. wasm_send_on_connection(wasm_exec_env_t exec_env,
  84. uint32 handle, int32 data_offset, uint32 len);
  85. bool
  86. wasm_config_connection(wasm_exec_env_t exec_env,
  87. uint32 handle, int32 cfg_offset, uint32 len);
  88. /**
  89. * gui interfaces
  90. */
  91. void
  92. wasm_obj_native_call(wasm_exec_env_t exec_env,
  93. int32 func_id, uint32 argv_offset, uint32 argc);
  94. void
  95. wasm_btn_native_call(wasm_exec_env_t exec_env,
  96. int32 func_id, uint32 argv_offset, uint32 argc);
  97. void
  98. wasm_label_native_call(wasm_exec_env_t exec_env,
  99. int32 func_id, uint32 argv_offset, uint32 argc);
  100. void
  101. wasm_cb_native_call(wasm_exec_env_t exec_env,
  102. int32 func_id, uint32 argv_offset, uint32 argc);
  103. void
  104. wasm_list_native_call(wasm_exec_env_t exec_env,
  105. int32 func_id, uint32 argv_offset, uint32 argc);
  106. #endif /* end of _NATIVE_INTERFACE_H */