Enable ARM and THUMB AOT support, enable Android platform support (#182)

* Sync with internal/feature: enable arm aot and android platform
This commit is contained in:
wenyongh
2020-02-27 16:38:44 +08:00
committed by GitHub
parent 4dbe7c44d0
commit 9a961c4843
52 changed files with 2466 additions and 466 deletions

View File

@ -8,6 +8,9 @@
#include "bh_common.h"
#include <stdlib.h>
#include <string.h>
#ifdef CONFIG_ARM_MPU
#include <arch/arm/aarch32/cortex_m/cmsis.h>
#endif
char *bh_strdup(const char *s)
{
@ -22,6 +25,28 @@ char *bh_strdup(const char *s)
return s1;
}
#ifdef CONFIG_ARM_MPU
/**
* This function will allow execute from sram region.
* This is needed for AOT code because by default all soc will
* disable the execute from SRAM.
*/
static void
disable_mpu_rasr_xn(void)
{
u32_t index;
/* Kept the max index as 8 (irrespective of soc) because the sram
would most likely be set at index 2. */
for (index = 0U; index < 8; index++) {
MPU->RNR = index;
if (MPU->RASR & MPU_RASR_XN_Msk) {
MPU->RASR |= ~MPU_RASR_XN_Msk;
}
}
}
#endif /* end of CONFIG_ARM_MPU */
static int
_stdout_hook_iwasm(int c)
{
@ -34,6 +59,14 @@ int bh_platform_init()
extern void __stdout_hook_install(int (*hook)(int));
/* Enable printf() in Zephyr */
__stdout_hook_install(_stdout_hook_iwasm);
#if WASM_ENABLE_AOT != 0
#ifdef CONFIG_ARM_MPU
/* Enable executable memory support */
disable_mpu_rasr_xn();
#endif
#endif
return 0;
}
@ -54,3 +87,14 @@ bh_mprotect(void *addr, uint32 size, int prot)
{
return 0;
}
void
bh_dcache_flush()
{
#if defined(CONFIG_CPU_CORTEX_M7)
uint32 key;
key = irq_lock();
SCB_CleanDCache();
irq_unlock(key);
#endif
}

View File

@ -153,5 +153,6 @@ enum {
void *bh_mmap(void *hint, unsigned int size, int prot, int flags);
void bh_munmap(void *addr, uint32 size);
int bh_mprotect(void *addr, uint32 size, int prot);
void bh_dcache_flush();
#endif

View File

@ -404,8 +404,8 @@ void vm_mutex_unlock(korp_mutex *mutex)
int _vm_sem_init(korp_sem* sem, unsigned int c)
{
k_sem_init(sem, 0, c);
return BHT_OK;
int ret = k_sem_init(sem, 0, c);
return ret == 0 ? BHT_OK : BHT_ERROR;
}
int _vm_sem_destroy(korp_sem *sem)