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

📄 syslib.c

📁 S3c2510下的VXWORKS的BSP源代码(包括了以太网、串口、USB等等驱动)
💻 C
字号:
/* sysLib.c - SAMSUNG S3C2510 system-dependent routines */

/* Copyright 2002 SAMSUNG ELECTRONICS */

/*
modification history
--------------------
01a,08feb02,jmLee   created.
*/


#include "vxWorks.h"
#include "intLib.h"
#include "errno.h"
#include "vme.h"
#include "memLib.h"
#include "cacheLib.h"
#include "sysLib.h"
#include "string.h"
#include "logLib.h"
#include "stdio.h"
#include "taskLib.h"
#include "vxLib.h"
#include "tyLib.h"
#include "arch/arm/mmuArmLib.h"
#include "private/vmLibP.h"
#include "dllLib.h"

#include "drv/multi/s3c2510.h"
#include "config.h"


/* imports */

IMPORT VOIDFUNCPTR _func_armIntStackSplit;                  /* ptr to fn to split stack */


/* globals */

UINT32* sysCacheUncachedAdrs = (UINT32*)SYS_CACHE_UNCACHED_ADRS;

#ifdef  INCLUDE_MMU
PHYS_MEM_DESC sysPhysMemDesc [] = {
    /* SDRAM */
    {
    (void*)LOCAL_MEM_LOCAL_ADRS,
    (void*)LOCAL_MEM_LOCAL_ADRS,
    LOCAL_MEM_SIZE,
    VM_STATE_MASK_VALID | VM_STATE_MASK_WRITABLE | VM_STATE_MASK_CACHEABLE,
    VM_STATE_VALID      | VM_STATE_WRITABLE      | VM_STATE_CACHEABLE
    },

#if     (USER_RESERVED_MEM > 0)
    /* Reserved RAM on system bus - Used for Buffer Descriptor and Buffer */
    {
    (void*)SYS_MEM_TOP,
    (void*)SYS_MEM_TOP,
    USER_RESERVED_MEM,
    VM_STATE_MASK_VALID | VM_STATE_MASK_WRITABLE | VM_STATE_MASK_CACHEABLE,
    VM_STATE_VALID      | VM_STATE_WRITABLE      | VM_STATE_CACHEABLE_NOT
    },
#endif  /* (USER_RESERVED_MEM > 0) */

    /* Boot ROM */
    {
    (void*)ROM_BASE_ADRS,
    (void*)ROM_BASE_ADRS,
    ROM_SIZE,
    VM_STATE_MASK_VALID | VM_STATE_MASK_WRITABLE | VM_STATE_MASK_CACHEABLE,
    VM_STATE_VALID      | VM_STATE_WRITABLE      | VM_STATE_CACHEABLE_NOT
    },

#ifdef  INCLUDE_FLASH
    /* FLASH */
    {
    (void*)FLASH_BASE_ADRS,
    (void*)FLASH_BASE_ADRS,
    FLASH_SIZE,
    VM_STATE_MASK_VALID | VM_STATE_MASK_WRITABLE | VM_STATE_MASK_CACHEABLE,
    VM_STATE_VALID      | VM_STATE_WRITABLE      | VM_STATE_CACHEABLE_NOT
    },
#endif  /* INCLUDE_FLASH */

#ifdef  INCLUDE_LCD
    /* LCD */
    {
    (void*)LCD_BASE_ADRS,
    (void*)LCD_BASE_ADRS,
    LCD_SIZE,
    VM_STATE_MASK_VALID | VM_STATE_MASK_WRITABLE | VM_STATE_MASK_CACHEABLE,
    VM_STATE_VALID      | VM_STATE_WRITABLE      | VM_STATE_CACHEABLE_NOT
    },
#endif  /* INCLUDE_LCD */

#ifdef  INCLUDE_SRAM
    /* SRAM */
    {
    (void*)SRAM_BASE_ADRS,
    (void*)SRAM_BASE_ADRS,
    SRAM_SIZE,
    VM_STATE_MASK_VALID | VM_STATE_MASK_WRITABLE | VM_STATE_MASK_CACHEABLE,
    VM_STATE_VALID      | VM_STATE_WRITABLE      | VM_STATE_CACHEABLE_NOT
    },
#endif  /* INCLUDE_SRAM */

    /* Interal Register */
    {
    (void*)S3C2510_REG_BASE_ADRS,
    (void*)S3C2510_REG_BASE_ADRS,
    S3C2510_REG_SIZE,
    VM_STATE_MASK_VALID | VM_STATE_MASK_WRITABLE | VM_STATE_MASK_CACHEABLE,
    VM_STATE_VALID      | VM_STATE_WRITABLE      | VM_STATE_CACHEABLE_NOT
    }
};

int sysPhysMemDescNumEnt = NELEMENTS(sysPhysMemDesc);
#endif

int     sysBus      = BUS;                                  /* system bus type (VME_BUS, etc) */
int     sysCpu      = CPU;                                  /* system CPU type (e.g. ARMARCH4/4_T)*/
char*   sysBootLine = BOOT_LINE_ADRS;                       /* address of boot line */
char*   sysExcMsg   = EXC_MSG_ADRS;                         /* catastrophic message area */
int     sysProcNum;                                         /* processor number of this CPU */
int     sysFlags;                                           /* boot flags */
char    sysBootHost[BOOT_FIELD_LEN];                        /* name of host from which we booted */
char    sysBootFile[BOOT_FIELD_LEN];                        /* name of file from which we booted */


#ifdef  INCLUDE_SEC_END
/* array of ethernet hardware address */

LOCAL unsigned char sysSecEnetAddr[][6] = {
#if 1
    {0x08, 0x00, 0x01, 0x01, 0x01, 0x01},
    {0x08, 0x00, 0x01, 0x01, 0x01, 0x02},
    {0x08, 0x00, 0x01, 0x01, 0x01, 0x03},
    {0x08, 0x00, 0x01, 0x01, 0x01, 0x04},
    {0x08, 0x00, 0x01, 0x01, 0x01, 0x05},
    {0x08, 0x00, 0x01, 0x01, 0x01, 0x06}
#else
    {0x08, 0x00, 0x02, 0x02, 0x02, 0x01},
    {0x08, 0x00, 0x02, 0x02, 0x02, 0x02},
    {0x08, 0x00, 0x02, 0x02, 0x02, 0x03},
    {0x08, 0x00, 0x02, 0x02, 0x02, 0x04},
    {0x08, 0x00, 0x02, 0x02, 0x02, 0x05},
    {0x08, 0x00, 0x02, 0x02, 0x02, 0x06}
#endif
};

STATUS sysSecEnetAddrGet(int unit, UCHAR* address);
#endif  /* INCLUDE_SEC_END */

/* externals */

IMPORT void sysIntStackSplit(char*, long);


/* forward declarations */

char* sysPhysMemTop(void);


/* included source files */

#include "intrCtl/s3c2510Intr.c"
#include "timer/s3c2510Timer.c"
#include "mem/nullNvRam.c"
#include "vme/nullVme.c"
#include "sio/s3c2510Sio.c"
#include "sysSerial.c"


/*******************************************************************************
*
* sysModel - return the model name of the CPU board
*
* This routine returns the model name of the CPU board.
*
* NOTE
* This routine does not include all of the possible variants, and the inclusion
* of a variant in here does not mean that it is supported.
*
* RETURNS: A pointer to a string identifying the board and CPU.
*/

char* sysModel(void)
{
    UINT32 pdcode;
    static char str[64];

    pdcode = *S3C2510_PDCODE;

    sprintf(str, "SAMSUNG SMDK2510(S3C%X Rev.%d.%d)",
            (pdcode & S3C2510_PDCODE_PC_MASK) >> S3C2510_PDCODE_PC_SHIFT,
            (pdcode & S3C2510_PDCODE_MAJ_REV_MASK) >> S3C2510_PDCODE_MAJ_REV_SHIFT,
            (pdcode & S3C2510_PDCODE_MIN_REV_MASK) >> S3C2510_PDCODE_MIN_REV_SHIFT
            );

    return (str);
}

/*******************************************************************************
*
* sysBspRev - return the BSP version with the revision eg 1.2/<x>
*
* This function returns a pointer to a BSP version with the revision. 
* e.g. 1.2/<x>. BSP_REV is concatenated to BSP_VERSION to form the BSP
* identification string.
*
* RETURNS: A pointer to the BSP version/revision string.
*/

char* sysBspRev(void)
{
    return (BSP_VERSION BSP_REV);
}

/*******************************************************************************
*
* sysHwInit0 - perform early BSP-specific initialisation
*
* This routine performs such BSP-specific initialisation as is necessary before
* the architecture-independent cacheLibInit can be called. It is called
* from usrInit() before cacheLibInit(), before sysHwInit() and before BSS
* has been cleared.
*
* RETURNS: N/A
*/

void sysHwInit0(void)
{
#ifdef  INCLUDE_CACHE_SUPPORT
    /*
     * Install the appropriate cache library, no address translation routines
     * are required for this BSP, as the default memory map has virtual and
     * physical addresses the same.
     */
    cacheArm940tLibInstall(NULL, NULL);
#endif  /* INCLUDE_CACHE_SUPPORT */

#ifdef  INCLUDE_MMU
    /* Install the appropriate MMU library and translation routines. */
    mmuArm940tLibInstall(NULL, NULL);
#endif  /* INCLUDE_MMU */

    /* Enable IOP clock. */
    *S3C2510_PCLKDIS &= ~(S3C2510_PCLKDIS_IOP);

#ifdef  INCLUDE_LED
    /* LED port is output mode, */
    *IOPMOD_LED &= ~LED_ALL_MASK;

    {
        FAST int i;

        /* LED_ON(LED_ALL_MASK); */
        for (i=0; i<CPLL_FREQ*10000; i++);
        /* LED_OFF(LED_ALL_MASK); */
        for (i=0; i<CPLL_FREQ*5000; i++); 
        
    }
#endif  /* INCLUDE_LED */

    return;
}

/*******************************************************************************
*
* sysHwInit - initialize the CPU board hardware
*
* This routine initializes various features of the hardware. Normally, it is
* called from usrInit() in usrConfig.c.
*
* NOTE: This routine should not be called directly by the user.
*
* RETURNS: N/A
*/

void sysHwInit(void)
{
    /* Install the IRQ/SVC interrupt stack splitting routine. */
    _func_armIntStackSplit = sysIntStackSplit;

    /* Initialize the serial devices. */
    sysSerialHwInit();
    /* LED_ON(LED4_MASK);
    LED_ON(LED5_MASK);
    LED_ON(LED6_MASK);  */
}

/*******************************************************************************
*
* sysHwInit2 - additional system configuration and initialization
*
* This routine connects system interrupts and does any additional
* configuration necessary. Note that this is called from
* sysClkConnect() in the timer driver.
*
* RETURNS: N/A
*
*/

void sysHwInit2(void)
{
    static BOOL initialized = FALSE;

    if (initialized)
    {
        return;
    }

    /* Initialize the interrupt library and interrupt driver. */
    intLibInit(S3C2510_INT_NUM_LEVELS, S3C2510_INT_NUM_LEVELS, INT_PREEMPT_MODEL);
    s3c2510IntrInit();

    /* Connect serial interrupt. */
    sysSerialHwInit2();
    
    LED_OFF(LED2_MASK);
    LED_OFF(LED4_MASK);
    LED_OFF(LED6_MASK);

    initialized = TRUE;
}

/*******************************************************************************
*
* sysPhysMemTop - get the address of the top of physical memory
*
* This routine returns the address of the first missing byte of memory, which
* indicates the top of memory.
*
* Normally, the user specifies the amount of physical memory with the macro
* LOCAL_MEM_SIZE in config.h.  BSPs that support run-time memory sizing do so
* only if the macro LOCAL_MEM_AUTOSIZE is defined. If not defined, then
* LOCAL_MEM_SIZE is assumed to be, and must be, the true size of physical memory.
*
* NOTE: Do no adjust LOCAL_MEM_SIZE to reserve memory for application use. See
* sysMemTop() for more information on reserving memory.
*
* RETURNS: The address of the top of physical memory.
*
* SEE ALSO: sysMemTop()
*/

char* sysPhysMemTop(void)
{
    return ((char*)(LOCAL_MEM_LOCAL_ADRS + LOCAL_MEM_SIZE));
}

/*******************************************************************************
*
* sysMemTop - get the address of the top of VxWorks memory
*
* This routine returns a pointer to the first byte of memory not controlled or
* used by VxWorks.
*
* The user can reserve memory space by defining the macro USER_RESERVED_MEM in
* config.h. This routine returns the address of the reserved memory area. The
* value of USER_RESERVED_MEM is in bytes.
*
* RETURNS: The address of the top of VxWorks memory.
*/

char* sysMemTop(void)
{
    return (sysPhysMemTop() - USER_RESERVED_MEM);
}

/*******************************************************************************
*
* sysToMonitor - transfer control to the ROM monitor
*
* This routine transfers control to the ROM monitor. It is usually called only
* by reboot() -- which services ^X -- and bus errors at interrupt level.
* However, in some circumstances, the user may wish to introduce a new
* <startType> to enable special boot ROM facilities.
*
* RETURNS: Does not return.
*/

STATUS sysToMonitor(
    int startType                                           /* passed to ROM to tell it how to boot */
    )
{
    FUNCPTR pRom;

    sysSerialReset();                                       /* put serial devices into quiet state */

    /* Jump to the warm boot entry. */

    pRom = (FUNCPTR)(ROM_TEXT_ADRS + 4);                    /* warm boot address */

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

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

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

/****************************************************************************
*
* sysProcNumGet - get the processor number
*
* This routine returns the processor number for the CPU board, which is set with
* sysProcNumSet().
*
* RETURNS: The processor number for the CPU board.
*
* SEE ALSO: sysProcNumSet()
*/

int sysProcNumGet(void)
{
    return (sysProcNum);
}

/****************************************************************************
*
* sysProcNumSet - set the processor number
*
* Set the processor number for the CPU board.  Processor numbers should be
* unique on a single backplane.
*
* NOTE
* By convention, only processor 0 should dual-port its memory.
*
* RETURNS: N/A
*
* SEE ALSO: sysProcNumGet()
*/

void sysProcNumSet(
    int procNum                                             /* processor number */
    )
{
    sysProcNum = procNum;
}

#ifdef  INCLUDE_SEC_END
/*******************************************************************************
*
* sysSecEnetAddrGet - get the hardware Ethernet address
*
* This routine provides the six byte Ethernet hardware address that will be used
* by each individual device unit. This routine must copy the six byte address to
* the space provided by <addr>.
*
* RETURNS: OK, or ERROR if the Ethernet address cannot be returned.
*/
 
STATUS sysSecEnetAddrGet(
    int unit,                                               /* unit number of device being used */
    UCHAR* addr                                             /* where to copy the ethernet address */
    )
{
    bcopy((char*)sysSecEnetAddr[unit], (char*)addr, 6);

    return (OK);
}
#endif  /* INCLUDE_SEC_END */

⌨️ 快捷键说明

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