mirror of https://github.com/ARMmbed/mbed-os.git
Change CThunk method for Cortex-A
thumb2 code executes invalid ram space, and it causes crash Add instruction cache clean codespull/1626/head
parent
6d3e9e32bf
commit
c5422eed25
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
#define CTHUNK_ADDRESS 1
|
#define CTHUNK_ADDRESS 1
|
||||||
|
|
||||||
#if defined(__CORTEX_M3) || defined(__CORTEX_M4) || defined(__CORTEX_A9) || defined(__thumb2__)
|
#if (defined(__CORTEX_M3) || defined(__CORTEX_M4) || defined(__thumb2__)) && ! defined(__CORTEX_A9)
|
||||||
#define CTHUNK_VARIABLES volatile uint32_t code[1]
|
#define CTHUNK_VARIABLES volatile uint32_t code[1]
|
||||||
/**
|
/**
|
||||||
* CTHUNK disassembly for Cortex-M3/M4 (thumb2):
|
* CTHUNK disassembly for Cortex-M3/M4 (thumb2):
|
||||||
|
@ -38,7 +38,7 @@
|
||||||
*/
|
*/
|
||||||
#define CTHUNK_ASSIGMENT m_thunk.code[0] = 0x8007E89F
|
#define CTHUNK_ASSIGMENT m_thunk.code[0] = 0x8007E89F
|
||||||
|
|
||||||
#elif defined(__CORTEX_M0PLUS) || defined(__CORTEX_M0)
|
#elif defined(__CORTEX_M0PLUS) || defined(__CORTEX_M0) || defined(__CORTEX_A9)
|
||||||
/*
|
/*
|
||||||
* CTHUNK disassembly for Cortex M0 (thumb):
|
* CTHUNK disassembly for Cortex M0 (thumb):
|
||||||
* * push {r0,r1,r2,r3,r4,lr} save touched registers and return address
|
* * push {r0,r1,r2,r3,r4,lr} save touched registers and return address
|
||||||
|
@ -196,14 +196,20 @@ class CThunk
|
||||||
|
|
||||||
#if defined(__CORTEX_A9)
|
#if defined(__CORTEX_A9)
|
||||||
/* Data cache clean */
|
/* Data cache clean */
|
||||||
|
/* Cache control */
|
||||||
{
|
{
|
||||||
uint32_t start_addr = (uint32_t)&m_thunk & 0xFFFFFFE0;
|
uint32_t start_addr = (uint32_t)&m_thunk & 0xFFFFFFE0;
|
||||||
uint32_t end_addr = ((uint32_t)&m_thunk + sizeof(m_thunk));
|
uint32_t end_addr = (uint32_t)&m_thunk + sizeof(m_thunk);
|
||||||
uint32_t addr;
|
uint32_t addr;
|
||||||
|
|
||||||
|
/* Data cache clean and invalid */
|
||||||
for (addr = start_addr; addr < end_addr; addr += 0x20) {
|
for (addr = start_addr; addr < end_addr; addr += 0x20) {
|
||||||
__v7_clean_inv_dcache_mva((void *)addr);
|
__v7_clean_inv_dcache_mva((void *)addr);
|
||||||
}
|
}
|
||||||
|
/* Instruction cache invalid */
|
||||||
|
__v7_inv_icache_all();
|
||||||
|
__ca9u_inv_tlb_all();
|
||||||
|
__v7_inv_btac();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
__ISB();
|
__ISB();
|
||||||
|
|
Loading…
Reference in New Issue