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

📄 sysalib.s

📁 powerPC866 系列平台BSP移植开发的参考代码
💻 S
字号:
/* sysALib.s - Embedded Planet Board system-dependent assembly routines */

/* Copyright 1984-2001 Wind River Systems, Inc. */
/* Copyright 2001-2004 Embedded Planet, LLC. */
	.data
	.globl	copyright_wind_river
	.long	copyright_wind_river

/* 
modification history
--------------------
02a,06Jul03,gad  first release for VxWorks 5.5
01a,19apr96,tpr  written.
*/

/*
DESCRIPTION
This module contains the entry code, sysInit(), for VxWorks images that start
running from RAM, such as 'vxWorks'. These images are loaded into memory
by some external program (e.g., a boot ROM) and then started.
The routine sysInit() must come first in the text segment. Its job is to perform
the minimal setup needed to call the generic C
routine usrInit() with parameter BOOT_COLD.

The routine sysInit() typically masks interrupts in the processor, sets the
initial stack pointer to _sysInit then jumps to usrInit.
Most other hardware and device initialization is performed later by
sysHwInit().
*/

#define _ASMLANGUAGE
#include "vxWorks.h"
#include "asm.h"
#include "cacheLib.h"
#include "config.h"
#include "regs.h"
#include "sysLib.h"

	/* globals */

	FUNC_EXPORT(_sysInit)			/* start of system code */
	FUNC_EXPORT(_sysMemProbeSup)	/* memProbe support rtn */
	FUNC_EXPORT(sysMemProbeSup)		/* memProbe support rtn */
	FUNC_EXPORT(sysDecGet)

	/* externals */

	FUNC_IMPORT(rpxBootParams)		/* defined in sysLib.c */
	FUNC_IMPORT(usrInit)

	.text

/*******************************************************************************
*
* sysInit - start after boot
*
* This is the system start-up entry point for VxWorks in RAM, the
* first code executed after booting.  The location of the Planet Core boot
* parameters is saved so a vxWorks compatible boot line may be constructed
* using these stored parameters. It then disables interrupts, sets up
* the stack, and jumps to the C routine usrInit() in usrConfig.c.
*
* The initial stack is set to grow down from the address of sysInit().  This
* stack is used only by usrInit() and is never used again.  Memory for the
* stack must be accounted for when determining the system load address.
*
* NOTE: This routine should not be called by the user.
*
* RETURNS: N/A

* sysInit (void)              /@ THIS IS NOT A CALLABLE ROUTINE @/

*/

FUNC_BEGIN(_sysInit)

	/*
	 * After exiting the Planet Core boot loader, r3 contains the location in DPRAM where
	 * the boot loader has saved the boot parameters for use in building the vxWorks boot
	 * line.  We store this just below at the address 0x3000 very briefly until it can be picked
	 * up by sysHwInit().
	 */

;	lis     	r6, HIADJ(0x00003000)
;	addi    	r6, r6, LO(0x00003000)
;	stw		r3, 0(r6)

	/*
	 * disable external interrupts and Instruction/Data MMU, set
	 * the exception prefix
	 */

	mfmsr   	p0					/* p0 = msr    */
	INT_MASK(p0, p1)				/* mask EE bit */
	rlwinm	p1, p1, 0, _PPC_MSR_BIT_DR + 1, _PPC_MSR_BIT_IR - 1
	rlwinm  	p1, p1, 0, _PPC_MSR_BIT_IP + 1, _PPC_MSR_BIT_IP - 1
	mtmsr   	p1					/* msr = p1    */
	isync							/* ISYNC */

	/* disable instruction and data caches */

	LOADPTR (p1, CACHE_CMD_DISABLE)
	mtspr	IC_CST, p1				/* Disable I cache */
	mtspr	DC_CST, p1				/* Disable D cache */

	/* unlock instruction and data caches */

	LOADPTR (p1, CACHE_CMD_UNLOCK_ALL)
	mtspr   IC_CST, p1				/* Unlock I cache */
	mtspr   DC_CST, p1				/* Unlock D cache */

	/* invalidate instruction and data caches */

	LOADPTR (p1, CACHE_CMD_INVALIDATE)
	mtspr   IC_CST, p1				/* Invalidate I cache */
	mtspr   DC_CST, p1				/* Invalidate D cache */

	/* invalidate entries within both TLBs */

	tlbia

	/* disable all devices (serial, ethernet, ...) */
/*	lis		r4, HIADJ(BCSR_RESET_VAL)
	lis		r5, HIADJ (BCSR)
	stw		r4, LO(BCSR)(r5)		 reset the BCSR register */

	/* initialize the stack pointer */

	LOADPTR (sp, _sysInit)
	addi	sp, sp, -FRAMEBASESZ	/* get frame stack */

	/* set the default boot code */

	LOADPTR (r3, BOOT_WARM_AUTOBOOT)

	/* jump to usrInit */

	b	usrInit			/* never returns - starts up kernel */
FUNC_END(_sysInit)

/*******************************************************************************
*
* sysMemProbeSup - sysBusProbe support routine
*
* This routine is called to try to read byte, word, or long, as specified
* by length, from the specified source to the specified destination.
*
* RETURNS: OK if successful probe, else ERROR

* STATUS sysMemProbeSup
*    (
*    int         length, /@ length of cell to test (1, 2, 4, 8, 16) @/
*    char *      src,    /@ address to read @/
*    char *      dest    /@ address to write @/
*    )

*/

FUNC_BEGIN(_sysMemProbeSup)
FUNC_LABEL(sysMemProbeSup)
        addi    p7, p0, 0       /* save length to p7 */
        xor     p0, p0, p0      /* set return status */
        cmpwi   p7, 1           /* check for byte access */
        bne     sbpShort        /* no, go check for short word access */
        lbz     p6, 0(p1)       /* load byte from source */
        stb     p6, 0(p2)       /* store byte to destination */
        isync                   /* enforce for immediate exception handling */
        blr
sbpShort:
        cmpwi   p7, 2           /* check for short word access */
        bne     sbpWord         /* no, check for word access */
        lhz     p6, 0(p1)       /* load half word from source */
        sth     p6, 0(p2)       /* store half word to destination */
        isync                   /* enforce for immediate exception handling */
        blr
sbpWord:
        cmpwi   p7, 4           /* check for short word access */
        bne     sysProbeExc     /* no, check for double word access */
        lwz     p6, 0(p1)       /* load half word from source */
        stw     p6, 0(p2)       /* store half word to destination */
        isync                   /* enforce for immediate exception handling */
        blr
sysProbeExc:
        li      p0, -1          /* shouldn't ever get here, but... */
        blr
FUNC_END(_sysMemProbeSup)

/*******************************************************************************
*
* sysDecGet - return the decrementer contents
*
* This routine will return the current contents of the
* decrementer register (MPU.SPR22)
#
* RETURNS: decrementer contents
*
* NOMANUAL
*/

FUNC_BEGIN(sysDecGet)
	mfspr	r3,22		/* load decrementer contents */

	/* Return to caller */

	bclr	20,0
FUNC_END(sysDecGet)

⌨️ 快捷键说明

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