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

📄 sysalib.s

📁 三星S3C44b0开发板配套 vxworks
💻 S
字号:
/* sysALib.s - Samsung SBC ARM7 system-dependent routines */


/* Copyright 1984-2001 Wind River Systems, Inc. */

/*
modification history
--------------------
01o,28jul04,a_m  BSP定制 for 多刃剑开发板
01d,18oct01,jb  Removing pre-pended underscores for new compilers (Diab/Gnu
                 elf)
01c,26apr01,m_h  fix thumb mode
01b,26apr01,m_h  convert tabs to spaces for readability
01a,12apr01,m_h  created from snds100 template.
*/

/*

DESCRIPTION
This module contains system-dependent routines written in assembly
language.  It 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().

sysInit() masks interrupts in the processor and the interrupt
controller and sets the initial stack pointer.  Other hardware and
device initialisation is performed later in the sysHwInit routine in
sysLib.c.

NOTE
The routines in this module don't use the "C" frame pointer %r11@ ! or
establish a stack frame.

SEE ALSO:
.I "ARM Architecture Reference Manual,"
.I "Samsung KS32C50100 Microcontroller User's Manual,"
.I "Samsung KS32C5000(A)/50100 Microcontroller Application Notes."
*/

#define _ASMLANGUAGE
#include "vxWorks.h"
#include "arch/arm/arm.h"
#include "regs.h"
#include "sysLib.h"
#include "config.h"
#include "wrSbcArm7.h"

    .data
    .globl  FUNC(copyright_wind_river)
    .long   FUNC(copyright_wind_river)
/* internals */

    .globl    FUNC(sysInit)        /* start of system code */
    .globl    FUNC(sysIntStackSplit)    /* routine to split interrupt stack */

/* externals */

    .extern    FUNC(usrInit)        /* system initialization routine */

    .extern    FUNC(vxSvcIntStackBase)    /* base of SVC-mode interrupt stack */
    .extern    FUNC(vxSvcIntStackEnd)    /* end of SVC-mode interrupt stack */
    .extern    FUNC(vxIrqIntStackBase)    /* base of IRQ-mode interrupt stack */
    .extern    FUNC(vxIrqIntStackEnd)    /* end of IRQ-mode interrupt stack */

    .text
    .balign 4

/*******************************************************************************
*
* sysInit - start after boot
*
* This routine is the system start-up entry point for VxWorks in RAM, the
* first code executed after booting.  It 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 ()              /@ THIS IS NOT A CALLABLE ROUTINE @/

*/

_ARM_FUNCTION(sysInit)

#ifdef  INCLUDE_VWARE_LAUNCH
    LDR    r2, =sysPrivateVwareParams
    STR    r1, [r2]
    LDR    r2, =sysPrivateVwareParams + 0x04
    STR    r0, [r2]
#endif /* INCLUDE_VWARE_LAUNCH */

    /*  : added */
    LDR    r2, L$_SbcArm7Intmsk		/*all interrupt disable*/
    MOV    r1, #0x07ffffff
    STR    r1, [r2]


    /* set initial stack pointer so stack grows down from start of code */

    LDR    sp, L$_STACK_ADDR
    MOV    fp, #0            /* zero frame pointer */

   /* Call C_Entry application routine with a pointer to the first */
   /* available memory address after ther compiler's global data */
   /* This memory may be used by the application. */

    /* now call usrInit */

    MOV    fp, #0            /* initialize frame pointer */
    MOV    r0, #BOOT_WARM_AUTOBOOT    /* pass startType */

#if    (CPU == ARMARCH4_T)
    LDR    r12, L$_usrInit
    BX     r12
#else
    B     FUNC(usrInit)
#endif    /* (CPU == ARMARCH4_T) */


/*******************************************************************************
*
* sysIntStackSplit - split interrupt stack and set interrupt stack pointers
*
* This routine is called, via a function pointer, during kernel
* initialisation.  It splits the allocated interrupt stack into IRQ and
* SVC-mode stacks and sets the processor's IRQ stack pointer. Note that
* the pointer passed points to the bottom of the stack allocated i.e.
* highest address+1.
*
* IRQ stack needs 6 words per nested interrupt;
* SVC-mode will need a good deal more for the C interrupt handlers.
* For now, use ratio 1:7 with any excess allocated to the SVC-mode stack
* at the lowest address.
*
* Note that FIQ is not handled by VxWorks so no stack is allocated for it.
*
* The stacks and the variables that describe them look like this.
* .CS
*
*         - HIGH MEMORY -
*     ------------------------ <--- vxIrqIntStackBase (r0 on entry)
*     |                      |
*     |       IRQ-mode       |
*     |    interrupt stack   |
*     |                      |
*     ------------------------ <--{ vxIrqIntStackEnd
*     |                      |    { vxSvcIntStackBase
*     |       SVC-mode       |
*     |    interrupt stack   |
*     |                      |
*     ------------------------ <--- vxSvcIntStackEnd
*         - LOW  MEMORY -
* .CE
*
* NOTE: This routine should not be called by the user.

* void sysIntStackSplit
*     (
*     char *pBotStack   /@ pointer to bottom of interrupt stack @/
*     long size        /@ size of stack @/
*     )

*/


_ARM_FUNCTION_CALLED_FROM_C(sysIntStackSplit)

    /*
     * r0 = base of space allocated for stacks (i.e. highest address)
     * r1 = size of space
     */

    SUB    r2, r0, r1            /* r2->lowest usable address */
    LDR    r3, L$_vxSvcIntStackEnd
    STR    r2, [r3]            /*  == end of SVC-mode stack */
    SUB    r2, r0, r1, ASR #3        /* leave 1/8 for IRQ */
    LDR    r3, L$_vxSvcIntStackBase
    STR    r2, [r3]

    /* now allocate IRQ stack, setting irq_sp */

    LDR    r3, L$_vxIrqIntStackEnd
    STR    r2, [r3]
    LDR    r3, L$_vxIrqIntStackBase
    STR    r0, [r3]

    MRS    r2, cpsr
    BIC    r3, r2, #MASK_MODE
    ORR    r3, r3, #MODE_IRQ32 | I_BIT    /* set irq_sp */
    MSR    cpsr, r3
    MOV    sp, r0

    /* switch back to original mode and return */

    MSR    cpsr, r2

#if    (CPU == ARMARCH4_T)
    BX     lr
#else
    MOV    pc, lr
#endif    /* (CPU == ARMARCH4_T) */

#ifdef INCLUDE_VWARE_LAUNCH
#include "sysAVware.s"
#endif /* INCLUDE_VWARE_LAUNCH */

/******************************************************************************/

/*
 * PC-relative-addressable pointers - LDR Rn,=sym is broken
 * note "_" after "$" to stop preprocessor preforming substitution
 */

    .balign    4

L$_vxSvcIntStackBase:
    .long    FUNC(vxSvcIntStackBase)

L$_vxSvcIntStackEnd:
    .long    FUNC(vxSvcIntStackEnd)

L$_vxIrqIntStackBase:
    .long    FUNC(vxIrqIntStackBase)

L$_vxIrqIntStackEnd:
    .long    FUNC(vxIrqIntStackEnd)

#if    (CPU == ARMARCH4_T)
L$_usrInit:
    .long    FUNC(usrInit)
#endif    /* (CPU == ARMARCH4_T) */

L$_STACK_ADDR:
    .long    FUNC(sysInit)

L$_SbcArm7Intmsk:
    .long    S3C44B0X_INTMASK
/*  : deleted */
/*L$_IopModReg:
    .long    SNGKS32C_IOPMOD

L$_IopDat:
    .long    SNGKS32C_IOPDATA*/

⌨️ 快捷键说明

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