📄 syslib.c
字号:
*
* 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
/* 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. 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;
UINT32 * p = (UINT32 *)ROM_TEXT_ADRS;
#ifdef INCLUDE_SNDS_END
END_OBJ * pEnd;
#endif
/*
* Examine ROM - if it's a VxWorks boot ROM, jump to the warm boot entry
* point; otherwise jump to the start of the ROM.
* A VxWorks boot ROM begins
* MOV R0,#BOOT_COLD
* B ...
* DCB "Copyright"
* We check the first and third words only. This could be tightened up
* if required (see romInit.s).
*/
if (p[0] == 0xE3A00002 && p[2] == 0x79706F43)
pRom = (FUNCPTR)(ROM_TEXT_ADRS + 4); /* warm boot address */
else
pRom = (FUNCPTR)ROM_TEXT_ADRS; /* start of ROM */
#ifdef INCLUDE_SNDS_END
/*
* Reset Ethernet controller to prevent it doing anything
* before jumping to the bootrom.
*/
pEnd = endFindByName ("secEnd", 0);
if (pEnd != NULL)
pEnd->pFuncTable->stop(pEnd->devObject.pDevice);
#endif /* INCLUDE_SNDS_END */
#if (CPU == ARM710A)
VM_ENABLE(FALSE); /* disable the MMU, D-cache and write-buffer */
#endif
(*pRom)(startType); /* jump to bootrom */
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 0;
}
/****************************************************************************
*
* 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;
}
/******************************************************************************
*
* sysLedsReadWrite - read/write the state of the LEDs on the board
*
* This routine can be used to read and write the state of the four LEDs
* on the board. The current state is ANDed and EORed with the supplied
* parameters. Bits 0..3 control LEDs 1..4. A 1 switches the LED on; a 0 off.
*
* Assume that LK9 is out, so BIDEN is high.
*
* RETURNS: previous state of LEDs.
*/
int sysLedsReadWrite
(
int and,
int eor
)
{
static UINT8 current = 0;
int oldLevel, previous;
UINT8 * ppbase = (UINT8 *)PARALLEL_BASE_ADR;
oldLevel = intLock();
ppbase[8] = 0; /* set output mode */
previous = current;
current = (current & and) ^ eor;
ppbase[0] = current << 4; /* write to Port Register b4..7*/
intUnlock(oldLevel);
return previous;
}
/******************************************************************************
*
* sysNvRamGet - get the contents of non-volatile RAM
*
* This routine copies the contents of non-volatile memory into a specified
* string. The string is terminated with an EOS.
*
* NOTE: This routine has no effect, since there is no non-volatile RAM.
*
* RETURNS: ERROR, always.
*
* SEE ALSO: sysNvRamSet()
*/
STATUS sysNvRamGet
(
char *string, /* where to copy non-volatile RAM */
int strLen, /* maximum number of bytes to copy */
int offset /* byte offset into non-volatile RAM */
)
{
sndsIICRead (EEPROM_SLAVE_ADDR, EEPROM_BOOTLINE_ADDR, string, strLen);
return OK;
}
/*******************************************************************************
*
* sysNvRamSet - write to non-volatile RAM
*
* This routine copies a specified string into non-volatile RAM.
*
* NOTE: This routine has no effect, since there is no non-volatile RAM.
*
* RETURNS: ERROR, always.
*
* SEE ALSO: sysNvRamGet()
*/
STATUS sysNvRamSet
(
char *string, /* string to be copied into non-volatile RAM */
int strLen, /* maximum number of bytes to copy */
int offset /* byte offset into non-volatile RAM */
)
{
sndsIICWrite(EEPROM_SLAVE_ADDR, EEPROM_BOOTLINE_ADDR, string, strLen);
return OK;
}
#ifdef INCLUDE_FLASH
/******************************************************************************
*
* sysFlashBoardDelay - create a delay
*
* This routine is used by flashMem.c to produce specified delays. It
* appears that the Flash driver cannot use taskDelay() at certain
* points.
*
* RETURNS: N/A
*/
void sysFlashBoardDelay (void)
{
return;
}
#endif /* INCLUDE_FLASH */
#ifdef INCLUDE_CACHE_SUPPORT
void sndsCacheEnable
(
int cachesize
)
{
UINT32 result;
SNDS_CTRL_REG_READ(SNDS_SYSCFG,result);
switch(cachesize)
{
case SNDS_CACHE_4K:
sndsCacheFlush();
SNDS_CTRL_REG_WRITE(SNDS_SYSCFG, (result & ~SNDS_CACHE_MODE));
SNDS_CTRL_REG_WRITE(SNDS_SYSCFG, (result|SNDS_WRITE_BUFF|SNDS_CACHE_ENABLE));
break;
case SNDS_CACHE_8K:
sndsCacheFlush();
SNDS_CTRL_REG_WRITE(SNDS_SYSCFG, (result & ~SNDS_CACHE_MODE));
SNDS_CTRL_REG_WRITE(SNDS_SYSCFG, (result|SNDS_WRITE_BUFF|SNDS_CACHE_ENABLE|SNDS_CACHE_8K));
break;
default:
break;
}
}
void sndsCacheDisable(void)
{
UINT32 result;
SNDS_CTRL_REG_READ(SNDS_SYSCFG, result);
SNDS_CTRL_REG_WRITE(SNDS_SYSCFG, (result & ~(SNDS_CACHE_ENABLE|SNDS_WRITE_BUFF)));
}
void sndsCacheFlush(void)
{
int i;
UINT32 *tagram;
tagram = (UINT32 *)SNDS_TAGRAM;
sndsCacheDisable();
for(i=0; i < 256; i++)
{
*tagram = 0x00000000;
tagram += 1;
}
}
#endif /* INCLUDE_CACHE_SUPPORT */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -