native_interface.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 DEPS_SSG_MICRO_RUNTIME_WASM_POC_APP_LIBS_NATIVE_INTERFACE_NATIVE_INTERFACE_H_
  17. #define DEPS_SSG_MICRO_RUNTIME_WASM_POC_APP_LIBS_NATIVE_INTERFACE_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. #define get_module_inst() \
  22. wasm_runtime_get_current_module_inst()
  23. #define validate_app_addr(offset, size) \
  24. wasm_runtime_validate_app_addr(module_inst, offset, size)
  25. #define addr_app_to_native(offset) \
  26. wasm_runtime_addr_app_to_native(module_inst, offset)
  27. #define addr_native_to_app(ptr) \
  28. wasm_runtime_addr_native_to_app(module_inst, ptr)
  29. #define module_malloc(size) \
  30. wasm_runtime_module_malloc(module_inst, size)
  31. #define module_free(offset) \
  32. wasm_runtime_module_free(module_inst, offset)
  33. char *wa_strdup(const char *);
  34. bool
  35. wasm_response_send(int32 buffer_offset, int size);
  36. void wasm_register_resource(int32 url_offset);
  37. void wasm_post_request(int32 buffer_offset, int size);
  38. void wasm_sub_event(int32 url_offset);
  39. /*
  40. * ************* sensor interfaces *************
  41. */
  42. bool
  43. wasm_sensor_config(uint32 sensor, int interval, int bit_cfg, int delay);
  44. uint32
  45. wasm_sensor_open(int32 name_offset, int instance);
  46. bool
  47. wasm_sensor_config_with_attr_container(uint32 sensor, int32 buffer_offset,
  48. int len);
  49. bool
  50. wasm_sensor_close(uint32 sensor);
  51. /*
  52. * *** timer interface ***
  53. */
  54. typedef unsigned int timer_id_t;
  55. timer_id_t wasm_create_timer(int interval, bool is_period, bool auto_start);
  56. void wasm_timer_destory(timer_id_t timer_id);
  57. void wasm_timer_cancel(timer_id_t timer_id);
  58. void wasm_timer_restart(timer_id_t timer_id, int interval);
  59. uint32 wasm_get_sys_tick_ms(void);
  60. #endif /* DEPS_SSG_MICRO_RUNTIME_WASM_POC_APP_LIBS_NATIVE_INTERFACE_NATIVE_INTERFACE_H_ */