native_interface.h 4.1 KB

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