Enable AoT and wamr-sdk, and change arguments of call wasm API (#157)
* Implement memory profiler, optimize memory usage, modify code indent * Implement memory.grow and limit heap space base offset to 1G; modify iwasm build type to Release and 64 bit by default * Add a new extension library: connection * Fix bug of reading magic number and version in big endian platform * Re-org platform APIs: move most platform APIs from iwasm to shared-lib * Enhance wasm loader to fix some security issues * Fix issue about illegal load of EXC_RETURN into PC on stm32 board * Updates that let a restricted version of the interpreter run in SGX * Enable native/app address validation and conversion for wasm app * Remove wasm_application_exectue_* APIs from wasm_export.h which makes confused * Refine binary size and fix several minor issues Optimize interpreter LOAD/STORE opcodes to decrease the binary size Fix issues when using iwasm library: _bh_log undefined, bh_memory.h not found Remove unused _stdin/_stdout/_stderr global variables resolve in libc wrapper Add macros of global heap size, stack size, heap size for Zephyr main.c Clear compile warning of wasm_application.c * Add more strict security checks for libc wrapper API's * Use one libc wrapper copy for sgx and other platforms; remove bh_printf macro for other platform header files * Enhance security of libc strcpy/sprintf wrapper function * Fix issue of call native for x86_64/arm/mips, add module inst parameter for native wrapper functions * Remove get_module_inst() and fix issue of call native * Refine wgl lib: remove module_inst parameter from widget functions; move function index check to runtime instantiate * Refine interpreter call native process, refine memory boudary check * Fix issues of invokeNative function of arm/mips/general version * Add a switch to build simple sample without gui support * Add BUILD_TARGET setting in makefile to replace cpu compiler flags in source code * Re-org shared lib header files, remove unused info; fix compile issues of vxworks * Add build target general * Remove unused files * Update license header * test push * Restore file * Sync up with internal/feature * Sync up with internal/feature * Rename build_wamr_app to build_wasm_app * Fix small issues of README * Enhance malformed wasm file checking Fix issue of print hex int and implement utf8 string check Fix wasi file read/write right issue Fix minor issue of build wasm app doc * Sync up with internal/feature * Sync up with internal/feature: fix interpreter arm issue, fix read leb issue * Sync up with internal/feature * Fix bug of config.h and rename wasi config.h to ssp_config.h * Sync up with internal/feature * Import wamr aot * update document * update document * Update document, disable WASI in 32bit * update document * remove files * update document * Update document * update document * update document * update samples * Sync up with internal repo
This commit is contained in:
170
core/app-framework/base/app/wa-inc/request.h
Normal file
170
core/app-framework/base/app/wa-inc/request.h
Normal file
@ -0,0 +1,170 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#ifndef _AEE_REQUEST_H_
|
||||
#define _AEE_REQUEST_H_
|
||||
|
||||
#include "bi-inc/shared_utils.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* CoAP request method codes */
|
||||
typedef enum {
|
||||
COAP_GET = 1,
|
||||
COAP_POST,
|
||||
COAP_PUT,
|
||||
COAP_DELETE,
|
||||
COAP_EVENT = (COAP_DELETE + 2)
|
||||
} coap_method_t;
|
||||
|
||||
/* CoAP response codes */
|
||||
typedef enum {
|
||||
NO_ERROR = 0,
|
||||
|
||||
CREATED_2_01 = 65, /* CREATED */
|
||||
DELETED_2_02 = 66, /* DELETED */
|
||||
VALID_2_03 = 67, /* NOT_MODIFIED */
|
||||
CHANGED_2_04 = 68, /* CHANGED */
|
||||
CONTENT_2_05 = 69, /* OK */
|
||||
CONTINUE_2_31 = 95, /* CONTINUE */
|
||||
|
||||
BAD_REQUEST_4_00 = 128, /* BAD_REQUEST */
|
||||
UNAUTHORIZED_4_01 = 129, /* UNAUTHORIZED */
|
||||
BAD_OPTION_4_02 = 130, /* BAD_OPTION */
|
||||
FORBIDDEN_4_03 = 131, /* FORBIDDEN */
|
||||
NOT_FOUND_4_04 = 132, /* NOT_FOUND */
|
||||
METHOD_NOT_ALLOWED_4_05 = 133, /* METHOD_NOT_ALLOWED */
|
||||
NOT_ACCEPTABLE_4_06 = 134, /* NOT_ACCEPTABLE */
|
||||
PRECONDITION_FAILED_4_12 = 140, /* BAD_REQUEST */
|
||||
REQUEST_ENTITY_TOO_LARGE_4_13 = 141, /* REQUEST_ENTITY_TOO_LARGE */
|
||||
UNSUPPORTED_MEDIA_TYPE_4_15 = 143, /* UNSUPPORTED_MEDIA_TYPE */
|
||||
|
||||
INTERNAL_SERVER_ERROR_5_00 = 160, /* INTERNAL_SERVER_ERROR */
|
||||
NOT_IMPLEMENTED_5_01 = 161, /* NOT_IMPLEMENTED */
|
||||
BAD_GATEWAY_5_02 = 162, /* BAD_GATEWAY */
|
||||
SERVICE_UNAVAILABLE_5_03 = 163, /* SERVICE_UNAVAILABLE */
|
||||
GATEWAY_TIMEOUT_5_04 = 164, /* GATEWAY_TIMEOUT */
|
||||
PROXYING_NOT_SUPPORTED_5_05 = 165, /* PROXYING_NOT_SUPPORTED */
|
||||
|
||||
/* Erbium errors */
|
||||
MEMORY_ALLOCATION_ERROR = 192, PACKET_SERIALIZATION_ERROR,
|
||||
|
||||
/* Erbium hooks */
|
||||
MANUAL_RESPONSE, PING_RESPONSE
|
||||
} coap_status_t;
|
||||
|
||||
|
||||
/**
|
||||
* @typedef request_handler_f
|
||||
*
|
||||
* @brief Define the signature of callback function for API
|
||||
* api_register_resource_handler() to handle request or for API
|
||||
* api_subscribe_event() to handle event.
|
||||
*
|
||||
* @param request pointer of the request to be handled
|
||||
*
|
||||
* @see api_register_resource_handler
|
||||
* @see api_subscribe_event
|
||||
*/
|
||||
typedef void (*request_handler_f)(request_t *request);
|
||||
|
||||
/**
|
||||
* @typedef response_handler_f
|
||||
*
|
||||
* @brief Define the signature of callback function for API
|
||||
* api_send_request() to handle response of a request.
|
||||
*
|
||||
* @param response pointer of the response to be handled
|
||||
* @param user_data user data associated with the request which is set when
|
||||
* calling api_send_request().
|
||||
*
|
||||
* @see api_send_request
|
||||
*/
|
||||
typedef void (*response_handler_f)(response_t *response, void *user_data);
|
||||
|
||||
|
||||
/*
|
||||
*****************
|
||||
* Request APIs
|
||||
*****************
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Register resource.
|
||||
*
|
||||
* @param url url of the resource
|
||||
* @param handler callback function to handle the request to the resource
|
||||
*
|
||||
* @return true if success, false otherwise
|
||||
*/
|
||||
bool api_register_resource_handler(const char *url, request_handler_f handler);
|
||||
|
||||
/**
|
||||
* @brief Send request asynchronously.
|
||||
*
|
||||
* @param request pointer of the request to be sent
|
||||
* @param response_handler callback function to handle the response
|
||||
* @param user_data user data
|
||||
*/
|
||||
void api_send_request(request_t * request, response_handler_f response_handler,
|
||||
void * user_data);
|
||||
|
||||
/**
|
||||
* @brief Send response.
|
||||
*
|
||||
* @param response pointer of the response to be sent
|
||||
*
|
||||
* @par
|
||||
* @code
|
||||
* void res1_handler(request_t *request)
|
||||
* {
|
||||
* response_t response[1];
|
||||
* make_response_for_request(request, response);
|
||||
* set_response(response, DELETED_2_02, 0, NULL, 0);
|
||||
* api_response_send(response);
|
||||
* }
|
||||
* @endcode
|
||||
*/
|
||||
void api_response_send(response_t *response);
|
||||
|
||||
|
||||
/*
|
||||
*****************
|
||||
* Event APIs
|
||||
*****************
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Publish an event.
|
||||
*
|
||||
* @param url url of the event
|
||||
* @param fmt format of the event payload
|
||||
* @param payload payload of the event
|
||||
* @param payload_len length in bytes of the event payload
|
||||
*
|
||||
* @return true if success, false otherwise
|
||||
*/
|
||||
bool api_publish_event(const char *url, int fmt, void *payload,
|
||||
int payload_len);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Subscribe an event.
|
||||
*
|
||||
* @param url url of the event
|
||||
* @param handler callback function to handle the event.
|
||||
*
|
||||
* @return true if success, false otherwise
|
||||
*/
|
||||
bool api_subscribe_event(const char * url, request_handler_f handler);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
68
core/app-framework/base/app/wa-inc/timer_wasm_app.h
Normal file
68
core/app-framework/base/app/wa-inc/timer_wasm_app.h
Normal file
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#ifndef _AEE_TIMER_H_
|
||||
#define _AEE_TIMER_H_
|
||||
|
||||
#include "bh_platform.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* board producer define user_timer */
|
||||
struct user_timer;
|
||||
typedef struct user_timer * user_timer_t;
|
||||
|
||||
/**
|
||||
* @typedef on_user_timer_update_f
|
||||
*
|
||||
* @brief Define the signature of callback function for API api_timer_create().
|
||||
*
|
||||
* @param timer the timer
|
||||
*
|
||||
* @see api_timer_create
|
||||
*/
|
||||
typedef void (*on_user_timer_update_f)(user_timer_t timer);
|
||||
|
||||
/*
|
||||
*****************
|
||||
* Timer APIs
|
||||
*****************
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Create timer.
|
||||
*
|
||||
* @param interval timer interval
|
||||
* @param is_period whether the timer is periodic
|
||||
* @param auto_start whether start the timer immediately after created
|
||||
* @param on_timer_update callback function called when timer expired
|
||||
*
|
||||
* @return the timer created if success, NULL otherwise
|
||||
*/
|
||||
user_timer_t api_timer_create(int interval, bool is_period, bool auto_start,
|
||||
on_user_timer_update_f on_timer_update);
|
||||
|
||||
/**
|
||||
* @brief Cancel timer.
|
||||
*
|
||||
* @param timer the timer to cancel
|
||||
*/
|
||||
void api_timer_cancel(user_timer_t timer);
|
||||
|
||||
/**
|
||||
* @brief Restart timer.
|
||||
*
|
||||
* @param timer the timer to cancel
|
||||
* @param interval the timer interval
|
||||
*/
|
||||
void api_timer_restart(user_timer_t timer, int interval);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user