📄 syslib.c
字号:
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 */ } }/********************************************************************************* sysPhysMemTop - get the address of the physical top of memory** This routine returns the address of the first missing byte of memory,* which indicates the top of memory.** Memory probing begins at the end of BSS; at every 4K boundary a byte* is read until it finds one that cannot be read, or* 4MB have been probed, whichever is first.** RETURNS: The address of the top of memory.** INTERNAL* This routine is used by sysHwInit() to differentiate between models.* It is highly questionable whether vxMemProbe() can be used during the* initial stage of booting.*/char* sysPhysMemTop (void) { static char *memTop = NULL; /* top of memory */ char gdtr[6]; if (memTop == NULL) {#ifdef LOCAL_MEM_AUTOSIZE# define TEST_PATTERN 0x12345678# define SYS_PAGE_SIZE 0x10000# define N_TIMES 3 int delta = SYS_PAGE_SIZE; BOOL found = FALSE; int temp[N_TIMES]; 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);#else memTop = (char *)(LOCAL_MEM_LOCAL_ADRS + LOCAL_MEM_SIZE);#endif /* LOCAL_MEM_AUTOSIZE */ /* copy the gdt from RAM/ROM to RAM, update, load */ bcopy ((char *)sysGdt, (char *)pSysGdt, GDT_ENTRIES * sizeof(GDT)); *(short *)&gdtr[0] = GDT_ENTRIES * sizeof(GDT) - 1; *(int *)&gdtr[2] = (int)pSysGdt; sysLoadGdt (gdtr); } return (memTop); }/********************************************************************************* sysMemTop - get the address of the top of VxWorks memory** This routine returns the address of the first byte of memory not controlled* or used by VxWorks.** The user can reserve memory space by defining the* macro USER_RESERVED_MEM. This* routine returns the address of the reserved memory* area. The value of USER_RESERVED_MEM is specified in byte units.* When used with any MMU options, USER_RESERVED_MEM should be a multiple* of the MMU page size. This will insure that the sysPhysMemDesc[] entry* for main ram is also a multiple of the page size.** For X86 architecture, if the image is being loaded into low memory (below* 1 Mbyte) then the top of memory is forced to be 0xa0000 (640K) for* DOS compatibility. This protects the I/O area that starts at that address.** 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.** For X86, the startType argument is not used. The board is reset by* pulsing the reset line and pointing the global descriptor table to 0x0.** 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); /* disable MMU */ /* determine 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); } /* 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); } } intLock (); sysHwInit (); /* disable all sub systems to a quiet state */ sysClkDisable (); /* TODO - This assumes the keyboard controller */ 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 */ }/******************************************************************************** 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 } }/******************************************************************************** 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); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -