📄 bootconfig.c
字号:
PPP_STR_MTU, /* Set MTU value for negotiation */ PPP_STR_LCP_ECHO_FAILURE, /* Set max # consecutive LCP echo failures */ PPP_STR_LCP_ECHO_INTERVAL, /* Set time for LCP echo requests */ PPP_STR_LCP_RESTART, /* Set timeout for LCP */ PPP_STR_LCP_MAX_TERMINATE, /* Set max # xmits for LCP term-reqs */ PPP_STR_LCP_MAX_CONFIGURE, /* Set max # xmits for LCP conf-reqs */ PPP_STR_LCP_MAX_FAILURE, /* Set max # conf-naks for LCP */ PPP_STR_IPCP_RESTART, /* Set timeout for IPCP */ PPP_STR_IPCP_MAX_TERMINATE, /* Set max # xmits for IPCP term-reqs */ PPP_STR_IPCP_MAX_CONFIGURE, /* Set max # xmits for IPCP conf-reqs */ PPP_STR_IPCP_MAX_FAILURE, /* Set max # conf-naks for IPCP */ PPP_STR_LOCAL_AUTH_NAME, /* Set local name for authentication */ PPP_STR_REMOTE_AUTH_NAME, /* Set remote name for authentication */ PPP_STR_PAP_FILE, /* Set the PAP secrets file */ PPP_STR_PAP_USER_NAME, /* Set username for PAP auth with peer */ PPP_STR_PAP_PASSWD, /* Set password for PAP auth with peer */ PPP_STR_PAP_RESTART, /* Set timeout for PAP */ PPP_STR_PAP_MAX_AUTHREQ, /* Set max # xmits for PAP auth-reqs */ PPP_STR_CHAP_FILE, /* Set the CHAP secrets file */ PPP_STR_CHAP_RESTART, /* Set timeout for CHAP */ PPP_STR_CHAP_INTERVAL, /* Set interval for CHAP rechallenge */ PPP_STR_CHAP_MAX_CHALLENGE /* Set max # xmits for CHAP challenge */ }; #endif /* INCLUDE_PPP */#endif /* INCLUDE_NETWORK *//* forward declarations */#ifdef __STDC__void usrRoot (char *pMemPoolStart, unsigned memPoolSize);void usrClock (void);void usrKernelInit (void);LOCAL void bootCmdLoop (void);LOCAL char autoboot (int timeout);LOCAL void printBootLogo (void);LOCAL void bootHelp (void);LOCAL STATUS bootLoad (char *bootString, FUNCPTR *pEntry);LOCAL void go (FUNCPTR entry);LOCAL void m (char *adrs);LOCAL void d (char *adrs, int nwords);LOCAL void bootExcHandler (int tid);LOCAL void skipSpace (char **strptr);LOCAL void printExcMsg (char *string);LOCAL STATUS getArg (char **ppString, int *pValue, BOOL defaultHex, BOOL optional);LOCAL void usrBootLineInit (int startType);LOCAL STATUS usrBootLineCrack (char *bootString, BOOT_PARAMS *pParams);#ifdef INCLUDE_NETWORKLOCAL STATUS netLoad (char *hostName, char *fileName, char *usr, char *passwd, FUNCPTR *pEntry);LOCAL void netifAdrsPrint (char *ifname);LOCAL STATUS checkInetAddrField (char *pInetAddr, BOOL subnetMaskOK);LOCAL STATUS usrNetIfAttach (char *devName, int unitNum, char *inetAdrs);LOCAL STATUS usrNetIfConfig (char *devName, int unitNum, char *inetAdrs, char *inetName, int netmask);LOCAL STATUS usrBpInit (char *devName, int unitNum, u_long startAddr);LOCAL STATUS usrSlipInit (char *pBootDev, int unitNum, char *localAddr, char *peerAddr);LOCAL STATUS usrPPPInit (char *pBootDev, int unitNum, char *localAddr, char *peerAddr);LOCAL STATUS bootpGet (char *pNetDev, char *pBootDevAddr, char *pBootFile, char *pHostAddr, int *pMask);#ifdef INCLUDE_DHCPCLOCAL STATUS dhcpGet (char *pNetDev, char *pBootDevAddr, char *pBootFile, char *pHostAddr, int *pMask, DHCP_LEASE_DATA *pDhcpLease);#endif#endif /* INCLUDE_NETWORK */#ifdef INCLUDE_SCSI_BOOTLOCAL STATUS scsiLoad (int bootDevId, int bootDevLUN, char *fileName, FUNCPTR *pEntry);#endif /* INCLUDE_SCSI_BOOT */#ifdef INCLUDE_FDLOCAL STATUS fdLoad (int drive, int type, char *fileName, FUNCPTR *pEntry);#endif /* INCLUDE_FD */#ifdef INCLUDE_IDELOCAL STATUS ideLoad (int drive, int type, char *fileName, FUNCPTR *pEntry);#endif /* INCLUDE_IDE */#ifdef INCLUDE_ATALOCAL STATUS ataLoad (int ctrl, int drive, char *fileName, FUNCPTR *pEntry);#endif /* INCLUDE_ATA */#ifdef INCLUDE_PCMCIALOCAL STATUS pcmciaLoad (int sock, char *fileName, FUNCPTR *pEntry);#endif /* INCLUDE_PCMCIA */#ifdef INCLUDE_TFFSLOCAL STATUS tffsLoad (int drive, int removable, char *fileName, FUNCPTR *pEntry);#endif /* INCLUDE_TFFS */#ifdef INCLUDE_TSFS_BOOTLOCAL STATUS tsfsLoad (char * fileName, FUNCPTR * pEntry);LOCAL void wdbRebootEventGet (void * pNode, WDB_EVT_DATA * pEvtData);#endif /* INCLUDE_TSFS_BOOT */#elsevoid usrRoot ();void usrClock ();void usrKernelInit ();LOCAL void bootCmdLoop ();LOCAL char autoboot ();LOCAL void printBootLogo ();LOCAL void bootHelp ();LOCAL STATUS bootLoad ();LOCAL void go ();LOCAL void m ();LOCAL void d ();LOCAL void bootExcHandler ();LOCAL void skipSpace ();LOCAL void printExcMsg ();LOCAL STATUS getArg ();LOCAL void usrBootLineInit ();LOCAL STATUS usrBootLineCrack ();#ifdef INCLUDE_NETWORKLOCAL STATUS netLoad ();LOCAL void netifAdrsPrint ();LOCAL STATUS checkInetAddrField ();LOCAL STATUS usrNetIfAttach ();LOCAL STATUS usrNetIfConfig ();LOCAL STATUS usrBpInit ();LOCAL STATUS usrSlipInit ();LOCAL STATUS usrPPPInit ();LOCAL STATUS bootpGet ();#endif /* INCLUDE_NETWORK */#ifdef INCLUDE_SCSI_BOOTLOCAL STATUS scsiLoad();#endif /* INCLUDE_SCSI_BOOT */#ifdef INCLUDE_FDLOCAL STATUS fdLoad ();#endif /* INCLUDE_FD */#ifdef INCLUDE_IDELOCAL STATUS ideLoad ();#endif /* INCLUDE_IDE */#ifdef INCLUDE_ATALOCAL STATUS ataLoad ();#endif /* INCLUDE_ATA */#ifdef INCLUDE_PCMCIALOCAL STATUS pcmciaLoad ();#endif /* INCLUDE_PCMCIA */#ifdef INCLUDE_TFFSLOCAL STATUS tffsLoad ();#endif /* INCLUDE_TFFS */#ifdef INCLUDE_TSFS_BOOTLOCAL STATUS tsfsLoad ();LOCAL void wdbRebootEventGet ();#endif /* INCLUDE_TSFS_BOOT */#endif /* __STDC__ */void sysLedConfig(void);void dv_putc(char c);void dvStringOut (char *pMsg);void dvHexOut (UINT32 value);void dvHexDig (UINT8 value);void dv_setbaud();void dv_delay();void dv_testmem(UINT32 *start, UINT32 *end);/********************************************************************************* usrInit - user-defined system initialization routine** This routine is called by the start-up code in romStart(). It is called* before kernel multi-tasking is enabled, with the interrupts locked out.** It starts by clearing BSS, so all variables are initialized to 0 as per* the C specification. Then it sets up exception vectors, initializes the* hardware by calling sysHwInit(), and finally starts the kernel with the* usrRoot() task to do the remainder of the initialization.** NOMANUAL*/void usrInit ( int startType ) { /* * This trap will catch improper loading of the data section. * We check the magic cookie values to make sure the data section is * in the expected memory location. We do not want * to proceed further if the data segment is not correct. * * It should be easy to detect entry into the trap using an ICE, JTAG, * or logic analyzer. Without the trap, the processor is likely to run * away out of control. * * Data section misalignment can occur when there is a change in tool * chain, build rules, compiler, host utilites, etc. */#if 0 *((volatile unsigned int *)0xc8004004)=0x2080; /*initialize gpio*/ *((volatile unsigned int *)0xc8004000)=0x0c00;#endif sysLedConfig(); /*initialize gpio pin 0,1,2,3,12 as output mode*//* dv_setbaud(); dvStringOut("Hello, Davey!\r\t");*/ while (trapValue1 != TRAP_VALUE_1 || trapValue2 != TRAP_VALUE_2) { /* infinite loop */; } #if (CPU_FAMILY == SPARC) excWindowInit (); /* SPARC window management */#endif#if (CPU_FAMILY == MIPS) sysGpInit (); /* MIPS global pointer */#endif /* (CPU_FAMILY == MIPS) */#ifdef INCLUDE_SYS_HW_INIT_0 /* * Perform any BSP-specific initialisation that must be done before * cacheLibInit() is called and/or BSS is cleared. */ SYS_HW_INIT_0 ();#endif /* INCLUDE_SYS_HW_INIT_0 */ /* configure data and instruction cache if available and leave disabled */#ifdef INCLUDE_CACHE_SUPPORT /* * SPR 73609: If a cache is not to be enabled, don't require * its mode to be defined. Instead, default it to disabled. */# if (!defined(USER_D_CACHE_ENABLE) && !defined(USER_D_CACHE_MODE))# define USER_D_CACHE_MODE CACHE_DISABLED# endif /* !USER_D_CACHE_ENABLE && !USER_D_CACHE_MODE */# if (!defined(USER_I_CACHE_ENABLE) && !defined(USER_I_CACHE_MODE))# define USER_I_CACHE_MODE CACHE_DISABLED# endif /* !USER_I_CACHE_ENABLE && !USER_I_CACHE_MODE */ cacheLibInit (USER_I_CACHE_MODE, USER_D_CACHE_MODE);#endif /* INCLUDE_CACHE_SUPPORT */#if (CPU == SPARClite) cacheLib.textUpdateRtn = NULL; /* XXX - mod hist 07u */#endif /* don't assume bss variables are zero before this call */ bzero (edata, end - edata); /* zero out bss variables */ sysStartType = startType; intVecBaseSet ((FUNCPTR *) VEC_BASE_ADRS); /* set vector base table */#if (CPU_FAMILY == AM29XXX) excSpillFillInit (); /* am29k stack cache managemt */#endif excVecInit (); /* install exception vectors */ sysHwInit (); /* initialize system hardware *//* dv_setbaud(); dvStringOut("Hello, Davey1\n"); */ usrKernelInit (); /* configure the Wind kernel */#if (CPU==SPARC) || (CPU_FAMILY==I80X86) /* XXX workaround for sun1e */#undef USER_I_CACHE_ENABLE /* XXX disable instruction cache */#endif /* (CPU==SPARC) || (CPU_FAMILY==I80X86) */#ifdef INCLUDE_CACHE_SUPPORT#ifdef USER_I_CACHE_ENABLE cacheEnable (INSTRUCTION_CACHE); /* enable instruction cache */#endif /* USER_I_CACHE_ENABLE */#endif /* INCLUDE_CACHE_SUPPORT */ /* start the kernel specifying usrRoot as the root task */ kernelInit ((FUNCPTR) usrRoot, ROOT_STACK_SIZE, (char *) MEM_POOL_START_ADRS, sysMemTop (), ISR_STACK_SIZE, INT_LOCK_LEVEL); }/*test routine, by davey*/#if 1void sysLedConfig(void){ ixp425GPIOLineConfig(IXP425_GPIO_PIN_0, IXP425_GPIO_OUT); ixp425GPIOLineConfig(IXP425_GPIO_PIN_1, IXP425_GPIO_OUT); ixp425GPIOLineConfig(IXP425_GPIO_PIN_2, IXP425_GPIO_OUT); ixp425GPIOLineConfig(IXP425_GPIO_PIN_3, IXP425_GPIO_OUT); ixp425GPIOLineConfig(IXP425_GPIO_PIN_12, IXP425_GPIO_OUT);}voiddv_putc(char c){ UINT32 base = 0xc8001000; UINT32 lsr; do { lsr = *(UINT32 *)(base+0x14); } while ((lsr & 0x20) == 0); *(volatile UINT32 *)(base+0x00) = c;}void dvStringOut (char *pMsg) { while (*pMsg) dv_putc (*pMsg++); }void dvHexOut (UINT32 value) { UINT8 dig, ch; UINT8 count = 28; UINT32 temp; for (dig = 0 ; dig < 8; dig++) { temp = (value >> count); temp = temp & 0x0000000f; ch = (UINT8)temp; dvHexDig (ch); count -= 4; } }void dvHexDig (UINT8 value) { UINT8 hex; hex = (value < 10) ? (value + 0x30) : (value + 55); dv_putc (hex); }void dv_setbaud(){ unsigned int base = 0xc8001000; unsigned int div = 96; unsigned int lcr; int delay=1000; lcr = *((UINT32 *)(base+0x0C)); lcr = 0x03; /*8bits one stop bit*/ *((volatile unsigned int *)(base+0x0C)) = lcr | 0x80; /*set DLAB*/ while(delay--); *((volatile unsigned int *)(base+0x00)) = div| 0xff; /*divisor low*/ *((volatile unsigned int *)(base+0x04)) = (div>>8)&0xff; /*divisor high*/ *((volatile unsigned int *)(base+0x0C)) = lcr; /*restore lcr*/ delay=1000; while(delay--); *((volatile unsigned int *)(base+0x10)) = 0x03; /*DTS|RTS*/ *((volatile unsigned int *)(base+0x08)) = 0x07; /*TX FIFO enable | RX FIFO reset | TX FIFO reset*/ *((volatile unsigned int *)(base+0x04)) = 0x00; /*disable interrupts*/ delay=1000; while(delay--); }void dv_delay(){ int n = 10000; while(n--) ;}#define TEST_MEM_START 0x00010000 /*stack area*/#define TEST_MEM_END 0x07000000 /*boot code area*/void dv_testmem(UINT32 *start, UINT32 *end){ UINT32 *ptr; printf("filling from 0x%x to 0x%x...", (UINT32)start, (UINT32)end); /*fill ptr to ptr*/ for(ptr=start; ptr<end; ptr++) { *ptr= (UINT32)ptr; if(!(((UINT32)ptr) % 0x4000)) printf("."); } printf("finish\n"); printf("verifying from 0x%x to 0x%x...", (UINT32)start, (UINT32)end); /*verify the value*/ for(ptr=start; ptr<end; ptr++) { if(*ptr != (UINT32)ptr) printf("failed at 0x%x: read value:0x%x\n", (UINT32)ptr, *ptr);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -