WebAssembly Micro Runtime first version
This commit is contained in:
44
core/shared-lib/include/bh_common.h
Executable file
44
core/shared-lib/include/bh_common.h
Executable file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef _BH_COMMON_H
|
||||
#define _BH_COMMON_H
|
||||
|
||||
#include "bh_assert.h"
|
||||
#include "bh_definition.h"
|
||||
#include "bh_platform.h"
|
||||
#include "bh_log.h"
|
||||
#include "bh_list.h"
|
||||
|
||||
#define bh_memcpy_s(dest, dlen, src, slen) do { \
|
||||
int _ret = slen == 0 ? 0 : b_memcpy_s (dest, dlen, src, slen); \
|
||||
(void)_ret; \
|
||||
bh_assert (_ret == 0); \
|
||||
} while (0)
|
||||
|
||||
#define bh_strcat_s(dest, dlen, src) do { \
|
||||
int _ret = b_strcat_s (dest, dlen, src); \
|
||||
(void)_ret; \
|
||||
bh_assert (_ret == 0); \
|
||||
} while (0)
|
||||
|
||||
#define bh_strcpy_s(dest, dlen, src) do { \
|
||||
int _ret = b_strcpy_s (dest, dlen, src); \
|
||||
(void)_ret; \
|
||||
bh_assert (_ret == 0); \
|
||||
} while (0)
|
||||
|
||||
#endif
|
||||
120
core/shared-lib/include/bh_list.h
Normal file
120
core/shared-lib/include/bh_list.h
Normal file
@ -0,0 +1,120 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef _BH_LIST_H
|
||||
#define _BH_LIST_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "korp_types.h" /*For bool type*/
|
||||
#include "bh_platform.h"
|
||||
|
||||
/* List user should embedded bh_list_link into list elem data structure
|
||||
* definition. And bh_list_link data field should be the first field.
|
||||
* For example, if we would like to use bh_list for our own data type A,
|
||||
* A must be defined as a structure like below:
|
||||
* struct A {
|
||||
* bh_list_link l;
|
||||
* ...
|
||||
* };
|
||||
*
|
||||
* bh_list_link is defined as a structure (not typedef void*).
|
||||
* It will make extend list into bi-direction easy.
|
||||
*/
|
||||
typedef struct _bh_list_link {
|
||||
struct _bh_list_link *next;
|
||||
} bh_list_link;
|
||||
|
||||
typedef struct _bh_list {
|
||||
bh_list_link head;
|
||||
uint32 len;
|
||||
} bh_list;
|
||||
|
||||
/* Beihai list operation return value */
|
||||
typedef enum _bh_list_status {
|
||||
BH_LIST_SUCCESS = 0, BH_LIST_ERROR = -1
|
||||
} bh_list_status;
|
||||
|
||||
/**
|
||||
* Initialize a list.
|
||||
*
|
||||
* @param list pointer to list.
|
||||
* @return <code>BH_LIST_ERROR</code> if OK;
|
||||
* <code>BH_LIST_ERROR</code> if list pointer is NULL.
|
||||
*/
|
||||
bh_list_status bh_list_init(bh_list *list);
|
||||
|
||||
/**
|
||||
* Insert an elem pointer into list. The list node memory is maintained by list while
|
||||
* elem memory is the responsibility of list user.
|
||||
*
|
||||
* @param list pointer to list.
|
||||
* @param elem pointer to elem that will be inserted into list.
|
||||
* @return <code>BH_LIST_ERROR</code> if OK;
|
||||
* <code>BH_LIST_ERROR</code> if input is invalid or no memory available.
|
||||
*/
|
||||
extern bh_list_status _bh_list_insert(bh_list *list, void *elem);
|
||||
|
||||
#ifdef _INSTRUMENT_TEST_ENABLED
|
||||
extern bh_list_status bh_list_insert_instr(bh_list *list, void *elem, const char*func_name);
|
||||
#define bh_list_insert(list, elem) bh_list_insert_instr(list, elem, __FUNCTION__)
|
||||
#else
|
||||
#define bh_list_insert _bh_list_insert
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Remove an elem pointer from list. The list node memory is maintained by list while
|
||||
* elem memory is the responsibility of list user.
|
||||
*
|
||||
* @param list pointer to list.
|
||||
* @param elem pointer to elem that will be inserted into list.
|
||||
* @return <code>BH_LIST_ERROR</code> if OK;
|
||||
* <code>BH_LIST_ERROR</code> if element does not exist in given list.
|
||||
*/
|
||||
bh_list_status bh_list_remove(bh_list *list, void *elem);
|
||||
|
||||
/**
|
||||
* Get the list length.
|
||||
*
|
||||
* @param list pointer to list.
|
||||
* @return the length of the list.
|
||||
*/
|
||||
uint32 bh_list_length(bh_list *list);
|
||||
|
||||
/**
|
||||
* Get the first elem in the list.
|
||||
*
|
||||
* @param list pointer to list.
|
||||
* @return pointer to the first node.
|
||||
*/
|
||||
void* bh_list_first_elem(bh_list *list);
|
||||
|
||||
/**
|
||||
* Get the next elem of given list input elem.
|
||||
*
|
||||
* @param node pointer to list node.
|
||||
* @return pointer to next list node.
|
||||
*/
|
||||
void* bh_list_elem_next(void *node);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* #ifndef _BH_LIST_H */
|
||||
|
||||
155
core/shared-lib/include/bh_log.h
Normal file
155
core/shared-lib/include/bh_log.h
Normal file
@ -0,0 +1,155 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**
|
||||
* @file bh_log.h
|
||||
* @date Tue Nov 8 18:19:10 2011
|
||||
*
|
||||
* @brief This log system supports wrapping multiple outputs into one
|
||||
* log message. This is useful for outputting variable-length logs
|
||||
* without additional memory overhead (the buffer for concatenating
|
||||
* the message), e.g. exception stack trace, which cannot be printed
|
||||
* by a single log calling without the help of an additional buffer.
|
||||
* Avoiding additional memory buffer is useful for resource-constraint
|
||||
* systems. It can minimize the impact of log system on applications
|
||||
* and logs can be printed even when no enough memory is available.
|
||||
* Functions with prefix "_" are private functions. Only macros that
|
||||
* are not start with "_" are exposed and can be used.
|
||||
*/
|
||||
|
||||
#ifndef _BH_LOG_H
|
||||
#define _BH_LOG_H
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "korp_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The following functions are the primitive operations of this log
|
||||
* system. A normal usage of the log system is to call bh_log_printf
|
||||
* or bh_log_vprintf one or multiple times and then call bh_log_commit
|
||||
* to wrap (mark) the previous outputs into one log message. The
|
||||
* bh_log and macros LOG_ERROR etc. can be used to output log messages
|
||||
* that can be wrapped into one log calling.
|
||||
*/
|
||||
int _bh_log_init(void);
|
||||
void _bh_log_set_verbose_level(int level);
|
||||
void _bh_log_printf(const char *fmt, ...);
|
||||
void _bh_log_vprintf(const char *fmt, va_list ap);
|
||||
void _bh_log_commit(void);
|
||||
|
||||
#if BEIHAI_ENABLE_LOG != 0
|
||||
# define bh_log_init() _bh_log_init ()
|
||||
# define bh_log_set_verbose_level(l) _bh_log_set_verbose_level (l)
|
||||
# define bh_log_printf(...) _bh_log_printf (__VA_ARGS__)
|
||||
# define bh_log_vprintf(...) _bh_log_vprintf (__VA_ARGS__)
|
||||
# define bh_log_commit() _bh_log_commit ()
|
||||
#else /* BEIHAI_ENABLE_LOG != 0 */
|
||||
# define bh_log_init() 0
|
||||
# define bh_log_set_verbose_level(l) (void)0
|
||||
# define bh_log_printf(...) (void)0
|
||||
# define bh_log_vprintf(...) (void)0
|
||||
# define bh_log_commit() (void)0
|
||||
#endif /* BEIHAI_ENABLE_LOG != 0 */
|
||||
|
||||
void _bh_log(const char *tag, const char *file, int line, const char *fmt, ...);
|
||||
|
||||
/* Always print fatal message */
|
||||
# define LOG_FATAL(...) _bh_log ("V0.", NULL, 0, __VA_ARGS__)
|
||||
|
||||
#if BEIHAI_ENABLE_LOG != 0
|
||||
# define LOG_ERROR(...) _bh_log ("V1.", NULL, 0, __VA_ARGS__)
|
||||
# define LOG_WARNING(...) _bh_log ("V2.", NULL, 0, __VA_ARGS__)
|
||||
# define LOG_INFO_RELEASE(...) _bh_log ("V3.", NULL, 0, __VA_ARGS__)
|
||||
# define LOG_INFO_APP_DEV(...) _bh_log ("V4.", NULL, 0, __VA_ARGS__)
|
||||
# define LOG_VERBOSE(...) _bh_log ("V5.", NULL, 0, __VA_ARGS__)
|
||||
# if BEIHAI_ENABLE_MEMORY_PROFILING != 0
|
||||
# define LOG_PROFILE(...) _bh_log ("V3.", NULL, 0, __VA_ARGS__)
|
||||
# else
|
||||
# define LOG_PROFILE(...) (void)0
|
||||
#endif
|
||||
# if BEIHAI_ENABLE_QUEUE_PROFILING != 0
|
||||
# define LOG_QUEUE_PROFILE(...) _bh_log ("V3.", NULL, 0, __VA_ARGS__)
|
||||
# else
|
||||
# define LOG_QUEUE_PROFILE(...) (void)0
|
||||
#endif
|
||||
# if BEIHAI_ENABLE_GC_STAT_PROFILING != 0
|
||||
# define LOG_GC_STAT_PROFILE(...) _bh_log ("V3.", NULL, 0, __VA_ARGS__)
|
||||
# else
|
||||
# define LOG_GC_STAT_PROFILE(...) (void)0
|
||||
#endif
|
||||
#else /* BEIHAI_ENABLE_LOG != 0 */
|
||||
# define LOG_ERROR(...) (void)0
|
||||
# define LOG_WARNING(...) (void)0
|
||||
# define LOG_INFO_APP_DEV(...) (void)0
|
||||
# define LOG_INFO_RELEASE(...) (void)0
|
||||
# define LOG_VERBOSE(...) (void)0
|
||||
# define LOG_PROFILE(...) (void)0
|
||||
# define LOG_QUEUE_PROFILE(...) (void)0
|
||||
# define LOG_GC_STAT_PROFILE(...) (void)0
|
||||
#endif /* BEIHAI_ENABLE_LOG != 0 */
|
||||
|
||||
#define LOG_PROFILE_INSTANCE_HEAP_CREATED(heap) \
|
||||
LOG_PROFILE ("PROF.INSTANCE.HEAP_CREATED: HEAP=%08X", heap)
|
||||
#define LOG_PROFILE_INSTANCE_THREAD_STARTED(heap) \
|
||||
LOG_PROFILE ("PROF.INSTANCE.THREAD_STARTED: HEAP=%08X", heap)
|
||||
#define LOG_PROFILE_HEAP_ALLOC(heap, size) \
|
||||
LOG_PROFILE ("PROF.HEAP.ALLOC: HEAP=%08X SIZE=%d", heap, size)
|
||||
#define LOG_PROFILE_HEAP_FREE(heap, size) \
|
||||
LOG_PROFILE ("PROF.HEAP.FREE: HEAP=%08X SIZE=%d", heap, size)
|
||||
#define LOG_PROFILE_HEAP_NEW(heap, size) \
|
||||
LOG_PROFILE ("PROF.HEAP.NEW: HEAP=%08X SIZE=%d", heap, size)
|
||||
#define LOG_PROFILE_HEAP_GC(heap, size) \
|
||||
LOG_PROFILE ("PROF.HEAP.GC: HEAP=%08X SIZE=%d", heap, size)
|
||||
#define LOG_PROFILE_STACK_PUSH(used) \
|
||||
LOG_PROFILE ("PROF.STACK.PUSH: USED=%d", used)
|
||||
#define LOG_PROFILE_STACK_POP() \
|
||||
LOG_PROFILE ("PROF.STACK.POP")
|
||||
|
||||
/* Please add your component ahead of LOG_COM_MAX */
|
||||
enum {
|
||||
LOG_COM_APP_MANAGER = 0,
|
||||
LOG_COM_GC,
|
||||
LOG_COM_HMC,
|
||||
LOG_COM_UTILS,
|
||||
LOG_COM_VERIFIER_JEFF,
|
||||
LOG_COM_VMCORE_JEFF,
|
||||
LOG_COM_MAX
|
||||
};
|
||||
|
||||
#if defined(BH_DEBUG)
|
||||
void log_parse_coms(const char *coms);
|
||||
int bh_log_dcom_is_enabled(int component);
|
||||
|
||||
#define LOG_DEBUG(component, ...) do { \
|
||||
if (bh_log_dcom_is_enabled (component)) \
|
||||
_bh_log ("V6: ", __FILE__, __LINE__, __VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
#else /* defined(BH_DEBUG) */
|
||||
|
||||
#define LOG_DEBUG(component, ...) (void)0
|
||||
|
||||
#endif /* defined(BH_DEBUG) */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _BH_LOG_H */
|
||||
76
core/shared-lib/include/bh_memory.h
Normal file
76
core/shared-lib/include/bh_memory.h
Normal file
@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef _BH_MEMORY_H
|
||||
#define _BH_MEMORY_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define BH_KB (1024)
|
||||
#define BH_MB ((BH_KB)*1024)
|
||||
#define BH_GB ((BH_MB)*1024)
|
||||
|
||||
/**
|
||||
* Initialize memory allocator with a pool, the bh_malloc/bh_free function
|
||||
* will malloc/free memory from the pool
|
||||
*
|
||||
* @param mem the pool buffer
|
||||
* @param bytes the size bytes of the buffer
|
||||
*
|
||||
* @return 0 if success, -1 otherwise
|
||||
*/
|
||||
int bh_memory_init_with_pool(void *mem, unsigned int bytes);
|
||||
|
||||
/**
|
||||
* Initialize memory allocator with memory allocator, the bh_malloc/bh_free
|
||||
* function will malloc/free memory with the allocator passed
|
||||
*
|
||||
* @param malloc_func the malloc function
|
||||
* @param free_func the free function
|
||||
*
|
||||
* @return 0 if success, -1 otherwise
|
||||
*/
|
||||
int bh_memory_init_with_allocator(void *malloc_func, void *free_func);
|
||||
|
||||
/**
|
||||
* Destroy memory
|
||||
*/
|
||||
void bh_memory_destroy();
|
||||
|
||||
/**
|
||||
* This function allocates a memory chunk from system
|
||||
*
|
||||
* @param size bytes need allocate
|
||||
*
|
||||
* @return the pointer to memory allocated
|
||||
*/
|
||||
void* bh_malloc(unsigned int size);
|
||||
|
||||
/**
|
||||
* This function frees memory chunk
|
||||
*
|
||||
* @param ptr the pointer to memory need free
|
||||
*/
|
||||
void bh_free(void *ptr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* #ifndef _BH_MEMORY_H */
|
||||
|
||||
99
core/shared-lib/include/bh_queue.h
Normal file
99
core/shared-lib/include/bh_queue.h
Normal file
@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef _BH_QUEUE_H
|
||||
#define _BH_QUEUE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "korp_types.h" /*For bool type*/
|
||||
#include "bh_platform.h"
|
||||
|
||||
struct _bh_queue_node;
|
||||
typedef struct _bh_queue_node * bh_message_t;
|
||||
struct bh_queue;
|
||||
typedef struct bh_queue bh_queue;
|
||||
|
||||
typedef void (*bh_queue_handle_msg_callback)(void *message);
|
||||
|
||||
#define bh_queue_malloc bh_malloc
|
||||
#define bh_queue_free bh_free
|
||||
|
||||
#define bh_queue_mutex korp_mutex
|
||||
#define bh_queue_sem korp_sem
|
||||
#define bh_queue_cond korp_cond
|
||||
|
||||
#define bh_queue_mutex_init vm_mutex_init
|
||||
#define bh_queue_mutex_destroy vm_mutex_destroy
|
||||
#define bh_queue_mutex_lock vm_mutex_lock
|
||||
#define bh_queue_mutex_unlock vm_mutex_unlock
|
||||
|
||||
#define bh_queue_sem_init vm_sem_init
|
||||
#define bh_queue_sem_destroy vm_sem_destroy
|
||||
#define bh_queue_sem_wait vm_sem_wait
|
||||
#define bh_queue_sem_reltimedwait vm_sem_reltimedwait
|
||||
#define bh_queue_sem_post vm_sem_post
|
||||
|
||||
#define bh_queue_cond_init vm_cond_init
|
||||
#define bh_queue_cond_destroy vm_cond_destroy
|
||||
#define bh_queue_cond_wait vm_cond_wait
|
||||
#define bh_queue_cond_timedwait vm_cond_reltimedwait
|
||||
#define bh_queue_cond_signal vm_cond_signal
|
||||
#define bh_queue_cond_broadcast vm_cond_broadcast
|
||||
|
||||
typedef void (*bh_msg_cleaner)(void *msg);
|
||||
|
||||
bh_queue *
|
||||
bh_queue_create();
|
||||
|
||||
void
|
||||
bh_queue_destroy(bh_queue *queue);
|
||||
|
||||
char * bh_message_payload(bh_message_t message);
|
||||
int bh_message_payload_len(bh_message_t message);
|
||||
int bh_message_type(bh_message_t message);
|
||||
|
||||
bh_message_t bh_new_msg(unsigned short tag, void *body, unsigned int len,
|
||||
void * handler);
|
||||
void bh_free_msg(bh_message_t msg);
|
||||
bool bh_post_msg(bh_queue *queue, unsigned short tag, void *body,
|
||||
unsigned int len);
|
||||
bool bh_post_msg2(bh_queue *queue, bh_message_t msg);
|
||||
|
||||
bh_message_t bh_get_msg(bh_queue *queue, int timeout);
|
||||
|
||||
unsigned
|
||||
bh_queue_get_message_count(bh_queue *queue);
|
||||
|
||||
void
|
||||
bh_queue_enter_loop_run(bh_queue *queue,
|
||||
bh_queue_handle_msg_callback handle_cb);
|
||||
|
||||
void
|
||||
bh_queue_enter_loop_run1(bh_queue *queue,
|
||||
bh_queue_handle_msg_callback handle_cb);
|
||||
|
||||
void
|
||||
bh_queue_exit_loop_run(bh_queue *queue);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* #ifndef _BH_QUEUE_H */
|
||||
|
||||
90
core/shared-lib/include/config.h
Normal file
90
core/shared-lib/include/config.h
Normal file
@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef _CONFIG_H_
|
||||
|
||||
/* Memory allocator ems */
|
||||
#define MEM_ALLOCATOR_EMS 0
|
||||
|
||||
/* Memory allocator tlsf */
|
||||
#define MEM_ALLOCATOR_TLSF 1
|
||||
|
||||
/* Default memory allocator */
|
||||
#define DEFAULT_MEM_ALLOCATOR MEM_ALLOCATOR_EMS
|
||||
|
||||
/* Beihai log system */
|
||||
#define BEIHAI_ENABLE_LOG 1
|
||||
|
||||
/* Beihai debugger support */
|
||||
#define BEIHAI_ENABLE_TOOL_AGENT 1
|
||||
|
||||
/* Beihai debug monitoring server, must define
|
||||
BEIHAI_ENABLE_TOOL_AGENT firstly */
|
||||
#define BEIHAI_ENABLE_TOOL_AGENT_BDMS 1
|
||||
|
||||
/* enable no signature on sdv since verify doesn't work as lacking public key */
|
||||
#ifdef CONFIG_SDV
|
||||
#define BEIHAI_ENABLE_NO_SIGNATURE 1
|
||||
#else
|
||||
#define BEIHAI_ENABLE_NO_SIGNATURE 0
|
||||
#endif
|
||||
|
||||
/* WASM VM log system */
|
||||
#define WASM_ENABLE_LOG 1
|
||||
|
||||
/* WASM Interpreter labels-as-values feature */
|
||||
#define WASM_ENABLE_LABELS_AS_VALUES 1
|
||||
|
||||
/* Heap and stack profiling */
|
||||
#define BEIHAI_ENABLE_MEMORY_PROFILING 0
|
||||
|
||||
/* Max app number of all modules */
|
||||
#define MAX_APP_INSTALLATIONS 3
|
||||
|
||||
/* Default timer number in one app */
|
||||
#define DEFAULT_TIMERS_PER_APP 20
|
||||
|
||||
/* Max timer number in one app */
|
||||
#define MAX_TIMERS_PER_APP 30
|
||||
|
||||
/* Max resource registration number in one app */
|
||||
#define RESOURCE_REGISTRATION_NUM_MAX 16
|
||||
|
||||
/* Max length of resource/event url */
|
||||
#define RESOUCE_EVENT_URL_LEN_MAX 256
|
||||
|
||||
/* Default length of queue */
|
||||
#define DEFAULT_QUEUE_LENGTH 50
|
||||
|
||||
/* Default watchdog interval in ms */
|
||||
#define DEFAULT_WATCHDOG_INTERVAL (3 * 60 * 1000)
|
||||
|
||||
/* Workflow heap size */
|
||||
/*
|
||||
#define WORKING_FLOW_HEAP_SIZE 0
|
||||
*/
|
||||
|
||||
/* Default/min/max heap size of each app */
|
||||
#define APP_HEAP_SIZE_DEFAULT (48 * 1024)
|
||||
#define APP_HEAP_SIZE_MIN (2 * 1024)
|
||||
#define APP_HEAP_SIZE_MAX (1024 * 1024)
|
||||
|
||||
/* Default/min/max stack size of each app thread */
|
||||
#define APP_THREAD_STACK_SIZE_DEFAULT (20 * 1024)
|
||||
#define APP_THREAD_STACK_SIZE_MIN (16 * 1024)
|
||||
#define APP_THREAD_STACK_SIZE_MAX (256 * 1024)
|
||||
|
||||
#endif
|
||||
89
core/shared-lib/include/errcode.h
Executable file
89
core/shared-lib/include/errcode.h
Executable file
@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**
|
||||
* @file errcode.h
|
||||
* @date Wed Feb 29 18:58:30 2012
|
||||
*
|
||||
* @brief Host-visible error code definition
|
||||
*/
|
||||
|
||||
#ifndef BEIHAI_ERRCODE_H
|
||||
#define BEIHAI_ERRCODE_H
|
||||
|
||||
/**
|
||||
* Responses to all remote requests from host to Beihai runtime has a
|
||||
* return error code, which is used to indicate the processing result:
|
||||
* successful or any error occurs. The following definitions include
|
||||
* all those error codes that may be returned to host.
|
||||
*/
|
||||
enum {
|
||||
BHE_SUCCESS = 0x000, /* Successful */
|
||||
|
||||
/* General errors: 0x100 */
|
||||
BHE_OUT_OF_MEMORY = 0x101, /* Out of memory */
|
||||
BHE_BAD_PARAMETER = 0x102, /* Bad parameters to native */
|
||||
BHE_INSUFFICIENT_BUFFER = 0x103,
|
||||
BHE_MUTEX_INIT_FAIL = 0x104,
|
||||
BHE_COND_INIT_FAIL = 0x105, /* Cond init fail is not return to
|
||||
* host now, it may be used later.
|
||||
*/
|
||||
BHE_WD_TIMEOUT = 0x106, /* Watchdog time out */
|
||||
|
||||
/* Communication: 0x200 */
|
||||
BHE_MAILBOX_NOT_FOUND = 0x201, /* Mailbox not found */
|
||||
BHE_MSG_QUEUE_IS_FULL = 0x202, /* Message queue is full */
|
||||
BHE_MAILBOX_DENIED = 0x203, /* Mailbox is denied by firewall */
|
||||
|
||||
/* Applet manager: 0x300 */
|
||||
BHE_LOAD_JEFF_FAIL = 0x303, /* JEFF file load fail, OOM or file
|
||||
* format error not distinct by
|
||||
* current JEFF loading
|
||||
* process (bool jeff_loader_load).
|
||||
*/
|
||||
BHE_PACKAGE_NOT_FOUND = 0x304, /* Request operation on a package,
|
||||
* but it does not exist.
|
||||
*/
|
||||
BHE_EXIST_LIVE_SESSION = 0x305, /* Uninstall package fail because of
|
||||
* live session exist.
|
||||
*/
|
||||
BHE_VM_INSTANCE_INIT_FAIL = 0x306, /* VM instance init fail when create
|
||||
* session.
|
||||
*/
|
||||
BHE_QUERY_PROP_NOT_SUPPORT = 0x307, /* Query applet property that Beihai
|
||||
* does not support.
|
||||
*/
|
||||
BHE_INVALID_BPK_FILE = 0x308, /* Incorrect Beihai package format */
|
||||
|
||||
BHE_VM_INSTNACE_NOT_FOUND = 0x312, /* VM instance not found */
|
||||
BHE_STARTING_JDWP_FAIL = 0x313, /* JDWP agent starting fail */
|
||||
BHE_GROUP_CHECK_FAIL = 0x314, /* Group access checking fail*/
|
||||
|
||||
/* Applet instance: 0x400 */
|
||||
BHE_UNCAUGHT_EXCEPTION = 0x401, /* uncaught exception */
|
||||
BHE_APPLET_BAD_PARAMETER = 0x402, /* Bad parameters to applet */
|
||||
BHE_APPLET_SMALL_BUFFER = 0x403, /* Small response buffer */
|
||||
|
||||
/*TODO: Should be removed these UI error code when integrate with ME 9 */
|
||||
/* UI: 0x500 */
|
||||
BHE_UI_EXCEPTION = 0x501,
|
||||
BHE_UI_ILLEGAL_USE = 0x502,
|
||||
BHE_UI_ILLEGAL_PARAMETER = 0x503,
|
||||
BHE_UI_NOT_INITIALIZED = 0x504,
|
||||
BHE_UI_NOT_SUPPORTED = 0x505,
|
||||
BHE_UI_OUT_OF_RESOURCES = 0x506
|
||||
};
|
||||
|
||||
#endif
|
||||
160
core/shared-lib/include/korp_types.h
Executable file
160
core/shared-lib/include/korp_types.h
Executable file
@ -0,0 +1,160 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef _KORP_TYPES_H
|
||||
#define _KORP_TYPES_H
|
||||
|
||||
#include "bh_platform.h"
|
||||
/* all types used in kORP should be explicit sized */
|
||||
typedef struct _korp_object korp_object;
|
||||
|
||||
typedef unsigned int obj_info;
|
||||
typedef korp_object* ref;
|
||||
|
||||
#define BYTES_OF_OBJ_INFO 4
|
||||
#define BYTES_OF_REF 4
|
||||
|
||||
/* don't change the number, it's hardcoded in kORP */
|
||||
enum _korp_array_type {
|
||||
ARRAY_UINT8 = 0, /* bytes_of_uint8 = 1 << ARRAY_UINT8 */
|
||||
ARRAY_UINT16 = 1, /* bytes_of_uint16 = 1 << ARRAY_UINT16 */
|
||||
ARRAY_UINT32 = 2, /* bytes_of_uint32 = 1 << ARRAY_UINT32 */
|
||||
ARRAY_UINT64 = 3, /* bytes_of_uint64 = 1 << ARRAY_UINT64 */
|
||||
ARRAY_BOOLEAN = 4,
|
||||
ARRAY_CHAR = 5,
|
||||
ARRAY_FLOAT = 6,
|
||||
ARRAY_DOUBLE = 7,
|
||||
ARRAY_BYTE = 8,
|
||||
ARRAY_SHORT = 9,
|
||||
ARRAY_INT = 10,
|
||||
ARRAY_LONG = 11,
|
||||
ARRAY_REF = 12 /* for calculation */
|
||||
};
|
||||
|
||||
enum _korp_java_type {
|
||||
JAVA_TYPE_WRONG = 0,
|
||||
JAVA_TYPE_BYTE = 'B',
|
||||
JAVA_TYPE_CHAR = 'C',
|
||||
JAVA_TYPE_DOUBLE = 'D',
|
||||
JAVA_TYPE_FLOAT = 'F',
|
||||
JAVA_TYPE_INT = 'I',
|
||||
JAVA_TYPE_LONG = 'J',
|
||||
JAVA_TYPE_SHORT = 'S',
|
||||
JAVA_TYPE_BOOLEAN = 'Z',
|
||||
JAVA_TYPE_CLASS = 'L',
|
||||
JAVA_TYPE_ARRAY = '[',
|
||||
JAVA_TYPE_VOID = 'V',
|
||||
JAVA_TYPE_STRING = '$' /* for TAG_String const value */
|
||||
};
|
||||
|
||||
enum korp_modifier_type {
|
||||
MOD_PUBLIC = 0x0001, /* Class Field Method */
|
||||
MOD_PRIVATE = 0x0002, /* Field Method */
|
||||
MOD_PROTECTED = 0x0004, /* Field Method */
|
||||
MOD_STATIC = 0x0008, /* Field Method */
|
||||
MOD_FINAL = 0x0010, /* Class Field Method */
|
||||
MOD_SUPER = 0x0020, /* Class */
|
||||
MOD_SYNCHRONIZED = 0x0020, /* Method */
|
||||
MOD_VOLATILE = 0x0040, /* Field */
|
||||
MOD_TRANSIENT = 0x0080, /* Field */
|
||||
MOD_NATIVE = 0x0100, /* Method */
|
||||
MOD_INTERFACE = 0x0200, /* Class */
|
||||
MOD_ABSTRACT = 0x0400, /* Class Method */
|
||||
MOD_STRICT = 0x0800 /* Method */
|
||||
};
|
||||
|
||||
/* object header, used to access object info */
|
||||
struct _korp_object {
|
||||
obj_info header; /* object header (I) */
|
||||
};
|
||||
|
||||
#define HASH_TABLE_SIZE 359
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL (void*)0
|
||||
#endif
|
||||
|
||||
#define KORP_ERROR (-1)
|
||||
|
||||
#ifndef __cplusplus
|
||||
#define true 1
|
||||
#define false 0
|
||||
#define inline __inline
|
||||
#endif
|
||||
|
||||
/* forwarded declarations */
|
||||
typedef struct _korp_string_pool korp_string_pool;
|
||||
typedef struct _korp_class_table korp_class_table;
|
||||
|
||||
typedef enum _korp_loader_exception {
|
||||
LD_OK = 0,
|
||||
LD_NoClassDefFoundError,
|
||||
LD_ClassFormatError,
|
||||
LD_ClassCircularityError,
|
||||
LD_IncompatibleClassChangeError,
|
||||
LD_AbstractMethodError, /* occurs during preparation */
|
||||
LD_IllegalAccessError,
|
||||
LD_InstantiationError,
|
||||
LD_NoSuchFieldError,
|
||||
LD_NoSuchMethodError,
|
||||
LD_UnsatisfiedLinkError,
|
||||
LD_VerifyError
|
||||
} korp_loader_exception;
|
||||
|
||||
typedef enum _korp_java_type korp_java_type;
|
||||
typedef enum _korp_array_type korp_array_type;
|
||||
|
||||
/* typedef struct _korp_thread korp_thread; */
|
||||
typedef struct _korp_method korp_method;
|
||||
typedef struct _korp_field korp_field;
|
||||
typedef struct _korp_class korp_class;
|
||||
typedef struct _korp_string korp_string;
|
||||
typedef struct _korp_package korp_package;
|
||||
typedef struct _korp_class_loader korp_class_loader;
|
||||
typedef struct _korp_ref_array korp_ref_array;
|
||||
|
||||
typedef struct _korp_entry korp_entry;
|
||||
typedef struct _korp_preloaded korp_preloaded;
|
||||
typedef struct _korp_env korp_env;
|
||||
|
||||
typedef struct _korp_java_array korp_java_array;
|
||||
typedef struct _korp_uint8_array korp_uint8_array;
|
||||
|
||||
typedef struct _korp_vm_thread_list korp_vm_thread_list;
|
||||
|
||||
#define korp_uint8 korp_uint32
|
||||
#define korp_uint16 korp_uint32
|
||||
#define korp_boolean korp_uint32
|
||||
#define korp_char korp_uint32
|
||||
#define korp_short korp_uint32
|
||||
#define korp_int korp_uint32
|
||||
#define korp_float korp_uint32
|
||||
|
||||
#define korp_long korp_uint64
|
||||
#define korp_double korp_uint64
|
||||
|
||||
#define korp_boolean_array korp_uint8_array
|
||||
#define korp_char_array korp_uint8_array
|
||||
#define korp_short_array korp_uint16_array
|
||||
#define korp_int_array korp_uint32_array
|
||||
#define korp_float_array korp_uint32_array
|
||||
#define korp_double_array korp_uint64_array
|
||||
#define korp_long_array korp_uint64_array
|
||||
|
||||
#define korp_code korp_uint8_array
|
||||
|
||||
#endif /* #ifndef _KORP_TYPES_H */
|
||||
|
||||
45
core/shared-lib/include/mem_alloc.h
Normal file
45
core/shared-lib/include/mem_alloc.h
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __MEM_ALLOC_H
|
||||
#define __MEM_ALLOC_H
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef void *mem_allocator_t;
|
||||
|
||||
mem_allocator_t
|
||||
mem_allocator_create(void *mem, uint32_t size);
|
||||
|
||||
void
|
||||
mem_allocator_destroy(mem_allocator_t allocator);
|
||||
|
||||
void *
|
||||
mem_allocator_malloc(mem_allocator_t allocator, uint32_t size);
|
||||
|
||||
void
|
||||
mem_allocator_free(mem_allocator_t allocator, void *ptr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* #ifndef __MEM_ALLOC_H */
|
||||
|
||||
Reference in New Issue
Block a user