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:
@ -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
|
||||
}
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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)
|
||||
|
||||
Reference in New Issue
Block a user