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

📄 syslib.c

📁 Vxworks下的C例子程序
💻 C
📖 第 1 页 / 共 3 页
字号:
*
* NOTE: This routine should not be called directly by the user.
*
* RETURNS: N/A
*/

void sysHwInit( void )
{
   volatile UINT32 temp;
   int ix, i;
   unsigned long *pDPRAM1;

#ifdef INCLUDE_VWARE_LAUNCH
   char vwareMacAdrs[VWARE_MAC_ADRS_LEN];
#endif /* INCLUDE_VWARE_LAUNCH */


    /* Get the physical location of the IMMR register */
    int immrVal = vxImmrGet() ;

/* load ethernet Macaddress from flash ,and write to globe variable array: sysFecEnetAddr[],*/            	

    /*if mac is changed, load new mac address,otherwise use default mac address:ETHERNET_MAC_ADRS*/
    /*is 0x0008d200 or other any value.*/
    if( *(UINT16 *)(PARA_BASE_ADRS + PARA_MACADRS_OFFSET) != 0xffff )
    {

#ifdef INCLUDE_MOT_FCC
     bcopy ((char *) (PARA_BASE_ADRS + PARA_MACADRS_OFFSET), (char *) glbEnetAddr, sizeof (glbEnetAddr));
   
#endif
    }


    RunLed(0x0);

    /* Issue a Software Reset Command to the CPM core */
    sysCpmReset();

    /* Initialize the LEDs */
    /*sysLedInit();*/

    /* Initialize DPRAM1 to zero.  */
    pDPRAM1 = (unsigned long *)immrVal;
    

    for (ix = 0; ix < 0x1000; ix++)
      *pDPRAM1++ = 0;

    /*  reset port A, B, C, and D */
    * M8260_IOP_PADIR(immrVal) = 0x00000000;
    * M8260_IOP_PAPAR(immrVal) = 0x00000000;
    * M8260_IOP_PASO(immrVal) = 0x00000000;
    * M8260_IOP_PAODR(immrVal) = 0x00000000;
    * M8260_IOP_PADAT(immrVal) = 0x00000000;

    * M8260_IOP_PBDIR(immrVal) = 0x00000000;
    * M8260_IOP_PBPAR(immrVal) = 0x00000000;
    * M8260_IOP_PBSO(immrVal) = 0x00000000;
    * M8260_IOP_PBODR(immrVal) = 0x00000000;
    * M8260_IOP_PBDAT(immrVal) = 0x00000000;

    * M8260_IOP_PCDIR(immrVal) = 0x00000000;
    * M8260_IOP_PCPAR(immrVal) = 0x00000000;
    * M8260_IOP_PCSO(immrVal) = 0x00000000;
    * M8260_IOP_PCODR(immrVal) = 0x00000000;
    * M8260_IOP_PCDAT(immrVal) = 0x00000000;

    * M8260_IOP_PDDIR(immrVal) = 0x00000000;
    * M8260_IOP_PDPAR(immrVal) = 0x00000000;
    * M8260_IOP_PDSO(immrVal) = 0x00000000;
    * M8260_IOP_PDODR(immrVal) = 0x00000000;
    * M8260_IOP_PDDAT(immrVal) = 0x00000000;

* M8260_PCI_BR0(immrVal) = 0x30000001;
* M8260_PCI_MSK0(immrVal) = 0xfe000000;
    
* M8260_PCI_BR1(immrVal) = 0x40000001;
* M8260_PCI_MSK1(immrVal) = 0xfe000000;

    /*
     * Initialize SICR.
     */
    *M8260_SICR( immrVal ) = 0x00000000;

 for(i = 0; i < 1000000; i++);
    /*
     * Initialize interrupts - default interrupt level.
     */
  
    m8260IntrInit() ;
      *M8260_IOP_PADIR( immrVal ) |= (PA7|PA8); 

 for(i = 0; i < 1000000; i++);
     
    if (sysChipRev() == SILICON_REV_PREA1)
       {
         temp = *M8260_SIUMCR( immrVal );
         temp &= 0xf3ffffff;    /* First clear DPPC ...   */
         temp |= 0x08000000;    /* ... then enable TBEN. */
         *M8260_SIUMCR( immrVal ) = temp;
       } 


 for(i = 0; i < 1000000; i++);
 
	/* 
	 * Init the DPRAM lib 
	 */
	sys82xxDpramLibInit();

	for(i = 0; i < 1000000; i++);

    /*
     * Setup port D for SMC1.
     */
    *M8260_IOP_PDPAR( immrVal ) |= (PD8 | PD9);
    *M8260_IOP_PDDIR( immrVal ) |=  PD9;


    
/*LEDs*/


   /*
     * Reset serial channels.
     */
    sysSerialHwInit();



  
#ifdef  FORCE_DEFAULT_BOOT_LINE
    strncpy(sysBootLine,DEFAULT_BOOT_LINE,strlen(DEFAULT_BOOT_LINE)+1);

#elif defined INCLUDE_VWARE_LAUNCH

    
#endif /* FORCE_DEFAULT_BOOT_LINE */

 	/* make sure Ethernet is disabled */
/*
#ifdef INCLUDE_MOT_SCC
	sysSccEnetDisable   ( 0 ) ;
	sysSccEnetIntDisable( 0 ) ;
#endif 
*/  /*move by yuecode*//* INCLUDE_MOT_SCC */
#ifdef INCLUDE_MOT_FCC
       sysFccEnetDisable (immrVal, 1);
	sysFccEnetDisable (immrVal, 3);
#endif /* INCLUDE_MOT_FCC */

#ifdef INCLUDE_REAL_TIME_CLOCK
        initRealTimeClk(7);
#endif
}

/*******************************************************************************
*
* 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 )
{
    static char * physTop = NULL;

    if (physTop == NULL)
    {
      physTop = (char *)(LOCAL_MEM_LOCAL_ADRS + LOCAL_MEM_SIZE);
    }

    return( physTop ) ;
}

/*******************************************************************************
*
* 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 )
{
    static char * memTop = NULL;

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

    return memTop ;
}

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

STATUS sysToMonitor
    (
       int startType    /* parameter passed to ROM to tell it how to boot   */
    )
{
    FUNCPTR pRom = (FUNCPTR) (ROM_TEXT_ADRS + 4);       /* Warm reboot      */


#ifdef INCLUDE_MOT_FCC
    /*                                                                      */
    /* Get the physical location of the IMMR register                       */
    /*                                                                      */
    int immrVal = vxImmrGet() ;
#endif /* INCLUDE_MOT_FCC */

    intLock();

    cacheDisable(INSTRUCTION_CACHE);
    cacheDisable(DATA_CACHE);

#if defined(INCLUDE_AUX_CLK) || defined(INCLUDE_AUXCLK)
    sysAuxClkDisable();
#endif /* INCLUDE_AUX_CLK || INCLUDE_AUXCLK */

#ifdef INCLUDE_MOT_SCC
    sysSccEnetDisable( 0 );     /* disable the ethernet device              */
    sysSccEnetIntDisable( 0 );  /* disable the ethernet device interrupt    */
#endif /* INCLUDE_MOT_SCC */

#ifdef INCLUDE_MOT_FCC
    /* disable the FCC */
    sysFccEnetDisable (immrVal, 1);
#endif /* INCLUDE_MOT_FCC */

    sysSerialReset();           /* reset the serial device                  */

    vxMsrSet(0);

    (*pRom) (startType);        /* jump to bootrom entry point              */

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


/******************************************************************************
*
* sysHwInit2 - initialize additional system hardware
*
* This routine connects system interrupt vectors and configures any 
* required features not configured by sysHwInit().
*
* RETURNS: N/A
*/

void sysHwInit2 (void)
{
    static BOOL configured = FALSE ; 
    if ( ! configured )
    {
#if defined(INCLUDE_AUXCLK) || defined(INCLUDE_AUXCLK)
        /*
         * initialize and start auxiliary clock support
         */
        sysAuxClkEnable();
#endif /* INCLUDE_AUXCLK */

        /*
         * initialize serial interrupts
         */
        sysSerialHwInit2() ;

        /*
         * 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 the CPU board.  Processor numbers
* should be unique on a single backplane.  It also maps local resources onto
* the VMEbus.
*
* RETURNS: N/A
*
* SEE ALSO: sysProcNumGet()
*
*/

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

/*******************************************************************************
*
* vxImmrSet - Set the IMMR to a specific value
*
* This routine sets the IMMR to a specific value
*
* RETURNS: N/A
*/

void vxImmrSet (UINT32 value)
    {
    immrAddress = value;
    return;
    }

/*******************************************************************************
*
* vxImmrGet - return the current IMMR value
*
* This routine returns the current IMMR value
*
* RETURNS: current IMMR value
*
*/

UINT32  vxImmrGet (void)
    {
    return (immrAddress);
    }

/*******************************************************************************
*
* sysBaudClkFreq - returns the frequency of the BRG clock
*
* This routine returns the frequency of the BRG clock
*
* NOTE: From page 9-5 in Rev0 of 8260 book
*
*       baud clock = 2*cpm_freq/2^2*(DFBRG+1) where DFBRG = 01
*                  = 2*cpm_freq/16
*
* RETURNS: Frequence in HZ
*
*/

int sysBaudClkFreq(void)
	{
    UINT32 cpmFreq = sysCpmFreqGet();

    if (cpmFreq == ERROR)
        return ERROR;
    else
        return cpmFreq*2/16; 
	}

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

⌨️ 快捷键说明

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