Example #1
0
void __attribute__ ((optimize("Os"))) __cpu_init()
{
	unsigned int tmp;

	/* turn on BTB */
	tmp = 0x0;
	__nds32__mtsr(tmp, NDS32_SR_MISC_CTL);

#if defined(NDS32_BASELINE_V3M) && defined(USE_C_EXT)
	/* set IVIC, vector size: 16 bytes, base: 0x0
	 * If we use v3m toolchain and want to use
	 * C extension please use USE_C_EXT in CFLAGS
	 */
	__nds32__mtsr(0x4001, NDS32_SR_IVB);
#else
	/* set IVIC, vector size: 4 bytes, base: 0x0
	 * If we use v3m toolchain and want to use
	 * assembly version please don't use USE_C_EXT
	 * in CFLAGS */
	__nds32__mtsr(0x0, NDS32_SR_IVB);
#endif
	/* Set PSW INTL to 0 */
	tmp = __nds32__mfsr(NDS32_SR_PSW);
	tmp = tmp & 0xfffffff9;
#if (defined(NDS32_BASELINE_V3M) || defined(NDS32_BASELINE_V3))
	/* Set PSW CPL to 7 to allow any priority */
	tmp = tmp | 0x70008;
#endif
	__nds32__mtsr(tmp, NDS32_SR_PSW);
	__nds32__dsb();
#if (defined(NDS32_BASELINE_V3M) || defined(NDS32_BASELINE_V3))
	/* Set PPL2FIX_EN to 0 to enable Programmable 
	 * Priority Level */
	__nds32__mtsr(0x0, NDS32_SR_INT_CTRL);
	/* set priority HW0: 0, HW1: 1, HW2: 2, HW3: 3 
	 * HW4-: 0 */
	__nds32__mtsr(0xe4, NDS32_SR_INT_PRI);
#endif
	/* enable FPU if the CPU support FPU */
#if defined(NDS32_EXT_FPU_DP) || defined(NDS32_EXT_FPU_SP)
	tmp = __nds32__mfsr(NDS32_SR_FUCOP_EXIST);
	if ((tmp & 0x80000001) == 0x80000001) {
		tmp = __nds32__mfsr(NDS32_SR_FUCOP_CTL);
		__nds32__mtsr((tmp | 0x1), NDS32_SR_FUCOP_CTL);
	}
#endif
	return;
}
void _nds32_init_mem(void) //The function is weak (optional)
{

    /* System without SDRAM. Use data local memory as system memory. */
    extern char __data_start;
    register unsigned int dlmsize;

    dlmsize = DLM_SIZE;//0x1000 << ((__nds32__mfsr(NDS32_SR_DLMB) >> 1) & 0xf);

#ifndef DLM_8K
    __nds32__mtsr(ILM_BASE|1, NDS32_SR_ILMB);
    __nds32__isb();
#endif
    /* Set DLM base to .data start address and enable it */
    __nds32__mtsr(DLM_BASE|1, NDS32_SR_DLMB);//__nds32__mtsr((unsigned)&__data_start|1, NDS32_SR_DLMB);
    __nds32__dsb();

    /* Update stack pointer to end of DLM
     * We suppose the .data + .bss + stack less then DLM size */
    __nds32__set_current_sp((unsigned)&__data_start + dlmsize);

}
Example #3
0
void _nds32_init_mem(void)
{
	/* Enable DLM */
	__nds32__mtsr(EDLM_BASE | 0x1, NDS32_SR_DLMB);
	__nds32__dsb();
}