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

📄 unzip.c

📁 ATMEL920T的BSP及ETH等已经设备驱动程序
💻 C
字号:
 /*****************************************************
  * filename   : unzip.c
  * function    : to uncompress the commpressed hammeros image 
  *                   to RAM_LOW_ADRS and continue to run
  * Date        : maven make 2003/4/1
  *****************************************************/

#ifndef __UNZIP_C__
#define  __UNZIP_C__

#include "stdio.h"
#include "vxWorks.h"
#include "stdlib.h" 
#include "string.h"
#include "config.h"
#include "cacheLib.h"
#include "vxLib.h"
#include "private/vmLibP.h"

#define    UNCMP_RTN    inflate
#define ROM_SYS_START_ADRS 	0x21000000
#define ROM_OFFSET(adr)    	(((UINT)adr - (UINT)sysInit) + (ROM_SYS_START_ADRS))
#define SYS_START_ADRS   	0x20001000 

#define IMAGE_START_ADRS 	0x10100000
#define IMAGE_SIZE 		0x200000

IMPORT void sysInit();
IMPORT STATUS    UNCMP_RTN ();
LOCAL void copyLongs ( FAST UINT *source, FAST UINT *destination, UINT nlongs );
LOCAL void fillLongs ( FAST UINT *buf, UINT nlongs, UINT val );

#define    binArrayStart    _binArrayStart
#define    binArrayEnd    _binArrayEnd

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 */
/*
const char ROM_POST_UNCMP_ERROR[] = "\n\rUncompress HammerOS image file ERROR";
const char ROM_POST_UNCMP_SUCCESS[] = "success\r\nLoad HammerOS, Please wait...\n\r";
const char ROM_POST_UNCMP_START[] = "\n\rUncompress HammerOS image file start...";
*/
void    usrInit(void);
void    uncmp_os(void);

void usrInit(void)
{    
  	volatile FUNCPTR absEntry;
	/*copyLongs( ( UINT * ) IMAGE_START_ADRS, ( UINT * ) ROM_SYS_START_ADRS, IMAGE_SIZE / sizeof ( long ) );*/
  	absEntry = (FUNCPTR)(((UINT)uncmp_os - (UINT)sysInit) +  (ROM_SYS_START_ADRS))  ;
  	(absEntry)();
}

void uncmp_os(void)
{
    	volatile FUNCPTR absEntry;
    	volatile FUNCPTR absUncompress = (FUNCPTR) UNCMP_RTN;
	/*
    	fillLongs ( ( UINT * ) ( SYS_START_ADRS ),
                ( ( UINT ) ROM_SYS_START_ADRS - ( UINT ) SYS_START_ADRS ) /
                sizeof( long ), 0 );
	*/
    	/*bzero( edata, end - edata ); */            /*zero out bss in cache*/

    	if ((absUncompress) ((UCHAR *)ROM_OFFSET(binArrayStart),
             	(UCHAR *)(SYS_START_ADRS),
             	(int)((UINT)binArrayEnd - (UINT)binArrayStart)) != OK)
 	{
       	return;
  	}
    	
    	/*
	__asm__ volatile ( "   eieio;  sync; isync" );
    	__asm__ volatile ( "   eieio;  sync; isync" );
	*/
  	absEntry = (FUNCPTR)(SYS_START_ADRS);
  	(absEntry)();
  	return;    
}

/*******************************************************************************
*
* 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++;
}

/*******************************************************************************
*
* 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;
}

#if 1
int sysToMonitor
    (
    int startType             /* parameter passed to ROM to tell it how */
                              /* to boot */ 
    )

{
    FUNCPTR	pRom;
    UINT32 *	p = (UINT32 *)ROM_TEXT_ADRS;

    /*
     * Examine ROM - if it's a VxWorks boot ROM, jump to the warm boot entry
     * point; otherwise jump to the start of the ROM.
     * A VxWorks boot ROM begins
     *    MOV	R0,#BOOT_COLD
     *    B	...
     *    DCB	"Copyright"
     * We check the first and third words only. This could be tightened up
     * if required (see romInit.s).
     */

    if (p[0] == 0xE3A00002 && p[2] == 0x79706F43)
        pRom = (FUNCPTR)(ROM_TEXT_ADRS + 4);	/* warm boot address */
    else
        pRom = (FUNCPTR)ROM_TEXT_ADRS;		/* start of ROM */

#if defined(CPU_720T)  || defined(CPU_720T_T) || \
    defined(CPU_740T)  || defined(CPU_740T_T) || \
    defined(CPU_920T)  || defined(CPU_920T_T) || \
    defined(CPU_940T)  || defined(CPU_940T_T) || \
    defined(CPU_946ES) || defined(CPU_946ES_T)

    VM_ENABLE(FALSE);	/* disable the MMU, cache(s) and write-buffer */
#endif

#if defined(CPU_920T) || defined(CPU_920T_T)
    /*
     * On 920T, can have the I-cache enabled once the MMU has been
     * disabled, so, unlike the other processors, disabling the MMU does
     * not disable the I-cache.  This would not be a problem, as the
     * 920T boot ROM initialisation code disables and flushes both caches.
     * However, in case we are, in fact, using a 7TDMI boot ROM,
     * disable and flush the I-cache here, or else the boot process may
     * fail.
     */

    cacheDisable (INSTRUCTION_CACHE);
#endif /* defined(CPU_920T/920T_T) */

    (*pRom)(startType);	/* jump to boot ROM */

    return OK;		/* in case we ever continue from ROM monitor */
}

char *	sysExcMsg   = EXC_MSG_ADRS;	/* catastrophic message area */
#endif
#endif

⌨️ 快捷键说明

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