diff options
author | Damien George <damien.p.george@gmail.com> | 2014-09-03 22:31:08 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-09-03 22:31:08 +0100 |
commit | 91fbea2c1ec2012b6a7857930ca64cba1f9f9a56 (patch) | |
tree | 2112ee4a17967fe8bf1cedcc59d1934434bad309 /py/asmarm.c | |
parent | fc54250d3158bcd897d43187b822765fb97f369f (diff) | |
parent | b7235b8412a7511c94b31c0391eaf5c1b35ed3a8 (diff) |
Merge pull request #845 from Vogtinator/master
Add allocation macros (per platform) and ARM cache flush
Diffstat (limited to 'py/asmarm.c')
-rw-r--r-- | py/asmarm.c | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/py/asmarm.c b/py/asmarm.c index 8ba22faa0..fff95fddb 100644 --- a/py/asmarm.c +++ b/py/asmarm.c @@ -40,8 +40,8 @@ struct _asm_arm_t { uint pass; - uint code_offset; - uint code_size; + mp_uint_t code_offset; + mp_uint_t code_size; byte *code_base; byte dummy_data[4]; @@ -64,7 +64,7 @@ asm_arm_t *asm_arm_new(uint max_num_labels) { void asm_arm_free(asm_arm_t *as, bool free_code) { if (free_code) { - m_del(byte, as->code_base, as->code_size); + MP_PLAT_FREE_EXEC(as->code_base, as->code_size); } m_del_obj(asm_arm_t, as); @@ -80,9 +80,22 @@ void asm_arm_start_pass(asm_arm_t *as, uint pass) { void asm_arm_end_pass(asm_arm_t *as) { if (as->pass == ASM_ARM_PASS_COMPUTE) { - // calculate size of code in bytes - as->code_size = as->code_offset; - as->code_base = m_new(byte, as->code_size); + MP_PLAT_ALLOC_EXEC(as->code_offset, (void**) &as->code_base, &as->code_size); + if(as->code_base == NULL) { + assert(0); + } + } + else if(as->pass == ASM_ARM_PASS_EMIT) { +#ifdef __arm__ + // flush I- and D-cache + asm volatile( + "0:" + "mrc p15, 0, r15, c7, c10, 3\n" + "bne 0b\n" + "mov r0, #0\n" + "mcr p15, 0, r0, c7, c7, 0\n" + : : : "r0", "cc"); +#endif } } |