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

📄 syslib.c

📁 标准powerpc bsp vxworks模板
💻 C
📖 第 1 页 / 共 2 页
字号:
    sysSerialHwInit();		/* serial devices */#endif#ifdef INCLUDE_VME    /* TODO - any VME hardware setup/reset */#endif#ifdef INCLUDE_PCI    /* TODO - PCI hardware setup/reset */#endif#ifdef INCLUDE_FLASH    /* TODO - any Flash ROM hardware setup/reset */#endif    }/********************************************************************************* sysHwInit2 - initialize additional system hardware** This routine connects system interrupt vectors and configures any* required features not configured by sysHwInit. It is called from usrRoot()* in usrConfig.c after the multitasking kernel has started.** RETURNS: N/A*/void sysHwInit2 (void)    {    static int	initialized;	/* must protect against double call! */    if (!initialized)	{	initialized = TRUE;	/*         * TODO - connect timer and abort vector interrupts and enable	 * those interrupts as needed.         */#ifdef INCLUDE_NETWORK	sysNetHwInit2 ();	/* network interface */#endif#ifdef INCLUDE_SERIAL	sysSerialHwInit2 ();	/* connect serial interrupts */#endif#ifdef INCLUDE_VME	/* TODO - any secondary VME setup */#endif#ifdef INCLUDE_PCI	/* TODO - any secondary PCI setup */#ifdef INCLUDE_PCI_AUTOCONF	sysPciAutoConfig();#if defined(INCLUDE_NETWORK) && defined(INCLUDE_END)       /* TODO - update load string routine */#endif /* defined(INCLUDE_NETWORK) && defined(INCLUDE_END) */#endif /* INCLUDE_PCI_AUTOCONF */#endif /* INCLUDE_PCI */	/* L2 Cache setup */#if	defined(INCLUDE_CACHE_SUPPORT) && defined(INCLUDE_CACHE_L2)#  ifdef USER_L2_CACHE_ENABLE	sysL2CacheInit ();#  else	sysL2CacheDisable ();#  endif#endif /*(INCLUDE_CACHE_SUPPORT) && (INCLUDE_CACHE_L2)*/	}    }/********************************************************************************* 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)	{#ifdef LOCAL_MEM_AUTOSIZE	/* TODO - If auto-sizing is possible, this would be the spot.  */#	error	"Dynamic memory sizing not supported"#else	/* Don't do autosizing, if size is given */	physTop = (char *)(LOCAL_MEM_LOCAL_ADRS + LOCAL_MEM_SIZE);#endif /* LOCAL_MEM_AUTOSIZE */	}    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.** The entry point for a warm boot is defined by the macro ROM_WARM_ADRS* in config.h.  We do an absolute jump to this address to enter the* ROM code.** RETURNS: Does not return.*/STATUS sysToMonitor    (    int startType    /* parameter passed to ROM to tell it how to boot */    )    {    FUNCPTR pRom = (FUNCPTR) (ROM_WARM_ADRS);    intLock ();			/* disable interrupts */    cacheDisable (0);   	/* Disable the Instruction Cache */    cacheDisable (1);   	/* Disable the Data Cache */#if     (CPU == PPC604)    vxHid0Set (vxHid0Get () & ~_PPC_HID0_SIED);	/* Enable Serial Instr Exec */#endif  /* (CPU == PPC604) */    sysHwInit ();		/* disable all sub systems to a quiet state */    vxMsrSet (0);		/* Clear the MSR */    (*pRom) (startType);	/* jump to romInit.s */    return (OK);		/* in case we 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** This routine sets the processor number for the CPU board.  Processor numbers* should be unique on a single backplane.** For bus systems, it is assumes that processor 0 is the bus master and* exports its memory to the bus.** RETURNS: N/A** SEE ALSO: sysProcNumGet()*/void sysProcNumSet    (    int procNum			/* processor number */    )    {    sysProcNum = procNum;    if (procNum == 0)        {#ifdef INCLUDE_VME	/* TODO - one-time setup of slave window control registers */#endif#ifdef INCLUDE_PCI	/* TODO - Enable/Initialize the interface as bus slave */#endif	}    }/********************************************************************************* sysCpuCheck - confirm the CPU type** This routine validates the cpu type.  If the wrong cpu type is discovered* a message is printed using the serial channel in polled mode.** RETURNS: N/A.*/void sysCpuCheck (void)    {    int msgSize;    int msgIx;    SIO_CHAN * pSioChan;        /* serial I/O channel */    /* Check for a valid CPU type;  If one is found, just return */#if	(CPU == PPC603)    if	((CPU_TYPE == CPU_TYPE_603) || (CPU_TYPE == CPU_TYPE_603E) ||         (CPU_TYPE == CPU_TYPE_603P))	{	return;	}#else	/* (CPU == PPC604) */    if	((CPU_TYPE == CPU_TYPE_604) || (CPU_TYPE == CPU_TYPE_604E))	{	return;	}#endif	/* (CPU == PPC604) */    /* Invalid CPU type; print error message and terminate */    msgSize = strlen (wrongCpuMsg);    sysSerialHwInit ();    pSioChan = sysSerialChanGet (0);    sioIoctl (pSioChan, SIO_MODE_SET, (void *) SIO_MODE_POLL);    for (msgIx = 0; msgIx < msgSize; msgIx++)    	{    	while (sioPollOutput (pSioChan, wrongCpuMsg[msgIx]) == EAGAIN);    	}    sysToMonitor (BOOT_NO_AUTOBOOT);    }/******************************************************************************** sysLanIntEnable - enable the LAN interrupt** This routine enables interrupts at a specified level for the on-board LAN* chip.** RETURNS: OK, or ERROR if network support not included.** SEE ALSO: sysLanIntDisable()*/STATUS sysLanIntEnable    (    int intLevel 		/* interrupt level to enable */    )    {#ifdef INCLUDE_NETWORK    /* TODO - enable lan interrupt */        return (OK);#else    return (ERROR);#endif /* INCLUDE_NETWORK */    }/******************************************************************************** sysLanIntDisable - disable the LAN interrupt** This routine disables interrupts for the on-board LAN chip. ** RETURNS: OK, or ERROR if network support not included.** SEE ALSO: sysLanIntEnable()*/STATUS sysLanIntDisable    (    int intLevel 		/* interrupt level to enable */    )    {#ifdef INCLUDE_NETWORK    /* TODO - disable lan interrupt */        return (OK);#else    return (ERROR);#endif /* INCLUDE_NETWORK */    }/******************************************************************************** sysLanEnetAddrGet - retrieve ethernet address.** This routine returns a six-byte ethernet address for a given ethernet unit.* The template END driver uses this routine to obtain the ethernet address if* indicated by a user-flag in END_LOAD_STRING in configNet.h; or if the* reading the ethernet address ROM is unsuccessful.** RETURNS: OK or ERROR if ROM has valid standard ethernet address*/STATUS sysLanEnetAddrGet    (    int		unit,    char *	enetAdrs    )    {    /* TODO -The default return code is ERROR, change function if necessary. */        return (ERROR);    }volatile static int sysNanoDummy = 1; /* dummy variable for spin loop *//******************************************************************************** sysNanoDelay - delay for specified number of nanoseconds** This function implements a spin loop type delay for at* least the specified number of nanoseconds.  This is not a task delay,* control of the processor is not given up to another task.  The actual delay* will be equal to or greater than the requested number of nanoseconds.** The purpose of this function is to provide a reasonably accurate time delay* of very short duration.  It should not be used for any delays that are much* greater than two system clock ticks in length.  For delays of a full clock* tick, or more, the use of taskDelay() is recommended.** This routine is interrupt safe.** .nT** RETURNS: N/A.** SEE ALSO:* .sA*/ void sysNanoDelay    (    UINT32 nanoseconds	/* nanoseconds to delay */    )    {    int i;    /*     * TODO - setup a calibrated spin loop.     *     * In this example code, we assume that one pass of the spin     * loop takes 1 microsecond for this BSP and processor.  Be sure     * to use 'volatile' as appropriate to force the compiler to      * not optimize your code.     *     * Must be interrupt safe.     *     * To calibrate, set SYS_LOOP_NANO to 1.  Measure the elapsed time     * for sysNanoDelay(1000000) to execute.  Set SYS_NANO_LOOP to the     * the number of milliseconds measured (round up to integer!).     * (or measure time for sysNanoDelay(1000) and set SYS_NANO_LOOP     * to the measured number of microseconds, rounded up to an integer).     */#define SYS_LOOP_NANO	1000	/* loop time in nanoseconds */    sysNanoDummy = 1;    for (i = 0; i < (nanoseconds/SYS_LOOP_NANO) + 1; i++)	{	sysNanoDummy += 1;	sysNanoDummy *= 2;	}    }

⌨️ 快捷键说明

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