native_interface.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /*
  2. * Copyright (C) 2019 Intel Corporation. All rights reserved.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #ifndef _NATIVE_INTERFACE_H_
  17. #define _NATIVE_INTERFACE_H_
  18. /* Note: the bh_plaform.h is the only head file separately
  19. implemented by both [app] and [native] worlds */
  20. #include "bh_platform.h"
  21. #include "wasm_export.h"
  22. #define validate_app_addr(offset, size) \
  23. wasm_runtime_validate_app_addr(module_inst, offset, size)
  24. #define addr_app_to_native(offset) \
  25. wasm_runtime_addr_app_to_native(module_inst, offset)
  26. #define addr_native_to_app(ptr) \
  27. wasm_runtime_addr_native_to_app(module_inst, ptr)
  28. #define module_malloc(size) \
  29. wasm_runtime_module_malloc(module_inst, size)
  30. #define module_free(offset) \
  31. wasm_runtime_module_free(module_inst, offset)
  32. /*char *wa_strdup(const char *);*/
  33. /*
  34. * request/response interfaces
  35. */
  36. bool
  37. wasm_response_send(wasm_module_inst_t module_inst,
  38. int32 buffer_offset, int size);
  39. void
  40. wasm_register_resource(wasm_module_inst_t module_inst,
  41. int32 url_offset);
  42. void
  43. wasm_post_request(wasm_module_inst_t module_inst,
  44. int32 buffer_offset, int size);
  45. void
  46. wasm_sub_event(wasm_module_inst_t module_inst,
  47. int32 url_offset);
  48. /*
  49. * sensor interfaces
  50. */
  51. bool
  52. wasm_sensor_config(wasm_module_inst_t module_inst,
  53. uint32 sensor, int interval, int bit_cfg, int delay);
  54. uint32
  55. wasm_sensor_open(wasm_module_inst_t module_inst,
  56. int32 name_offset, int instance);
  57. bool
  58. wasm_sensor_config_with_attr_container(wasm_module_inst_t module_inst,
  59. uint32 sensor,
  60. int32 buffer_offset, int len);
  61. bool
  62. wasm_sensor_close(wasm_module_inst_t module_inst,
  63. uint32 sensor);
  64. /*
  65. * timer interfaces
  66. */
  67. typedef unsigned int timer_id_t;
  68. timer_id_t
  69. wasm_create_timer(wasm_module_inst_t module_inst,
  70. int interval, bool is_period, bool auto_start);
  71. void
  72. wasm_timer_destroy(wasm_module_inst_t module_inst, timer_id_t timer_id);
  73. void
  74. wasm_timer_cancel(wasm_module_inst_t module_inst, timer_id_t timer_id);
  75. void
  76. wasm_timer_restart(wasm_module_inst_t module_inst,
  77. timer_id_t timer_id, int interval);
  78. uint32
  79. wasm_get_sys_tick_ms(wasm_module_inst_t module_inst);
  80. /*
  81. * connection interfaces
  82. */
  83. uint32
  84. wasm_open_connection(wasm_module_inst_t module_inst,
  85. int32 name_offset, int32 args_offset, uint32 len);
  86. void
  87. wasm_close_connection(wasm_module_inst_t module_inst,
  88. uint32 handle);
  89. int
  90. wasm_send_on_connection(wasm_module_inst_t module_inst,
  91. uint32 handle, int32 data_offset, uint32 len);
  92. bool
  93. wasm_config_connection(wasm_module_inst_t module_inst,
  94. uint32 handle, int32 cfg_offset, uint32 len);
  95. /**
  96. * gui interfaces
  97. */
  98. void
  99. wasm_obj_native_call(wasm_module_inst_t module_inst,
  100. int32 func_id, uint32 argv_offset, uint32 argc);
  101. void
  102. wasm_btn_native_call(wasm_module_inst_t module_inst,
  103. int32 func_id, uint32 argv_offset, uint32 argc);
  104. void
  105. wasm_label_native_call(wasm_module_inst_t module_inst,
  106. int32 func_id, uint32 argv_offset, uint32 argc);
  107. void
  108. wasm_cb_native_call(wasm_module_inst_t module_inst,
  109. int32 func_id, uint32 argv_offset, uint32 argc);
  110. void
  111. wasm_list_native_call(wasm_module_inst_t module_inst,
  112. int32 func_id, uint32 argv_offset, uint32 argc);
  113. #endif /* end of _NATIVE_INTERFACE_H */