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

📄 bootinit.c

📁 motorola mpc系列 mpc852cpu bsp
💻 C
📖 第 1 页 / 共 2 页
字号:
/************************************************************************
Copyright 2003 - 2004 UPTI, Inc.

filename     : bootInit.c

description  : ROM initialization module

author       : lx

modification : lx   create            2001-01-01
************************************************************************/

#include "copyright_wrs.h"

/*
DESCRIPTION
This module provides a generic boot ROM facility.  The target-specific
romInit.s module performs the minimal preliminary board initialization and
then jumps to the C routine romStart().  This routine, still executing out
of ROM, copies the first stage of the startup code to a RAM address and
jumps to it.  The next stage clears memory and then uncompresses the
remainder of ROM into the final VxWorks ROM image in RAM.

A modified version of the Public Domain \f3zlib\fP library is used to
uncompress the VxWorks boot ROM executable linked with it.  Compressing
object code typically achieves over 55% compression, permitting much
larger systems to be burned into ROM.  The only expense is the added few
seconds delay while the first two stages complete.

ROM AND RAM MEMORY LAYOUT
Example memory layout for a 1-megabyte board:
.CS
    --------------  0x00100000 = LOCAL_MEM_SIZE = sysMemTop()
    |            |
    |    RAM     |
    |  0 filled  |
    |            |
    |------------| = (romInit+ROM_COPY_SIZE) or binArrayStart
    | ROM image  |
    |----------- |  0x00090000  = RAM_HIGH_ADRS
    | STACK_SAVE |
    |------------|
    |            |  0x00080000  = 0.5 Megabytes
    |            |
    |            |
    | 0 filled   |
    |            |
    |            |  0x00001000  = RAM_ADRS & RAM_LOW_ADRS
    |            |
    |            |  exc vectors, bp anchor, exc msg, bootline
    |            |
    |            |
    --------------  0x00000000  = LOCAL_MEM_LOCAL_ADRS
.CE
.CS
    --------------
    |    ROM     |
    |            |  0xff8xxxxx  = binArrayStart
    |            |
    |            |  0xff800008  = ROM_TEXT_ADRS
    --------------  0xff800000  = ROM_BASE_ADRS
.CE

SEE ALSO:
inflate(), romInit(), and deflate

AUTHOR
The original compression software for zlib was written by Jean-loup Gailly
and Mark Adler. See the manual pages of inflate and deflate for
more information on their freely available compression software.
*/

#include "vxWorks.h"
#include "sysLib.h"
#include "config.h"
#include "errno.h"
#include "sioLib.h"
#include "string.h"
#include "drv/multi/ppc860cpm.h"

#include "drv/multi/ppc860Siu.h"




#define UNCMP_RTN   inflate

#ifndef USER_RESERVED_MEM
#   define USER_RESERVED_MEM 0
#endif

/*
 * If memory is to be cleared, it will be cleared from SYS_MEM_BOTTOM
 * up to (but not including) SYS_MEM_TOP, except for text and data segments.
 * The user reserved area is not cleared.
 */

#define SYS_MEM_TOP \
    (LOCAL_MEM_LOCAL_ADRS + LOCAL_MEM_SIZE - USER_RESERVED_MEM)

#define SYS_MEM_BOTTOM \
    (LOCAL_MEM_LOCAL_ADRS + RESERVED)

IMPORT void     romInit ();
IMPORT STATUS   UNCMP_RTN ();
IMPORT void     usrInit ();
IMPORT void     sysInitAlt ();
IMPORT void     start ();

#if ((CPU_FAMILY == MIPS) || (CPU_FAMILY==PPC))
#define binArrayStart   _binArrayStart
#define binArrayEnd     _binArrayEnd
#define RESIDENT_DATA   RAM_DST_ADRS
#else
#define RESIDENT_DATA   (&sdata)
IMPORT  char    sdata;              /* defined in romInit.s */
#endif

IMPORT UCHAR    binArrayStart [];   /* compressed binary image */
IMPORT UCHAR    binArrayEnd;        /* end of compressed binary image */
IMPORT char etext [];               /* defined by the loader */
IMPORT char edata [];               /* defined by the loader */
IMPORT char end [];                 /* defined by the loader */


#ifndef RAM_DST_ADRS                /* default uncompress dest */
#define RAM_DST_ADRS        RAM_HIGH_ADRS
#endif

/* If the boot code is in RAM and the RAM is already initialized,
 * clearing the RAM is not necessary.  Macro BOOTCODE_IN_RAM is
 * used not to clear the RAM.
 */
#ifdef  BOOTCODE_IN_RAM             /* not to clear RAM */
#undef  ROM_TEXT_ADRS
#undef  ROM_BASE_ADRS
#define ROM_TEXT_ADRS   ((UINT)romInit)
#define ROM_BASE_ADRS   ((UINT)romInit)
#endif  /* BOOTCODE_IN_RAM */

#if defined (UNCOMPRESS) || defined (ROM_RESIDENT)
#ifndef ROM_COPY_SIZE
#define ROM_COPY_SIZE   (ROM_SIZE - (ROM_TEXT_ADRS - ROM_BASE_ADRS))
#endif
#endif  /* UNCOMPRESS */

#define ROM_OFFSET(adr) (((UINT)adr - (UINT)romInit) + ROM_TEXT_ADRS)

/* forward declarations */

LOCAL void copyLongs( FAST UINT *source, FAST UINT *destination, UINT nlongs );
#ifndef BOOTCODE_IN_RAM
#ifdef BOARD_TEST
LOCAL void fillLongs( FAST UINT *buf, UINT nlongs, FAST UINT val );
#endif
#endif  /* BOOTCODE_IN_RAM */


/*******************************************************************************
*
* romStart - generic ROM initialization
*
* This is the first C code executed after reset.
*
* This routine is called by the assembly start-up code in romInit().
* It clears memory, copies ROM to RAM, and possibly invokes the uncompressor.
* It then jumps to the entry point of the uncompressed object code.
*
* RETURNS: N/A
*/

#define     PB22                           0x00000200
#define     PB23                           0x00000100
#define     PC15                           0x0001
#define     PC13                           0x0004

#define SIZE_1M     0x100000

void romStart
    (
    FAST int startType      /* start type */
    )

{


#if ((CPU_FAMILY==SPARC) || (CPU_FAMILY==MIPS) || (CPU_FAMILY==I80X86) || \
     (CPU_FAMILY==PPC) || (CPU_FAMILY==ARM))
    volatile                /* to force absolute adressing */
#endif                      /* (CPU_FAMILY==SPARC) */

    FUNCPTR absEntry;       /* to avoid PC Relative Jump Subroutine */

#if ((CPU_FAMILY==ARM) && (!defined(ROM_RESIDENT)))
    VOIDFUNCPTR ramfillLongs = fillLongs;     /* force call to RAM */
#define fillLongs(a,b,c) ramfillLongs(a,b,c)
#endif                      /* (CPU_FAMILY==ARM) */


    *PCDAT(INTERNAL_MEM_MAP_ADDR) |= (PC15|PC13);
#if 0
{
    unsigned long ulTmp, i;

    
    for(i = 0x00000001; i < 0x80000000; i = i << 1)
    {
        *(unsigned long *)(0x0) = i;
        ulTmp = i;
        i = *(unsigned long *)(0x00001000);
        i = ulTmp;
        if(*(unsigned long *)(0x0) != i)
        {

            *PCDAT(INTERNAL_MEM_MAP_ADDR) &= ~PC13;
        }
    }

    
    *(unsigned long *)(0x00000000) = 0x12345678;


    for(i = 0x00000004; i < LOCAL_MEM_BANK_SIZE; i = i << 1)
    {
        *(unsigned long *)(i + 0x00000000) = i;
    }

    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;
        }
    }
}
#endif

#ifdef BOARD_TEST_MEM
{
    unsigned long i,j, ulTmp,ulCnt = 0;
    unsigned long loop = 0;
    unsigned char ucvalue = 0;
    /*
     * Copy from ROM to RAM, minus the compressed image
     * if compressed boot ROM which relies on binArray
     * appearing last in DATA segment.
     */
    *PCDAT(INTERNAL_MEM_MAP_ADDR) &= ~(PC13|PC15);
    loop = 0x1ffff;
    while(loop != 0)
    {
        loop--;
    }

    *PCDAT(INTERNAL_MEM_MAP_ADDR) |= 0xffff;
    *PCDAT(INTERNAL_MEM_MAP_ADDR) |= 0xffff;
    loop = 0x1ffff;
    while(loop != 0)
    {
        loop--;
    }

     
    for(i = 0x00000001; i < 0x80000000; i = i << 1)
    {
        *(unsigned long *)(0x0) = i;
        ulTmp = i;
        i = *(unsigned long *)(0x00001000);
        i = ulTmp;
        if(*(unsigned long *)(0x0) != i)
        {
            *PCDAT(INTERNAL_MEM_MAP_ADDR) &= ~PC13;


        }
    }

{
  
    *(unsigned long *)(0x00000000) = 0x12345678;

    for(i = 0x00000004; i < LOCAL_MEM_BANK_SIZE; i = i << 1)
    {
        *(unsigned long *)(i + 0x00000000) = i;

⌨️ 快捷键说明

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