📄 syslib2.c
字号:
BOOL found = FALSE;
PHYS_MEM_DESC *pMmu;
int temp[N_TIMES];
char gdtr[6];
char *p;
int ix;
if (memTop != NULL)
return (memTop);
/* if (&end) is in upper memory, we assume it is VxWorks image.
* if not, it is Boot image */
if ((int)&end > 0x100000)
p = (char *)(((int)&end + (delta - 1)) & (~ (delta - 1)));
else
p = (char *)0x100000;
/* find out the actual size of the memory (max 1GB) */
for (; (int)p < 0x40000000; p += delta)
{
for (ix=0; ix<N_TIMES; ix++) /* save and write */
{
temp[ix] = *((int *)p + ix);
*((int *)p + ix) = TEST_PATTERN;
}
cacheFlush (DATA_CACHE, p, 4 * sizeof(int)); /* for 486, Pentium */
if (*(int *)p != TEST_PATTERN) /* compare */
{
p -= delta;
if (delta == VM_PAGE_SIZE)
{
memTop = p;
found = TRUE;
break;
}
delta = VM_PAGE_SIZE;
}
for (ix=0; ix<N_TIMES; ix++) /* restore */
*((int *)p + ix) = temp[ix];
}
if (!found) /* we are fooled by write-back external cache */
memTop = (char *)(LOCAL_MEM_LOCAL_ADRS + LOCAL_MEM_SIZE);
/* copy the global descriptor table from RAM/ROM to RAM */
bcopy ((char *)sysGdt, (char *)pSysGdt, GDT_ENTRIES * sizeof(GDT));
*(short *)&gdtr[0] = GDT_ENTRIES * sizeof(GDT) - 1;
*(int *)&gdtr[2] = (int)pSysGdt;
#ifdef INCLUDE_PCI
pciIomapLibInit (PCI_MECHANISM_1, PCI_CONFIG_ADDR, PCI_CONFIG_DATA, NONE);
#if FALSE
pciIomapLibInit (PCI_MECHANISM_2, PCI_CONFIG_CSE, PCI_CONFIG_FORWARD,
PCI_CONFIG_BASE);
#endif /* FALSE */
/* PCI-to-PCI bridge initialization should be done here, if it is.
* It is not necessary for Intel 430HX PCISET, which splits
* the extended memory area as follows:
* - Flash BIOS area from 4GByte to (4GB - 512KB)
* - DRAM memory from 1MB to a maximum of 512MB
* - PCI memory space from the top of DRAM to (4GB - 512KB)
*/
#ifdef INCLUDE_8472
sys8472PciInit();
#endif
#ifdef INCLUDE_FEI
sys557PciInit ();
#endif /* INCLUDE_FEI */
#else
{
GDT *pGdt = pSysGdt;
int limit = (((int)memTop) / 0x1000 - 1);
for (ix=1; ix < GDT_ENTRIES; ix++)
{
pGdt++;
pGdt->limit00 = limit & 0x0ffff;
pGdt->limit01 = ((limit & 0xf0000) >> 16) | (pGdt->limit01 & 0xf0);
}
}
#endif /* INCLUDE_PCI */
/* load the global descriptor table. set the MMU table */
sysLoadGdt (gdtr);
pMmu = &sysPhysMemDesc[2]; /* upper memory */
pMmu->len = (UINT)memTop - (UINT)pMmu->physicalAddr;
memTopPhys = memTop; /* set the real memory size */
return (memTop);
}
/*******************************************************************************
*
* 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;
if ((int)&end < 0x100000) /* this is for bootrom */
memTop = (char *)0xa0000;
}
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 by 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 pEntry;
int ix;
int iy;
int iz;
char buf[ROM_SIGNATURE_SIZE];
short *pSrc;
short *pDst;
VM_ENABLE (FALSE); /* disbale MMU */
/* decide a destination RAM address and the entry point */
if ((int)&end > 0x100000)
{
pDst = (short *)RAM_HIGH_ADRS; /* copy it in lower mem */
pEntry = (FUNCPTR)(RAM_HIGH_ADRS + ROM_WARM_HIGH);
}
else
{
pDst = (short *)RAM_LOW_ADRS; /* copy it in upper mem */
pEntry = (FUNCPTR)(RAM_LOW_ADRS + ROM_WARM_LOW);
}
/* disable 16-bit memory access */
#ifdef INCLUDE_ULTRA
sysOutByte (IO_ADRS_ULTRA + 4, sysInByte (IO_ADRS_ULTRA + 4) | 0x80);
sysOutByte (IO_ADRS_ULTRA + 5, sysInByte (IO_ADRS_ULTRA + 5) & ~0x80);
#endif /* INCLUDE_ULTRA */
#ifdef INCLUDE_ELC
sysOutByte (IO_ADRS_ELC + 5, sysInByte (IO_ADRS_ELC + 5) & ~0x80);
#endif /* INCLUDE_ELC */
/* copy EPROM to RAM and jump, if there is a VxWorks EPROM */
for (ix = 0; ix < NELEMENTS(sysRomBase); ix++)
{
bcopyBytes ((char *)sysRomBase[ix], buf, ROM_SIGNATURE_SIZE);
if (strncmp (sysRomSignature, buf, ROM_SIGNATURE_SIZE) == 0)
{
for (iy = 0; iy < 1024; iy++)
{
*sysRomBase[ix] = iy; /* map the moveable window */
pSrc = (short *)((int)sysRomBase[ix] + 0x200);
for (iz = 0; iz < 256; iz++)
*pDst++ = *pSrc++;
}
(*pEntry) (startType);
}
}
#ifdef INCLUDE_FD
if (sysWarmType == 1)
{
IMPORT int dosFsDrvNum;
fdDrv (FD_INT_VEC, FD_INT_LVL); /* initialize floppy disk */
if (dosFsDrvNum == ERROR)
dosFsInit (NUM_DOSFS_FILES); /* initialize DOS-FS */
if (usrFdConfig (sysWarmFdDrive, sysWarmFdType, "/vxboot/") == ERROR)
{
printErr ("usrFdConfig failed.\n");
return (ERROR);
}
}
#endif /* INCLUDE_FD */
#ifdef INCLUDE_ATA
if (sysWarmType == 2)
{
ATA_RESOURCE *pAtaResource = &ataResources[sysWarmAtaCtrl];
IMPORT char *memTopPhys;
IMPORT int dosFsDrvNum;
if (ataDrv (sysWarmAtaCtrl, pAtaResource->drives,
pAtaResource->intVector, pAtaResource->intLevel,
pAtaResource->configType, pAtaResource->semTimeout,
pAtaResource->wdgTimeout) == ERROR) /* initialize ATA/IDE disk */
{
printErr ("Could not initialize.\n");
return (ERROR);
}
if (dosFsDrvNum == ERROR)
dosFsInit (NUM_DOSFS_FILES); /* initialize DOS-FS */
#if (CPU_FAMILY==I80X86)
#define ATA_MEM_DOSFS 0x200000
if ((int)&end < 0x100000)
{
if ((int)memTopPhys >= (0x200000 + ATA_MEM_DOSFS))
memAddToPool ((char *)memTopPhys - ATA_MEM_DOSFS, ATA_MEM_DOSFS);
}
#endif /* (CPU_FAMILY==I80X86) */
if (usrAtaConfig (sysWarmAtaCtrl, sysWarmAtaDrive, "/vxboot/") == ERROR)
{
printErr ("usrAtaConfig failed.\n");
return (ERROR);
}
}
#endif /* INCLUDE_ATA */
#ifdef INCLUDE_TFFS
if (sysWarmType == 3)
{
IMPORT int dosFsDrvNum;
tffsDrv (); /* initialize TFFS */
if (dosFsDrvNum == ERROR)
dosFsInit (NUM_DOSFS_FILES); /* initialize DOS-FS */
if (usrTffsConfig (sysWarmTffsDrive, FALSE, "/vxboot/") == ERROR)
{
printErr ("usrTffsConfig failed.\n");
return (ERROR);
}
}
#endif /* INCLUDE_TFFS */
#if (defined(INCLUDE_FD) || defined(INCLUDE_ATA) || defined(INCLUDE_TFFS))
if ((sysWarmType == 1) || (sysWarmType == 2) || (sysWarmType == 3))
{
int fd;
if ((fd = open ("/vxboot/bootrom.sys", O_RDWR, 0644)) == ERROR)
{
if ((fd = open ("/vxboot/bootrom.dat", O_RDWR, 0644)) == ERROR)
{
printErr ("Can't open \"%s\"\n", "bootrom.{sys,dat}");
return (ERROR);
}
if (read (fd, (char *)pDst, 0x20) == ERROR) /* a.out header */
{
printErr ("Error during read file: %x\n", errnoGet ());
return (ERROR);
}
}
/* read text and data, write them to the memory */
if (read (fd, (char *)pDst, 0x98000) == ERROR)
{
printErr ("Error during read file: %x\n", errnoGet ());
return (ERROR);
}
close (fd);
(*pEntry) (startType);
}
#endif /* (INCLUDE_FD) || (INCLUDE_ATA) || (INCLUDE_TFFS) */
intLock ();
#ifdef INCLUDE_ELC
elcdetach (0);
#endif /* INCLUDE_ELC */
#ifdef INCLUDE_ULTRA
ultradetach (0);
#endif /* INCLUDE_ULTRA */
sysClkDisable ();
sysWait ();
sysOutByte (COMMAND_8042, 0xfe); /* assert SYSRESET */
sysWait ();
sysOutByte (COMMAND_8042, 0xff); /* NULL command */
sysReboot (); /* crash the global descriptor table */
return (OK); /* in case we ever continue from ROM monitor */
}
/*******************************************************************************
*
* sysIntDisable - disable a bus interrupt level
*
* This routine disables a specified bus interrupt level.
*
* RETURNS: ERROR, always.
*
* ARGSUSED0
*/
STATUS sysIntDisable
(
int intLevel /* interrupt level to disable */
)
{
return (ERROR);
}
/*******************************************************************************
*
* sysIntEnable - enable a bus interrupt level
*
* This routine enables a specified bus interrupt level.
*
* RETURNS: ERROR, always.
*
* ARGSUSED0
*/
STATUS sysIntEnable
(
int intLevel /* interrupt level to enable */
)
{
return (ERROR);
}
/****************************************************************************
*
* 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;
}
/*******************************************************************************
*
* sysDelay - allow recovery time for port accesses
*
* This routine provides a brief delay used between accesses to the same serial
* port chip.
*
* RETURNS: N/A
*/
void sysDelay (void)
{
char ix;
ix = sysInByte (0x84); /* it takes 720ns */
}
/*******************************************************************************
*
* sysStrayInt - Do nothing for stray interrupts.
*
* Do nothing for stray interrupts.
*/
LOCAL void sysStrayInt (void)
{
sysStrayIntCount++;
}
/*******************************************************************************
*
* sysMmuMapAdd - insert a new mmu mapping
*
* This routine adds a new mmu mapping entry to allow dynamic mappings.
*
* RETURNS: OK or ERROR depending on availability of free mappings.
*/
STATUS sysMmuMapAdd
(
void *address,
UINT length,
UINT initialStateMask,
UINT initialState
)
{
PHYS_MEM_DESC *pMmu;
STATUS result = OK;
pMmu = &sysPhysMemDesc[sysPhysMemDescNumEnt];
if(pMmu->virtualAddr != (void *)DUMMY_VIRT_ADDR)
result = ERROR;
else
{
pMmu->virtualAddr = address;
pMmu->physicalAddr = address;
pMmu->len = length;
pMmu->initialStateMask = initialStateMask;
pMmu->initialState = initialState;
sysPhysMemDescNumEnt += 1;
}
return (result);
}
#if FALSE
/*******************************************************************************
*
* sysIntVecSetEnt - entry hook routine for intVecSet()
*
* This is an entry hook routine for intVecSet()
*
* RETURNS: N/A
*/
LOCAL void sysIntVecSetEnt
(
FUNCPTR *vector, /* vector offset */
FUNCPTR function /* address to place in vector */
)
{
}
/*******************************************************************************
*
* sysIntVecSetExit - exit hook routine for intVecSet()
*
* This is an exit hook routine for intVecSet()
*
* RETURNS: N/A
*/
LOCAL void sysIntVecSetExit
(
FUNCPTR *vector, /* vector offset */
FUNCPTR function /* address to place in vector */
)
{
}
#endif /* FALSE */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -