⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bootinit.c

📁 motorola mpc系列 mpc852cpu bsp
💻 C
📖 第 1 页 / 共 2 页
字号:
    }

    if( 0x12345678 != *(unsigned long *)(0x00000000) )
    {
        *PCDAT(INTERNAL_MEM_MAP_ADDR) &= ~PC13;

       
    }

    for(i = 0x00000004; i < LOCAL_MEM_BANK_SIZE; i = i << 1)
    {
        if (*(unsigned long *)(i + 0x00000000) != i)
        {
            *PCDAT(INTERNAL_MEM_MAP_ADDR) &= ~PC13;
        }
    }

    *PCDAT(INTERNAL_MEM_MAP_ADDR) &= ~PB15;
    loop = 0x1ffff;
    while(loop != 0)
    {
        loop--;
    }
    *PCDAT(INTERNAL_MEM_MAP_ADDR) |= PC15;
        loop = 0x1ffff;
    while(loop != 0)
    {
        loop--;
    }

}
   


    while(1)
    {

        for( i = 0x00000000; i < LOCAL_MEM_BANK_SIZE - 4; i += 4 )
        {
            *(unsigned long *)(i) = i;
            if (i%0x00100000 == 0)
            {
                if (i%0x00100000 == 0)
                {
                    *PCDAT(INTERNAL_MEM_MAP_ADDR) &= ~PC15;
                    loop = 0x1ffff;
                    while(loop != 0)
                    {
                        loop--;
                    }
                    *PCDAT(INTERNAL_MEM_MAP_ADDR) |= PC15;
                    loop = 0x1ffff;
                    while(loop != 0)
                    {
                        loop--;
                    }
                }
            }
        }
        for( i = 0x00000000; i < LOCAL_MEM_BANK_SIZE - 4; i += 4 )
        {
            if (*(unsigned long *)(i) != i)
            {
                *PCDAT(INTERNAL_MEM_MAP_ADDR) &= ~PC13;
            }
            if (i%0x00100000 == 0)
            {
                *PCDAT(INTERNAL_MEM_MAP_ADDR) &= ~PC13;
                loop = 0x1ffff;
                while(loop != 0)
                {
                    loop--;
                }
                *PCDAT(INTERNAL_MEM_MAP_ADDR) |= PC13;
                loop = 0x1ffff;
                while(loop != 0)
                {
                    loop--;
                }
            }
        }

        *PCDAT(INTERNAL_MEM_MAP_ADDR) &= ~PC15;
        for(;;)
        {
        }

    }



}
#endif

#ifdef ROM_RESIDENT
    /* If ROM resident code, then copy only data segment
     * from ROM to RAM, initialize memory and jump
     * to usrInit.
     */

#if  (CPU_FAMILY == SPARC)
    copyLongs ((UINT *)(etext + 8), (UINT *) RESIDENT_DATA,
#elif    ((CPU_FAMILY == MIPS) || (CPU_FAMILY == PPC))
    copyLongs ((UINT *)(etext + 0), (UINT *) RESIDENT_DATA,
#else
    copyLongs ((UINT *)(etext + 4), (UINT *) RESIDENT_DATA,
#endif
               ((UINT) edata - (UINT) RESIDENT_DATA) / sizeof (long));

#else   /* ROM_RESIDENT */

#ifdef UNCOMPRESS       /* defined in makefile , valid*/

#if (CPU_FAMILY == MIPS)

     /* copy text to uncached locations to avoid problems with
     *  copy back caches */

    ((FUNCPTR)ROM_OFFSET(copyLongs)) (ROM_TEXT_ADRS, (UINT)K0_TO_K1(romInit),
        ROM_COPY_SIZE / sizeof (long));
#else   /* CPU_FAMILY == MIPS */
    ((FUNCPTR)ROM_OFFSET(copyLongs)) (ROM_TEXT_ADRS, (UINT)romInit,
        ROM_COPY_SIZE / sizeof (long));
#endif  /* CPU_FAMILY == MIPS */

#else   /* UNCOMPRESS */

#if (CPU_FAMILY == MIPS)
    /*
     * copy text to uncached locations to avoid problems with
     * copy back caches
     * copy the entire data segment because there is no way to ensure that
     * binArray is the last thing in the data segment because of GP relative
     * addressing
     */
    ((FUNCPTR)ROM_OFFSET(copyLongs)) (ROM_TEXT_ADRS, (UINT)K0_TO_K1(romInit),
        ((UINT)edata - (UINT)romInit) / sizeof (long));
#else   /* CPU_FAMILY == MIPS */

    ((FUNCPTR)ROM_OFFSET(copyLongs)) ( ROM_TEXT_ADRS,
                                       (UINT)romInit,
                                       ((UINT)binArrayStart - (UINT)romInit) / sizeof (long));
#endif  /* CPU_FAMILY == MIPS */

#endif  /* UNCOMPRESS */
#endif  /* ROM_RESIDENT */


#ifdef BOARD_TEST
#if (CPU_FAMILY != MIPS) && (!defined (BOOTCODE_IN_RAM))

    /* clear all memory if cold booting */

    if (startType & BOOT_CLEAR)
    {
#ifdef ROM_RESIDENT
    /* Clear memory not loaded with text & data.
     *
     * We are careful about initializing all memory (except
     * STACK_SAVE bytes) due to parity error generation (on
     * some hardware) at a later stage.  This is usually
     * caused by read accesses without initialization.
     */
    fillLongs ((UINT *)SYS_MEM_BOTTOM,
        ((UINT) RESIDENT_DATA - STACK_SAVE - (UINT)SYS_MEM_BOTTOM)
        / sizeof(long), 0);
    fillLongs (((UINT *) edata),
        ((UINT)SYS_MEM_TOP - ((UINT) edata)) / sizeof(long), 0);

#else    /* ROM_RESIDENT */
    fillLongs ((UINT *)(SYS_MEM_BOTTOM),
        ((UINT)romInit - STACK_SAVE - (UINT)SYS_MEM_BOTTOM) /
        sizeof(long), 0);

#if     defined (UNCOMPRESS)
    fillLongs ((UINT *)((UINT)romInit + ROM_COPY_SIZE),
            ((UINT)SYS_MEM_TOP - ((UINT)romInit + ROM_COPY_SIZE))
            / sizeof(long), 0);
#else
    fillLongs ((UINT *)binArrayStart,
        ((UINT)SYS_MEM_TOP - (UINT)binArrayStart) / sizeof (long), 0);
#endif     /* UNCOMPRESS */
#endif     /* ROM_RESIDENT */

    /*
     * Ensure the boot line is null. This is necessary for those
     * targets whose boot line is excluded from cleaning.
     */

    *(BOOT_LINE_ADRS) = EOS;
    }

#endif  /* (CPU_FAMILY != MIPS) && (!defined (BOOTCODE_IN_RAM)) */

#endif

    /* jump to VxWorks entry point (after uncompressing) */


#if defined (UNCOMPRESS) || defined (ROM_RESIDENT)
#if (CPU_FAMILY == I960)
    absEntry = (FUNCPTR)sysInitAlt;         /* reinit proc tbl */
#else
    absEntry = (FUNCPTR)usrInit;            /* on to bootConfig */
#endif  /* CPU_FAMILY == I960 */

#else   /* defined (UNCOMPRESS) || defined (ROM_RESIDENT) */
{
#if (CPU_FAMILY == MIPS)
    volatile FUNCPTR absUncompress = (FUNCPTR) UNCMP_RTN;
    if ((absUncompress) ( (UCHAR *)ROM_OFFSET(binArrayStart),
                          (UCHAR *)K0_TO_K1(RAM_DST_ADRS),
                          (int)((UINT)&binArrayEnd - (UINT)binArrayStart) )
        != OK)

#elif   (CPU_FAMILY == I80X86) || (CPU_FAMILY == ARM)
    volatile FUNCPTR absUncompress = (FUNCPTR) UNCMP_RTN;
    if ((absUncompress) ((UCHAR *)ROM_OFFSET(binArrayStart),
                (UCHAR *)RAM_DST_ADRS, &binArrayEnd - binArrayStart) != OK)
#else
    if (UNCMP_RTN ((UCHAR *)ROM_OFFSET(binArrayStart),
                (UCHAR *)RAM_DST_ADRS, &binArrayEnd - binArrayStart) != OK)
#endif    /* (CPU_FAMILY == MIPS) */
    return;        /* if we return then ROM's will halt */

    absEntry = (FUNCPTR)RAM_DST_ADRS;            /* compressedEntry () */
}
#endif  /* defined UNCOMPRESS || defined ROM_RESIDENT */

#if (CPU == ARM7TDMI_T)
    absEntry = (FUNCPTR)((UINT32)absEntry | 1);     /* force Thumb state */
#endif  /* (CPU == ARM7TDMI_T) */

    *PCDAT(INTERNAL_MEM_MAP_ADDR) |= PC15;
    *PCDAT(INTERNAL_MEM_MAP_ADDR) |= PC13;

    (absEntry) (startType);

}       /* romStart() */

#if     (CPU_FAMILY==ARM) && (!defined(ROM_RESIDENT))
#undef fillLongs
#endif  /* (CPU_FAMILY==ARM) */



/*******************************************************************************
*
* copyLongs - copy one buffer to another a long at a time
*
* This routine copies the first <nlongs> longs from <source> to <destination>.
*/

LOCAL void copyLongs (source, destination, nlongs)
    FAST UINT *source;          /* pointer to source buffer      */
    FAST UINT *destination;     /* pointer to destination buffer */
    UINT nlongs;                /* number of longs to copy       */
{
    FAST UINT *dstend = destination + nlongs;

    while (destination < dstend)
    {
        *destination++ = *source++;
    }
}

#ifndef    BOOTCODE_IN_RAM
#ifdef     BOARD_TEST
/*******************************************************************************
*
* fillLongs - fill a buffer with a value a long at a time
*
* This routine fills the first <nlongs> longs of the buffer with <val>.
*/

LOCAL void fillLongs (buf, nlongs, val)
    FAST UINT *buf;             /* pointer to buffer              */
    UINT nlongs;                /* number of longs to fill        */
    FAST UINT val;              /* char with which to fill buffer */

{
    FAST UINT *bufend = buf + nlongs;

    while (buf < bufend)
    {
        *buf++ = val;
    }
}
#endif
#endif  /* BOOTCODE_IN_RAM */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -