If your function doesn't need prologue, you can use the attribute "
no_prologue"
This is an example:
Code:
void _nds32_init_mem(void) __attribute__((no_prologue, optimize("Os")));
void _nds32_init_mem(void) //The function is weak (optional)
{
#ifdef CFG_AG102 // AG102
#ifndef CFG_NORAM
/* initialize DDR2 controller */
do {
NDS32_REG_WRITE(DDR2C_BASE + DDR2C_DCR_OFFSET, 0x000025cc); // SDRAM configure
NDS32_REG_WRITE(DDR2C_BASE + DDR2C_DTAR_OFFSET, 0x00100000); // Data training addr.
NDS32_REG_WRITE(DDR2C_BASE + DDR2C_DRR_OFFSET, 0x00034812); // Set refresh
NDS32_REG_WRITE(DDR2C_BASE + DDR2C_MR_OFFSET, 0x00000852); // Set mode
NDS32_REG_WRITE(DDR2C_BASE + DDR2C_IOCR_OFFSET, 0x0000000f); // Set IOCR
/*
* Enable host ports and trigger initialization
*/
NDS32_REG_WRITE(DDR2C_BASE + DDR2C_CCR_OFFSET, 0x80020000);
/* Wait for ddr init state to be set */
__nds32__isb();
/* Wait until the config initialization is finish */
while(NDS32_REG_READ(DDR2C_BASE + DDR2C_CSR_OFFSET) >> 23);
...
}
The objdump of _nds32_init_mem: (partial)
Code:
000004e4 <_nds32_init_mem>:
4e4: 46 10 01 51 sethi $r1,#0x151
4e8: 58 10 81 51 ori $r1,$r1,#0x151
4ec: 46 00 0e 01 sethi $r0,#0xe01
4f0: a8 41 swi333 $r1,[$r0+#0x4]
4f2: 46 10 00 10 sethi $r1,#0x10
4f6: 80 21 mov55 $r1,$r1
4f8: 46 20 0f 01 sethi $r2,#0xf01
4fc: 58 21 00 30 ori $r2,$r2,#0x30
......
It contains no prologue and no epilogue.