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

📄 syslib.c

📁 au1500开发的应用程序
💻 C
📖 第 1 页 / 共 2 页
字号:
/* sysLib.c - V100R001CPE system-dependent routines */

/* Copyright 2002-2005 Founder Communications,Inc. */

/*
modification history
--------------------
01a,15mar05,fhchen  adapted from pb1500_mips32sf/sysLib.c (ver 01d)
*/

/*
DESCRIPTION

This library provides board-specific routines.

DMA, AC97, PCI, USB are not supported in CPE board and no RTC available.

*/

/* includes */

#include "vxWorks.h"
#include "cacheLib.h"
#include "sysLib.h"
#include "intLib.h"
#include "version.h"
#include "config.h"
#include "arch/mips/taskMipsLib.h"

/* externals */

IMPORT void 	fpIntr (void);
IMPORT void 	sysWbFlush (void);
IMPORT int  	sysFpaAck (void);
IMPORT int 	sysAtlIntResolve(void);
IMPORT STATUS   sysSetTlbEntry (int, int, int, int);
IMPORT void	sysClkInt (void); 
IMPORT void     sysWiredSet (int);

IMPORT int      sysCompareSet ();
IMPORT int      sysGetPrid ();
IMPORT int      sysWiredGet ();
IMPORT void     sysClearTlbEntry ();
IMPORT BOOL     vxTas();

/* forward declarations */

void sysClearTlb (void);
void sysSetTlb (int, int, int);
LOCAL int sysSw0Ack (void);
LOCAL int sysSw1Ack (void);
void sysSw0Gen (void);
void sysSw1Gen (void);

/* defines */

/* globals */

int   sysBus      = BUS;                /* system bus type (VME_BUS, etc) */
int   sysCpu      = CPU;                /* system CPU type (MIPS_Vr5400) */
char *sysMemTopAdr= NULL;		/* top of memory */
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 */

/* Initialize cache function pointer */

LOCAL STATUS      sysCacheInit ();
FUNCPTR sysCacheLibInit = (FUNCPTR) sysCacheInit;

/* libraries */

#include "sysGpio.c"
#include "au1500Gpio.c"
#include "au1500Int.c"
#include "vme/nullVme.c"
#include "auTimer.c"
#include "sysSerial.c"

#ifdef  INCLUDE_NETWORK
# include "sysNet.h"
# include "sysNet.c"
#ifdef  INCLUDE_AUEND
# include "sysAuEnd.c"
#endif /* INCLUDE_AUEND */
#endif /* INCLUDE_NETWORK */

#ifdef INCLUDE_SYSLED
# include "sysLed.c"
#endif /* INCLUDE_SYSLED */

#ifdef INCLUDE_EXTERNAL_WATCHDOG
# include "sysWdog.c"
#endif  /* INCLUDE_EXTERNAL_WATCHDOG */

#if (NV_RAM_SIZE == NONE)
# include "mem/nullNvRam.c"
#endif 

#if defined(INCLUDE_EEPROM)
# include "24c16NvRam.c"
#endif 

/***************************************************************************
*
* sysModel - return the model name of the CPU board
*
* This routine returns the model name of the CPU board.
*
* RETURNS: A pointer to the string.
*/

char *sysModel (void)
    {
    return ("AU1500 - Foundercom, V100R001CPE");
    }

/***************************************************************************
*
* sysBspRev - return the bsp version with the revision number.
*
* This function returns a pointer to a bsp version with the revision,
* for example, "1.1/<x>." BSP_REV is concatanated 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);
    }

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

void sysHwInit (void)
    {
    /* set CPU clock speed */

    *(volatile UINT32 *)AU_CLOCK_CPU_PLL_CONTROL = CPU_PLL_DIVISOR;
    sysWbFlush ();

    *(volatile UINT32 *)AU_SYS_FREQ_CONTROL_0 = 0;
    *(volatile UINT32 *)AU_SYS_FREQ_CONTROL_1 = 0;
    *(volatile UINT32 *)AU_SYS_CLOCK_SOURCE   = 0;
    sysWbFlush ();

    /* init status register but leave interrupts disabled */

    intSRSet (DEFAULT_SR & ~SR_IE);

    /* !should clear IE bit, or you can not enter usrRoot! */

    taskSRInit (DEFAULT_SR & ~SR_IE);

    /* initialize GPIO  */

    sysGpioInit();

#if defined(INCLUDE_EEPROM)

    /* initialize EEPROM */

    at24c16Init();

#endif  /* INCLUDE_EEPROM */

#if defined(INCLUDE_SYSLED)

    /* initialize LEDs */

    sysLedInit();
    
#endif  /* INCLUDE_SYSLED */
    
    /* initialize the interrupt controller */

    au1000IntInit();

    /* Always reset the TLB */

    sysClearTlb ();

    /* Setup the serial device */

    sysSerialHwInit ();

    /* disable enet macs */

    *(volatile UINT32 *)AU_MAC0_ENABLE = 0;
    *(volatile UINT32 *)AU_MAC1_ENABLE = 0;
    sysWbFlush ();

#if 1
    /* reset PHYS */

    sysPhyReset(PHY0_RESET_PIN);
    sysPhyReset(PHY1_RESET_PIN);
    
#endif 
    
    /* Initialize the sysClk device */  

    sysClkConfig ();   

    /* Initialize the auxClk device */  

    sysAuxClkConfig (); 

#ifdef  FORCE_DEFAULT_BOOT_LINE
    
    /* use default boot line instead of that in NvRAM when debugging */
    
    strncpy (sysBootLine,DEFAULT_BOOT_LINE,strlen(DEFAULT_BOOT_LINE)+1);

#endif

#if defined(INCLUDE_SYSLED)

    /* turn on the LEDs, should be removed */
    
    sysLedOn(LED_ALL);

#endif  /* INCLUDE_SYSLED */
    }

/***************************************************************************
*
* sysHwInit2 - additional system configuration and initialization
*
* This routine connects system interrupts and does any additional
* configuration necessary.
*
* RETURNS: N/A
*
*/

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

    if(!configured)
        {

        /* !should set IE bit, or usrRoot will hang! */

        taskSRInit (DEFAULT_SR);

        /* connect timestamp, sys clock and aux clock interrupts */
    
        (void) intConnect (INUM_TO_IVEC(IV_TIMER_VEC), sysTimestampInt, 0);
        (void) intConnect (INUM_TO_IVEC(IV_TOY_MATCH2_VEC), sysClkInt, 0);
        (void) intConnect (INUM_TO_IVEC(IV_RTC_MATCH2_VEC), sysAuxClkInt, 0);

#if defined(INCLUDE_AUX_CLK)
        
        /* initialize and start auxiliary clock, set clock rate */
        
        sysAuxClkEnable();
        sysAuxClkRateSet(AUX_CLK_RATE);
        
#endif /* INCLUDE_AUX_CLK */

#if defined(INCLUDE_TIMESTAMP)
        
        /* enable timestamp */

        sysTimestampEnable();

#endif  /* INCLUDE_TIMESTAMP */

        /* connect serial channel interrupts */
        
        sysSerialHwInit2 ();

#ifdef INCLUDE_AUEND

        sysLanAuInit ();
#endif

        /* Indicate we have been through this procedure for reentrancy */

        configured = TRUE;
        }
    }

/******************************************************************************
*
* 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
*
* This routine sets the processor number for this board.  Processor numbers
* should be unique on a single backplane.
*
* RETURNS: N/A
*
* SEE ALSO: sysProcNumGet()
*/

void sysProcNumSet
    (
    int procNum
    )
    {
    sysProcNum = procNum;
    }

/***************************************************************************
*
* sysPhysMemTop - get the address of the top of memory
*
* This routine returns the address of the first missing byte of memory, which
* indicates the top of memory.
*
* NOTE: Do not 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 memory.
*/

char *sysPhysMemTop (void)
    {
    static char * memTop = NULL;

    if (memTop == NULL)
	memTop = (char *)(LOCAL_MEM_LOCAL_ADRS + LOCAL_MEM_SIZE);
    return (memTop);
    }

/***************************************************************************
*
* sysMemTop - get the address of the top of logical memory
*
* This routine returns the address of the first unusable byte of memory.
* VxWorks will not use any memory at or above this address.
*
* The user can reserve local memory from the board by declaring the
* macro USER_RESERVED_MEM with the amount of memory to reserve. This
* routine will return a pointer to the first byte of the reserved memory
* area.
*
* RETURNS: The address of the top of usable memory.
*/

char *sysMemTop (void)
    {
    static char * memTop = NULL;

    if (memTop == NULL)
        memTop = sysPhysMemTop () - USER_RESERVED_MEM;

    return (memTop);
    }

⌨️ 快捷键说明

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