bootConfig.c
上传用户:luoyougen
上传日期:2008-05-12
资源大小:23136k
文件大小:159k
源码类别:

VxWorks

开发平台:

C/C++

  1. /* bootConfig.c - system configuration module for boot ROMs */
  2. /* Copyright 1984 - 2002 Wind River Systems, Inc. */
  3. /*
  4. modification history
  5. --------------------
  6. 12q,19jun02,elr  Moved close for ftp data sockets (SPR #77169)
  7. 12p,06jun02,pai  Removed redundant error messages from xxxLoad() routines.
  8. 12o,23may02,mas  corrected args passed to smNetInit() (SPR 71787)
  9. 12n,22may02,jkf  SPR#76700, pcmciaInit must be called before muxDevLoad
  10. 12m,22may02,sbs  changed default sys clock rate to a macro (SPR #1918)
  11. 12l,16may02,vvv  restored SLIP support
  12. 12k,10may02,wap  Reduce tBoot's priority to below tNetTask's before doing
  13.                  netLoad() (SPR #76107)
  14. 12j,06may02,sbs  updating boot banner
  15. 12i,30apr02,wap  Correct arguments passed to dhcpcOptionAdd() for
  16.                  little-endian targets (SPR #73769)
  17. 12h,24apr02,mas  fixed backplane NETIF params in usrBpInit() (SPR 76236)
  18. 12g,31mar02,jkf  SPR#74251, using bootLib.h macros for array sizes
  19. 12f,28mar02,jkf  SPR#74558, bootrom: command line input length increased.
  20. 12e,22mar02,zmm  Fix mask in 'd' instruction for little endian only (SPR 5602)
  21. 12d,14mar02,hdn  added X86 specific code for HTT in go () (spr 73738)
  22. 12c,13mar02,vvv  removed references to SLIP (SPR #72992)
  23. 12b,04mar02,pch  SPR 73609
  24. 12a,29jan02,vvv  allow icmpMaskGet to work if host and target are in different
  25.                  subnets; added debug messages for netmask configuration
  26. 11z,17jan02,pcm  SPR 72642 - split excInit() into excInit() and excShowInit()
  27. 11y,10dec01,kab  SPR 71410 - stack overflow
  28. 11x,10dec01,sbs  Added version command and check for the length of bootline 
  29.                  before saving to NVRAM. 
  30. 11w,10dec01,rec  Made 'd' command endian independent (SPR 5602).
  31. 11v,09dec01,jkf  SPR#62094, 62122, need devSplit() for booting from dosfs
  32. 11u,07dec01,jkf  SPR#70548, Booting from Partitioned disks fails with SCSI
  33. 11t,30nov01,nrv  including sysTffs.c when INCLUDE_TFFS is defined
  34. 11s,28nov01,tlc  Correct diab syntax error for MIPS architecture.
  35. 11r,11nov01,sbs  Added intLock() before jumping out of boot image (SPR 3704)
  36.                  Removed '!' as an option to continue booting (SPR 7256)
  37. 11q,13nov01,yvp  Added include for private/excLibP.h
  38. 11p,27oct01,dat  Adding trap for misaligned data section SPR 9006
  39. 11o,09oct01,rae  merge from truestack ver11n.  Base 11j (SPR 25374)
  40. 11p,19oct01,vvv  fixed IP_MAX_UNITS declaration (SPR #70476)
  41. 11o,11oct01,aeg  updated initialization sequence of selectLib (SPR #31319).
  42. 11n,16sep01,dat  Use of WRS_ASM macro
  43. 11m,18jun01,mil  Cleaned up compiler warnings.
  44. 11l,27feb01,hk   update printBootLogo() copyright notice to cover 2001.
  45. 11l,07feb01,spm  added merge record for 30jan01 update from version 10z of
  46.                  tor2_0_x branch (base 10y) and fixed modification history
  47. 11k,30jan01,ijm  merged SPR# 28602 fixes: proxy ARP services are obsolete
  48. 10q,30apr99,jpd  changed copyright year from 1998 to 1999.
  49. 10p,13nov98,jpd  conditionally add sysHwInit0() call before cacheLibInit(); make
  50.  cacheEnable call depend on INCLUDE_CACHE_SUPPORT (SPR #22707).
  51. 10z,01sep99,spm  allowed proxy client and server to use any device (SPR #8993)
  52. 11j,08dec00,rae  Fixed minor #ifdef problem
  53. 11i,06dec00,rae  usrRoot can't return ERROR
  54. 11h,17nov00,spm  fixed NPT merge to allow build without END device support
  55. 11g,14nov00,rae  removed unused argument from sockLibAdd()
  56. 11f,01nov00,ham  update muxDevStopAll call in response to muxLib.c's ver 03k.
  57. 11e,17oct00,niq  Integrating T3 DHCP
  58. 11e,28feb00,gnn  merged from NPT
  59. 11d,04oct99,pul  Modification for NPT: passing the right cookie to muxDevStart
  60. 11c,29apr99,pul  Upgraded NPT phase3 code to tor2.0.0
  61. 11b,29mar99,pul  removed mmuxMCastMapAdd()
  62. 11a,26mar99,sj   added NPT support: muxLibInit; muxMaxBinds
  63. 10z,19mar99,dat  removed bp driver interface SPR 25877, fixed bug in ver 10x.
  64. 11a,19apr00,zl   fixed unitNum default to 0 in mEnet(). Updated copyright year.
  65. 10y,17mar99,spm  added support for identical unit numbers (SPR #20913)
  66. 10x,16mar99,dat  SPR 25790, fixed startup of END and BSD drivers
  67. 10w,16mar99,spm  recovered orphaned code from tor1_0_1.sens1_1 (SPR #25770)
  68. 10v,01mar99,spm  bypassed incorrect cleanup after successful TFTP file 
  69.                  transfer (SPR #24618)
  70. 10u,26feb99,dat  added FEI support (23818)
  71. 10t,19feb99,spm  fixed construction of device name for pcmcia (SPR #21676)
  72. 10s,02feb99,sgv  Added bitflag value to sockLibAdd
  73. 10r,28jan99,jmp  added TSFS_BOOT facility (SPR# 24466).
  74. 10q,20jan99,scb  usrBpInit() modified to use "sm=" before SM_ANCHOR_ADRS (23035)
  75. 10p,26jan99,jkf  removed x86 specific memAddToPool's from ataLoad,
  76.                  ideLoad, pcmciaLoad, & tffsLoad.  Replaced with
  77.                  BSP specific memAddToPool in sysHwInit2() (SPR#21338).
  78. 10o,13nov98,n_s  added call to muxDevStopAll in go. spr #23229
  79. 10n,11sep98,spm  corrected documentation for bootpGet and dhcpGet (SPR #20629)
  80. 10m,04sep98,ham  set subnetmask through ntohl() in bootpGet(),SPR#21909.
  81. 10l,03jun98,hdn  disabled system clock just before jumping to the entry point
  82.  for PentiumPro's Local APIC Timer.
  83. 10k,23apr98,yp   merged TrueFFS support
  84. 10j,01apr98,hdn  moved tffsLoad from usrTffs.c.
  85. 10i,04feb98,jpd  updated copyright date.
  86. 10h,19mar98,spm  corrected prototype for mEnet() routine (SPR #20174); changed
  87.                  parameter name to match coding standards
  88. 10g,02feb98,spm  replaced invalid logMsg calls with printf statements
  89. 10f,06jan98,hdn  added support for TFFS.
  90. 10e,30nov97,vin  added network system pool
  91. 10d,20nov97,gnn  fixed spr#7265 to deal with devices with no attach routine.
  92. 10c,27oct97,vin  fixed call to endLoadFunc(..).
  93. 10b,03oct97,gnn  removed references to endDriver global
  94. 10b,23oct97,tam  fixed compilation warnings.
  95. 10a,26sep97,gnn  added muxAddrResFuncAdd call for ipAttach
  96. 09z,26sep97,vin  used NUM_XXX_MIN macros for system pool configuration.
  97. 09y,25sep97,gnn  SENS beta feedback fixes
  98. 09x,26aug97,vin  fixed warnings in muxIoctl
  99. 09w,26aug97,spm  major overhaul of DHCP client: reorganized code and changed
  100.                  user interface to support multiple leases at runtime, improved
  101.                  handling of address information, and allowed selection of UDP
  102.                  ports; also fixed incorrect treatment of gateway field by
  103.                  BOOTP/DHCP (SPR #9137)
  104. 09v,12aug97,gnn  changes necessitated by MUX/END update.
  105. 09u,15jul97,spm  fixed byte ordering of netmask from DHCP client (SPR #8739)
  106. 09t,01jul97,jag  removed stale code for RESOLVER (SPR #8868)
  107. 09j,15aug97,cdp  add casts etc. to stop compiler warnings.
  108. 09i,05feb97,cdp  remove ARM test hook (_func_armStartup).
  109. 09h,21jan97,jpd  Added support for Olicom and lnEbsa Ethernet drivers, made
  110.                  cacheLib calls dependent upon INCLUDE_CACHE_SUPPORT being
  111.                  defined.
  112. 09g,12dec96,cdp  added _func_armStartup for ARM platforms.
  113. 09s,02jun97,spm  changed DHCP option tags to prevent name conflicts (SPR #8667)
  114. 09r,20may97,gnn  fixed SPR 8627 so that multiple gn devices are supported.
  115. 09q,19may97,spm  included rngLib.h to fix DHCP client build error (SPR #8606)
  116. 09p,30apr97,spm  moved usrNetIfConfig for "gn" device to prevent DHCP error
  117. 09o,25apr97,gnn  changed INCLUDE_GN to INCLUDE_END
  118. 09n,18apr97,spm  corrected structure element name in BOOTP interface
  119. 09m,17apr97,gnn  added support for configNet style configuration of ENDs.
  120. 09l,07apr97,spm  changed BOOTP interface to DHCP style: all options supported
  121. 09k,29jan97,spm  made global variables for DHCP client unique
  122. 09j,29jan97,spm  removed parameters from dhcpBootBind()
  123. 09i,21jan97,gnn  added the new argument to muxDevLoad().
  124. 09h,20dec96,vin  fixed warnings muxDevLoad(). added AF_ROUTE.
  125. 09g,06mar97,mas  deleted unused variable 'char gateway[INET_ADDR_LEN];' from
  126.  bootLoad() (SPR 8113).
  127. 09g,18dec96,spm  fixed bug in unit number support and restored lost DHCP code
  128. 09f,17dec96,gnn  added stuff for new etherHooks.
  129. 09e,27nov96,spm  added support for DHCP client and network device unit numbers
  130. 09d,25nov96,vin  added new cluster configuration.
  131. 09c,01oct96,spm  added bzero() call to checkInetAddrField (SPR 6326)
  132. 09b,22sep96,spm  Fixed SPR 7120: added support for gateways to BOOTP startup
  133. 09a,24jul96,vin  fetching netmask after usrNetIfConfig() mods for bsd4.4.
  134. 08z,21jun96,jmb  long modhist -- deleted entries prior to 1994.  SPR #6528
  135. 08y,19jun96,hdn  defined IDE_MEM_DOSFS to 0x200000.
  136. 08x,13jun96,hdn  added INCLUDE_ESMC for SMC91c9x Ethernet driver.
  137. 08w,05jun96,kkk  update copyright year from 1995 to 1996.
  138. 08v,05jun96,ism  bumped copyright date to 1996.
  139. 19v,19apr96,jds  changed the include of scsiLib.h to be done after config.h;
  140.                  also added setting to asynchronous mode all target devices
  141. 08u,20mar96,hdn  made inclusion of pppLib.h and strmLib.h conditional.
  142. 09t,07mar96,gnn  added SLIP_MTU to slipInit so that we could configure
  143.     the MTU.  (SPR #4652)
  144. 08s,06mar96,tpr  added #include "bootElfLib.h".
  145. 08r,06mar96,dat  removed __DATE__ from printBootLogo
  146. 08q,06mar96,tpr  Enabled the Instruction Cache for PowerPC.
  147. 08p,06dec95,vin  fixed usrStrmInit warning.
  148. 08o,29nov95,vin  added baudrate processing of boot string.
  149. 08n,06sep95,jag  deleted call to  fattachInit (), changed sadInit to 
  150.  autopushInit (), and changed iosStrmInit to strmInit (). 
  151. 08m,01aug95,dzb  changed STREAMS options to go through iosStrmInit ().
  152.  added usrStrmInit ().
  153.                  PPP initialization failure message (SPR #4505).
  154. 08l,25jul95,dzb  tweaked socket library initialization.
  155. 08k,25jul95,dzb  added socket library init for BSD vs. STREAMS.
  156. 08j,18jul95,dzb  wait for PPP interface to come up in usrPPPInit().
  157. 08i,17jul95,dzb  fixed ordering of boot params search.
  158. 08h,26jun95,dzb  removed PPP_S_USEHOSTNAME option.
  159. 08g,21jun95,dzb  Added INCLUDE_PPP_CRYPT for unbundled crypt() support.
  160. 08f,20jun95,dzb  Added PPP support.
  161. 09b,28nov95,tpr  re-ordered history following PPC merge.
  162. 09a,11oct95,dat  new BSP revision id, modified signon banner printing
  163. 08z,29jun95,caf  added nicEvb driver entry.
  164. 08y,28jun95,caf  for PPC, called cacheTextUpdate() instead of cacheClear().
  165. 08x,26jun95,kvk  Removed references to _edata and _end for a clean 
  166.  bootrom_uncmp build.
  167. 08w,06jun95,caf  fixed edata and end for Green Hills/PowerPC.
  168. 08v,26jun95,ms  updated for new serial drivers, removed WDB support.
  169. 08u,21jun95,ms  changed copywrite to 1995
  170. 08t,01jun95,caf  added support for "ilac" driver.
  171. 08s,22may95,yao  adjust reference to edata, end to SVR4 ABI standard 
  172.  for PowerPC.
  173. 08r,22may95,p_m  added WDB agent support.
  174.           + ms
  175. 08q,05apr95,kkk  changed edata & end to char arrays (spr# 3917)
  176. 08p,28mar95,kkk  made baud rate a macro in configAll.h
  177. 08o,19mar95,dvs  removed TRON references.
  178. 08n,08dec94,hdn  swapped 1st and 2nd parameters of fdDevCreate().
  179.  fixed bootHelp message; fd=... and ide=...
  180. 08m,21nov94,hdn  fixed a problem by swapping 1st and 2nd parameters of sscanf.
  181. 08l,20nov94,kdl  added hashLibInit() call if using dosFs.
  182. 08k,11nov94,dzb  added QU network interface.
  183. 08j,09nov94,jds  additions for scsi backward compatability ; scsi[12]IfInit()
  184. 08i,20oct94,hdn  used ideRawio() instead of using raw file system.
  185.  swapped 1st and 2nd parameter of ideLoad() and fdLoad().
  186. 08h,17aug94,dzb  fixed setting the gateway for a slip connection (SPR #2353).
  187.                  added INCLUDE_NETWORK macros for scalability (SPR #1147).
  188.    added CSLIP support.
  189. 08g,14jun94,caf  updated copyright notices.
  190. 08f,29may94,hdn  fixed more FTP bootrom bug in netLoad().
  191.  updated the copyright year 93 to 94.
  192.  disabled cache for i486 and Pentium.
  193. 08e,26may94,kdl  changed netLoad() to properly close FTP connections (SPR 3231).
  194. 08d,10may94,hdn  fixed the FTP bootrom bug (John's patch)
  195. 08c,09feb94,hdn  added support for if_elt 3COM EtherLink III driver.
  196.  added support for if_ene Eagle NE2000 driver.
  197. */
  198. /*
  199. DESCRIPTION
  200. This is the WRS-supplied configuration module for the VxWorks boot ROM.
  201. It is a stripped-down version of usrConfig.c, having no VxWorks shell or
  202. debugging facilities.  Its primary function is to load an object module
  203. over the network with either RSH or FTP.  Additionally, a simple set of
  204. single letter commands is provided for displaying and modifying memory
  205. contents.  Use this module as a starting point for placing applications 
  206. in ROM.
  207. */
  208. #include "vxWorks.h"
  209. #include "bootEcoffLib.h"
  210. #include "bootElfLib.h"
  211. #include "bootLib.h"
  212. #include "bootLoadLib.h"
  213. #include "bootpLib.h"
  214. #include "bsdSockLib.h"
  215. #include "cacheLib.h"
  216. #include "cbioLib.h"
  217. #include "ctype.h"
  218. #include "dosFsLib.h"
  219. #include "dpartCbio.h"
  220. #include "errno.h"
  221. #include "errnoLib.h"
  222. #include "fcntl.h"
  223. #include "fioLib.h"
  224. #include "ftpLib.h"
  225. #include "hostLib.h"
  226. #include "icmpLib.h"
  227. #include "ifLib.h"
  228. #include "if_sl.h"
  229. #include "inetLib.h"
  230. #include "intLib.h"
  231. #include "ioLib.h"
  232. #include "iosLib.h"
  233. #include "loadAoutLib.h"
  234. #include "loadCoffLib.h"
  235. #include "loadLib.h"
  236. #include "logLib.h"
  237. #include "memLib.h"
  238. #include "msgQLib.h"
  239. #include "netLib.h"
  240. #include "pipeDrv.h"
  241. #include "proxyLib.h"
  242. #include "qLib.h"
  243. #include "qPriBMapLib.h"
  244. #include "rebootLib.h"
  245. #include "remLib.h"
  246. #include "rngLib.h"
  247. #include "routeLib.h"
  248. #include "semLib.h"
  249. #include "sockLib.h"
  250. #include "stdio.h"
  251. #include "string.h"
  252. #include "sysLib.h"
  253. #include "sysSymTbl.h"
  254. #include "taskHookLib.h"
  255. #include "taskLib.h"
  256. #include "tftpLib.h"
  257. #include "tickLib.h"
  258. #include "trcLib.h"
  259. #include "unistd.h"
  260. #include "usrFdiskPartLib.h"
  261. #include "version.h"
  262. #include "wdLib.h"
  263. #include "net/if.h"
  264. #include "net/mbuf.h"
  265. #include "netinet/if_ether.h"
  266. #include "drv/netif/smNetLib.h"
  267. #include "ipProto.h"
  268. #include "private/excLibP.h"
  269. #include "private/kernelLibP.h"
  270. #include "private/workQLibP.h"
  271. #include "config.h"
  272. #include "scsiLib.h"
  273. #ifdef INCLUDE_PPP
  274. #include "pppLib.h"
  275. #endif /* INCLUDE_PPP */
  276. #ifdef INCLUDE_DHCPC
  277. #include "dhcpcLib.h"
  278. #include "dhcpcBootLib.h"
  279. #include "dhcp/dhcpc.h"
  280. #include "dhcp/dhcpcCommonLib.h"
  281. #endif
  282. #if (defined(INCLUDE_SECOND_SMNET)   || 
  283.      defined(INCLUDE_SM_NET_ADDRGET) || 
  284.      defined(INCLUDE_SM_SEQ_ADDR))
  285. # ifndef   INCLUDE_SM_NET
  286. #  define  INCLUDE_SM_NET
  287. # endif /* INCLUDE_SM_NET */
  288. #endif /* INCLUDE_SECOND_SMNET || ... */
  289. #if (defined(INCLUDE_SECOND_SMNET) && !defined(INCLUDE_SM_NET_ADDRGET))
  290. #  define INCLUDE_SM_NET_ADDRGET
  291. #endif /* INCLUDE_SECOND_SMNET && !INCLUDE_SM_NET_ADDRGET */
  292. #ifdef  INCLUDE_SM_NET
  293. # ifndef   INCLUDE_BSD
  294. #  define  INCLUDE_BSD
  295. # endif /* INCLUDE_BSD */
  296. # ifndef   INCLUDE_SM_COMMON
  297. #  define  INCLUDE_SM_COMMON
  298. # endif /* INCLUDE_SM_COMMON */
  299. #endif /* INCLUDE_SM_NET */
  300. /* defines */
  301. #define STREQ(A, B) (strcmp(A, B) == 0 ? 1 : 0)
  302. #define TIMEOUT 7 /* number of seconds before auto-boot */
  303. /* maximum line length for cmd input to 'm' and 'mEnet' routine */
  304. #define MAX_LINE        160
  305. /* maximum line length for bootCmdLoop() command line input */
  306. #define BOOT_CMD_MAX_LINE        BOOT_LINE_SIZE
  307. #define RSHD 514 /* rshd service */
  308. #define DEC FALSE /* getArg parameters */
  309. #define HEX TRUE
  310. #define OPT TRUE
  311. #define MAX_ADR_SIZE  6 
  312. #define DOS_ID_OFFSET                   3
  313. #define FIRST_PARTITION_SECTOR_OFFSET   (0x1be + 8)
  314. #define VXDOS                           "VXDOS"
  315. #define VXEXT                           "VXEXT"
  316. #ifdef USE_LEDS_FOR_DEBUG
  317. #define DEBUG_LED(val) IXP1200_REG_WRITE(IXP1200_LED_ADDR, (val))
  318. #else
  319. #define DEBUG_LED(val)
  320. #endif
  321. #ifndef    NUM_PARTITIONS_DISK_BOOT
  322. #   define NUM_PARTITIONS_DISK_BOOT    1 /* one partition on the disk */
  323. #endif  /* NUM_PARTITIONS_DISK_BOOT */
  324. #ifndef    PARTITION_DISK_BOOT
  325. #   define PARTITION_DISK_BOOT         1 /* partition mounted during boot */
  326. #endif  /* PARTITION_DISK_BOOT */
  327. /* DO NOT ADD ANYTHING BEFORE THE FIRST ROUTINE compressedEntry() */
  328. void usrInit ();
  329. IMPORT void  sysInitAlt ();
  330. #if (CPU_FAMILY==MIPS)
  331. IMPORT void  sysGpInit ();
  332. #endif /* (CPU_FAMILY==MIPS) */
  333. #ifdef  INCLUDE_NETWORK
  334. #ifdef ETHERNET_ADR_SET
  335. void mEnet (char *);
  336. void  sysEnetAddrGet ();
  337. void  sysEnetAddrSet ();
  338. #endif  /* ETHERNET_ADR_SET */
  339. #endif  /* INCLUDE_NETWORK */
  340. #ifdef INCLUDE_END
  341. LOCAL void* findCookie(int unitNo, char* devName);
  342. #endif /* INCLUDE_END */
  343. IMPORT STATUS programFlash(UINT8* buf,
  344.                            UINT32 flashStart, UINT32 flashEnd,
  345.                            BOOL skipNVRam, BOOL skipFUtil);
  346. /*******************************************************************************
  347. *
  348. * compressedEntry - compressed entry point after decompression 
  349. *
  350. * This routine is the entry point after the bootroms decompress, if
  351. * compression is utilized.  This routine must be the first item of the
  352. * text segment of this file.  With ANSI C, strings will appear in text
  353. * segment so one should avoid entering strings, routines, or anything
  354. * else that might displace this routine from base of the text segment.
  355. *
  356. * It is unwise to add functionality to this routine without due cause.
  357. * We are in the prehistoric period of system initialization.  
  358. *
  359. * NOMANUAL
  360. */
  361. void compressedEntry 
  362.     (
  363.     int startType
  364.     )
  365.     {
  366. #if (CPU_FAMILY==MIPS)
  367.     WRS_ASM (".extern _gp; la $gp,_gp");
  368. #endif
  369. #if (CPU_FAMILY==I960)
  370.     sysInitAlt (startType); /* jump to the i960 entry point */
  371. #else
  372.     usrInit (startType); /* all others procede below */
  373. #endif
  374.     }
  375. #ifdef INCLUDE_END
  376. #include "end.h"
  377. #include "muxLib.h"
  378. #include "muxTkLib.h"
  379. #include "configNet.h"
  380. #include "m2Lib.h"
  381. IMPORT int  ipAttach ();
  382. IMPORT END_TBL_ENTRY endDevTbl[];
  383. typedef struct cookie_tbl
  384.     {
  385.     int unitNo;
  386.     char devName[END_NAME_MAX];
  387.     void* pCookie;
  388.     }COOKIE_TBL;
  389. COOKIE_TBL cookieTbl[32];
  390. #ifndef MUX_MAX_BINDS
  391. #define MUX_MAX_BINDS 8
  392. #endif
  393. void*   pCookie;
  394. M2_INTERFACETBL endM2Tbl;
  395. #endif  /* INCLUDE_END */
  396. #ifndef IP_MAX_UNITS 
  397. #define IP_MAX_UNITS 1
  398. #endif
  399. IP_DRV_CTRL ipDrvCtrl [IP_MAX_UNITS];
  400. int ipMaxUnits = IP_MAX_UNITS;
  401. /* Wind kernel configuration facility */
  402. #undef INCLUDE_SHOW_ROUTINES /* keep out kernel show routines */
  403. #undef INCLUDE_SM_NET_SHOW
  404. #include "usrKernel.c" /* kernel configuration facility */
  405. /* imports */
  406. IMPORT char edata []; /* defined by the loader */
  407. IMPORT char end []; /* defined by the loader */
  408. #define FREE_MEM_START_ADRS FREE_RAM_ADRS
  409. #ifdef  INCLUDE_INITIAL_MEM_ALLOCATION
  410. #define MEM_POOL_START_ADRS 
  411.     (ROUND_UP(FREE_MEM_START_ADRS, (INITIAL_MEM_ALIGNMENT)) + 
  412.     (INITIAL_MEM_SIZE))
  413. #else   /* INCLUDE_INITIAL_MEM_ALLOCATION */
  414. #define MEM_POOL_START_ADRS FREE_MEM_START_ADRS
  415. #endif  /* INCLUDE_INITIAL_MEM_ALLOCATION */
  416. #ifdef  INCLUDE_TSFS_BOOT /* boot via Target Server File System */
  417. #if ((WDB_COMM_TYPE == WDB_COMM_SERIAL) && 
  418. (CONSOLE_TTY == NONE || CONSOLE_TTY == WDB_TTY_CHANNEL))
  419. #define INCLUDE_TSFS_BOOT_VIO_CONSOLE /* needed for Target Server Console */
  420. #endif
  421. #define INCLUDE_WDB /* WDB agent needed for TSFS Boot */
  422. #define INCLUDE_WDB_TSFS /* target-server file system */
  423. #undef  INCLUDE_WDB_BANNER /* print banner after agent starts */
  424. #undef  INCLUDE_WDB_TTY_TEST /* test serial line communcation */
  425. #undef  INCLUDE_WDB_START_NOTIFY /* notify the host of task creation */
  426. #undef  INCLUDE_WDB_USER_EVENT /* user events handling */
  427. #undef  INCLUDE_WDB_CTXT /* context control */
  428. #undef  INCLUDE_WDB_FUNC_CALL /* spawn function as separate task */
  429. #undef  INCLUDE_WDB_GOPHER /* gopher info gathering */
  430. #undef  INCLUDE_WDB_EXIT_NOTIFY /* notify the host of task exit */
  431. #undef  INCLUDE_WDB_REG /* get/set hardware registers */
  432. #undef  INCLUDE_WDB_EVENTPOINTS /* eventpoints handling */
  433. #undef  INCLUDE_WDB_MEM /* optional memory services */
  434. #undef  INCLUDE_WDB_BP /* breakpoint support */
  435. #include "wdb/wdbEvtLib.h"
  436. #include "../../src/config/usrWdb.c"    /* WDB agent configuration */
  437. #else /* INCLUDE_TSFS_BOOT not defined */
  438. #undef INCLUDE_WDB
  439. #endif  /* INCLUDE_TSFS_BOOT */
  440. #ifdef  INCLUDE_NETWORK
  441. /* forward declarations */
  442. LOCAL STATUS usrNetProtoInit (void);
  443. IMPORT int lnEbsaattach ();
  444. IMPORT int oliattach ();
  445. IMPORT int dcattach ();
  446. IMPORT int eglattach ();
  447. IMPORT int eiattach ();
  448. IMPORT int feiattach ();
  449. IMPORT int exattach ();
  450. IMPORT int enpattach ();
  451. IMPORT int ieattach ();
  452. IMPORT int ilacattach ();
  453. IMPORT int lnattach ();
  454. IMPORT int lnsgiattach ();
  455. IMPORT int nicattach ();
  456. IMPORT int nicEvbattach ();
  457. IMPORT int medattach ();
  458. IMPORT int      elcattach ();
  459. IMPORT int      ultraattach ();
  460. IMPORT int      eexattach ();
  461. IMPORT int      eltattach ();
  462. IMPORT int      eneattach ();
  463. IMPORT int      esmcattach ();
  464. IMPORT int quattach ();
  465. IMPORT int loattach ();
  466. IMPORT int snattach ();
  467. IMPORT int fnattach ();
  468. IMPORT STATUS slipInit ();
  469. IMPORT int ifreset ();
  470. IMPORT void if_dettach ();
  471. IMPORT u_long in_netof ();
  472. IMPORT struct ifnet * ifunit ();
  473. IMPORT int pcmciaattach ();
  474. #ifdef  NETIF_USR_DECL
  475.     NETIF_USR_DECL  /* additional declarations, from BSP */
  476. #endif
  477. #ifdef INCLUDE_IF_USR
  478. IMPORT int IF_USR_ATTACH ();
  479. #endif /* INCLUDE_IF_USR */
  480. LOCAL NETIF netIf [] =
  481.     {
  482. #ifdef  NETIF_USR_ENTRIES
  483.     NETIF_USR_ENTRIES /* additional entries, from BSP */
  484. #endif
  485. #ifdef INCLUDE_IF_USR
  486.         { IF_USR_NAME, IF_USR_ATTACH, IF_USR_ARG1, IF_USR_ARG2, IF_USR_ARG3,
  487.           IF_USR_ARG4, IF_USR_ARG5, IF_USR_ARG6, IF_USR_ARG7, IF_USR_ARG8 },
  488. #endif /* INCLUDE_IF_USR */
  489. #ifdef  INCLUDE_LNEBSA
  490. { "lnEbsa", lnEbsaattach, (char*)IO_ADRS_LNEBSA, INT_VEC_LNEBSA,
  491.   INT_LVL_LNEBSA, LNEBSA_POOL_ADRS, LNEBSA_POOL_SIZE,
  492.   LNEBSA_DATA_WIDTH, LNEBSA_MODE, LNEBSA_DMA_CHAN },
  493. #endif  /* INCLUDE_LNEBSA */
  494. #ifdef  INCLUDE_OLI
  495. { "oli", oliattach, (char*)IO_ADRS_NISA_BASE,
  496.   IO_ADRS_NISA_PCMCIA, IO_ADRS_NISA_PCMEM,
  497.   INT_VEC_PCMCIA_A, INT_LVL_PCMCIA_A,
  498.   INT_VEC_PCMCIA_B, INT_LVL_PCMCIA_B },
  499. #endif
  500. #ifdef INCLUDE_DC
  501. { "dc", dcattach, (char*)IO_ADRS_DC, INT_VEC_DC, INT_LVL_DC,
  502.   DC_POOL_ADRS, DC_POOL_SIZE, DC_DATA_WIDTH, DC_RAM_PCI_ADRS,
  503.   DC_MODE },
  504. #endif /* INCLUDE_DC */
  505. #ifdef INCLUDE_EGL
  506. { "egl", eglattach, (char*)IO_ADRS_EGL, INT_VEC_EGL, INT_LVL_EGL },
  507. #endif /* INCLUDE_EGL */
  508. #ifdef INCLUDE_EI
  509.         { "ei", eiattach, (char*)INT_VEC_EI, EI_SYSBUS, EI_POOL_ADRS, 0, 0},
  510. #endif /* INCLUDE_EI */
  511. #ifdef INCLUDE_FEI
  512.         { "fei", feiattach, (char*)FEI_POOL_ADRS, 0, 0, 0, 0},
  513. #endif /* INCLUDE_FEI */
  514. #ifdef  INCLUDE_EX
  515.         { "ex", exattach, (char*)IO_ADRS_EX, INT_VEC_EX, INT_LVL_EX,
  516.   IO_AM_EX_MASTER, IO_AM_EX },
  517. #endif /* INCLUDE_EX */
  518. #ifdef  INCLUDE_ENP
  519.         { "enp", enpattach, (char*)IO_ADRS_ENP, INT_VEC_ENP, INT_LVL_ENP,
  520.   IO_AM_ENP },
  521. #endif /* INCLUDE_ENP */
  522. #ifdef  INCLUDE_IE
  523.         { "ie", ieattach, (char*)IO_ADRS_IE, INT_VEC_IE, INT_LVL_IE },
  524. #endif /* INCLUDE_IE */
  525. #ifdef INCLUDE_ILAC
  526. { "ilac", ilacattach, (char*)IO_ADRS_ILAC, INT_VEC_ILAC},
  527. #endif /* INCLUDE_ILAC */
  528. #ifdef  INCLUDE_LN
  529.         { "ln", lnattach, (char*)IO_ADRS_LN, INT_VEC_LN, INT_LVL_LN,
  530.           LN_POOL_ADRS, LN_POOL_SIZE, LN_DATA_WIDTH, LN_PADDING,
  531.   LN_RING_BUF_SIZE },
  532. #endif /* INCLUDE_LN */
  533. #ifdef  INCLUDE_LNSGI
  534.         { "lnsgi", lnsgiattach, (char*)IO_ADRS_LNSGI, INT_VEC_LNSGI,
  535.           INT_LVL_LNSGI, LNSGI_POOL_ADRS, LNSGI_POOL_SIZE, LNSGI_DATA_WIDTH,
  536.           LNSGI_PADDING, LNSGI_RING_BUF_SIZE },
  537. #endif  /* INCLUDE_LNSGI */
  538. #ifdef  INCLUDE_NIC
  539.         { "nic", nicattach, (char*)IO_ADRS_NIC, INT_VEC_NIC, INT_LVL_NIC },
  540. #endif /* INCLUDE_NIC */
  541. #ifdef  INCLUDE_NIC_EVB
  542.         { "nicEvb", nicEvbattach, (char*)IO_ADRS_NIC,INT_VEC_NIC,INT_LVL_NIC },
  543. #endif /* INCLUDE_NIC_EVB */
  544. #ifdef  INCLUDE_MED
  545.         { "med", medattach, (char*)IO_ADRS_DBETH, INT_VEC_DBETH, INT_LVL_DBETH},
  546. #endif /* INCLUDE_MED */
  547. #ifdef  INCLUDE_ELC
  548. { "elc", elcattach, (char*)IO_ADRS_ELC, INT_VEC_ELC, INT_LVL_ELC,
  549.   MEM_ADRS_ELC, MEM_SIZE_ELC, CONFIG_ELC},
  550. #endif  /* INCLUDE_ELC */
  551. #ifdef  INCLUDE_ULTRA
  552. { "ultra", ultraattach, (char*)IO_ADRS_ULTRA, INT_VEC_ULTRA,
  553.   INT_LVL_ULTRA, MEM_ADRS_ULTRA, MEM_SIZE_ULTRA, CONFIG_ULTRA},
  554. #endif  /* INCLUDE_ULTRA */
  555. #ifdef  INCLUDE_EEX
  556. { "eex", eexattach, (char*)IO_ADRS_EEX, INT_VEC_EEX, INT_LVL_EEX,
  557.   NTFDS_EEX, CONFIG_EEX},
  558. #endif  /* INCLUDE_EEX */
  559. #ifdef  INCLUDE_ELT
  560. { "elt", eltattach, (char*)IO_ADRS_ELT, INT_VEC_ELT, INT_LVL_ELT,
  561.   NRF_ELT, CONFIG_ELT},
  562. #endif  /* INCLUDE_ELT */
  563. #ifdef  INCLUDE_ENE
  564. { "ene", eneattach, (char*)IO_ADRS_ENE, INT_VEC_ENE, INT_LVL_ENE},
  565. #endif  /* INCLUDE_ELT */
  566. #ifdef  INCLUDE_ESMC
  567. { "esmc", esmcattach, (char*)IO_ADRS_ESMC, INT_VEC_ESMC, INT_LVL_ESMC,
  568.   CONFIG_ESMC, RX_MODE_ESMC},
  569. #endif  /* INCLUDE_ESMC */
  570. #ifdef  INCLUDE_QU
  571. { "qu", quattach, (char*)IO_ADRS_QU_EN, INT_VEC_QU_EN, QU_EN_SCC,
  572.           QU_EN_TX_BD, QU_EN_RX_BD, QU_EN_TX_OFF, QU_EN_RX_OFF, QU_EN_MEM},
  573. #endif  /* INCLUDE_QU */
  574. #ifdef  INCLUDE_SN
  575.         { "sn", snattach, (char*)IO_ADRS_SN, INT_VEC_SN },
  576. #endif /* INCLUDE_SN */
  577. #ifdef  INCLUDE_FN
  578.         { "fn", fnattach },
  579. #endif  /* INCLUDE_FN */
  580. #ifdef  INCLUDE_SM_NET
  581.         { "sm", smNetAttach2, 0, 0, 0, 0, 0, 0, 0, 0 },
  582. #endif  /* INCLUDE_SM_NET */
  583. #ifdef INCLUDE_PCMCIA
  584. { "pcmcia", pcmciaattach, 0, 0, 0, 0, 0, 0 },
  585. #endif /* INCLUDE_PCMCIA */
  586. #ifdef  INCLUDE_PPP
  587. {"ppp", 0, 0, 0, 0, 0},
  588. #endif  /* INCLUDE_PPP */
  589. #ifdef  INCLUDE_SLIP
  590. { "sl", 0, 0, 0, 0, 0 },
  591. #endif /* INCLUDE_SLIP */
  592. { "lo", loattach, 0, 0, 0, 0 },
  593.         { 0, 0, 0, 0, 0, 0 },
  594.     };
  595. #endif  /* INCLUDE_NETWORK */
  596. /* global variables */
  597. SYMTAB_ID sysSymTbl;
  598. int consoleFd; /* fd of initial console device */
  599. char consoleName [20]; /* console device name, eg. "/tyCo/0" */
  600. int sysStartType; /* BOOT_CLEAR, BOOT_NO_AUTOBOOT, ... */
  601. BOOL scsiInitialized      = FALSE;
  602. int bootCmdTaskPriority  = 1;
  603. int bootCmdTaskOptions   = VX_SUPERVISOR_MODE;
  604. int bootCmdTaskStackSize = BOOT_CMD_STACK_SIZE;
  605. /* Two magic cookies used to detect data section misalignment */
  606. #define TRAP_VALUE_1 0x12348765
  607. #define TRAP_VALUE_2 0x5a5ac3c3
  608. LOCAL volatile UINT32 trapValue1 = TRAP_VALUE_1;
  609. LOCAL volatile UINT32 trapValue2 = TRAP_VALUE_2;
  610. #ifdef  INCLUDE_NETWORK
  611. /* network protocol configuration parameters */
  612. #ifdef INCLUDE_TCP
  613. TCP_CFG_PARAMS tcpCfgParams =   /* tcp configuration parameters */
  614.     {
  615.     TCP_FLAGS_DFLT,             /* include rfc1323 support */
  616.     TCP_SND_SIZE_DFLT,          /* default send buffer size */
  617.     TCP_RCV_SIZE_DFLT,          /* default recv buffer size */
  618.     TCP_CON_TIMEO_DFLT,         /* initial connection time out */
  619.     TCP_REXMT_THLD_DFLT,        /* retransmit threshold */
  620.     TCP_MSS_DFLT,               /* default maximum segment size */
  621.     TCP_RND_TRIP_DFLT,          /* default round trip time */
  622.     TCP_IDLE_TIMEO_DFLT,        /* idle timeouts before first probe */
  623.     TCP_MAX_PROBE_DFLT          /* max no. probes before dropping */
  624.     };
  625. #endif /* INCLUDE_TCP */
  626. #ifdef INCLUDE_UDP
  627. UDP_CFG_PARAMS udpCfgParams =   /* udp configuration parameters */
  628.     {
  629.     UDP_FLAGS_DFLT,
  630.     UDP_SND_SIZE_DFLT,          /* send buffer size */
  631.     UDP_RCV_SIZE_DFLT           /* recv buffer size */
  632.     };
  633. #endif /* INCLUDE_UDP */
  634. #ifdef INCLUDE_ICMP
  635. ICMP_CFG_PARAMS icmpCfgParams = /* icmp configuration parameters */
  636.     {
  637.     ICMP_FLAGS_DFLT             /* no icmp mask replies by default */
  638.     };
  639. #endif  /* INCLUDE_ICMP */
  640. IP_CFG_PARAMS ipCfgParams =     /* ip configuration parameters */
  641.     {
  642.     IP_FLAGS_DFLT,              /* default ip flags */
  643.     IP_TTL_DFLT,                /* ip default time to live */
  644.     IP_QLEN_DFLT,               /* default ip intr queue len */
  645.     IP_FRAG_TTL_DFLT            /* default ip fragment time to live */
  646.     };
  647. /* network buffers configuration */
  648. /*
  649.  * mBlk, clBlk configuration table for network stack data pool.
  650.  * Only used for data transfer in the network stack.
  651.  */
  652. M_CL_CONFIG mClBlkConfig =
  653.     {
  654.     /* 
  655.     no. mBlks no. clBlks memArea memSize
  656.     ----------- ---------- ------- -------
  657.     */
  658.     NUM_NET_MBLKS_MIN,  NUM_CL_BLKS_MIN, NULL,  0
  659.     };
  660. /*
  661.  * network stack data cluster pool configuration table
  662.  * Only used for data transfer in the network stack.
  663.  */
  664. CL_DESC clDescTbl [] =
  665.     {
  666.     /*
  667.     clusterSize     num              memArea         memSize
  668.     -----------     ----             -------         -------
  669.     */
  670.     {64,            NUM_64_MIN, NULL,           0},
  671.     {128,           NUM_128_MIN,        NULL,           0},
  672.     {256,           NUM_256_MIN,        NULL,           0},
  673.     {512,           NUM_512_MIN,        NULL,           0},
  674.     {1024,          NUM_1024_MIN,       NULL,           0},
  675.     };
  676. int clDescTblNumEnt = (NELEMENTS(clDescTbl));
  677. /*
  678.  * mBlk, clBlk configuration table for network stack system pool.
  679.  * Used for network stack system structures such as routes, sockets,
  680.  * protocol control blocks, interface addresses, mulitcast addresses,
  681.  * and multicast routing entries.
  682.  */
  683. M_CL_CONFIG sysMclBlkConfig = 
  684.     {
  685.     /* 
  686.     no. mBlks no. clBlks memArea memSize
  687.     ----------- ---------- ------- -------
  688.     */
  689.     NUM_SYS_MBLKS_MIN,  NUM_SYS_CL_BLKS_MIN, NULL,  0
  690.     };
  691. /*
  692.  * network stack system cluster pool configuration table
  693.  * Used for network stack system structures such as routes, sockets,
  694.  * protocol control blocks, interface addresses, mulitcast addresses,
  695.  * and multicast routing entries.
  696.  */
  697. CL_DESC sysClDescTbl [] = 
  698.     {
  699.     /* 
  700.     clusterSize num memArea memSize
  701.     ----------- ---- ------- -------
  702.     */
  703.     {64, NUM_SYS_64_MIN, NULL, 0},
  704.     {128, NUM_SYS_128_MIN, NULL, 0},
  705.     {256, NUM_SYS_256_MIN, NULL, 0},
  706.     {512, NUM_SYS_512_MIN, NULL, 0},
  707.     }; 
  708. int sysClDescTblNumEnt = (NELEMENTS(sysClDescTbl));
  709. #ifdef  INCLUDE_PPP
  710. #ifndef PPP_OPTIONS_FLAGS
  711. #define PPP_OPTIONS_FLAGS ((PPP_OPT_NO_ALL << PPP_S_NO_ALL)  | 
  712.     (PPP_OPT_PASSIVE_MODE << PPP_S_PASSIVE_MODE)             | 
  713.     (PPP_OPT_SILENT_MODE << PPP_S_SILENT_MODE)               | 
  714.     (PPP_OPT_DEFAULTROUTE << PPP_S_DEFAULTROUTE)             | 
  715.     (PPP_OPT_PROXYARP << PPP_S_PROXYARP)                     | 
  716.     (PPP_OPT_IPCP_ACCEPT_LOCAL << PPP_S_IPCP_ACCEPT_LOCAL)   | 
  717.     (PPP_OPT_IPCP_ACCEPT_REMOTE << PPP_S_IPCP_ACCEPT_REMOTE) | 
  718.     (PPP_OPT_NO_IP << PPP_S_NO_IP)                           | 
  719.     (PPP_OPT_NO_ACC << PPP_S_NO_ACC)                         | 
  720.     (PPP_OPT_NO_PC << PPP_S_NO_PC)                           | 
  721.     (PPP_OPT_NO_VJ << PPP_S_NO_VJ)                           | 
  722.     (PPP_OPT_NO_VJCCOMP << PPP_S_NO_VJCCOMP)                 | 
  723.     (PPP_OPT_NO_ASYNCMAP << PPP_S_NO_ASYNCMAP)               | 
  724.     (PPP_OPT_NO_MN << PPP_S_NO_MN)                           | 
  725.     (PPP_OPT_NO_MRU << PPP_S_NO_MRU)                         | 
  726.     (PPP_OPT_NO_PAP << PPP_S_NO_PAP)                         | 
  727.     (PPP_OPT_NO_CHAP << PPP_S_NO_CHAP)                       | 
  728.     (PPP_OPT_REQUIRE_PAP << PPP_S_REQUIRE_PAP)               | 
  729.     (PPP_OPT_REQUIRE_CHAP << PPP_S_REQUIRE_CHAP)             | 
  730.     (PPP_OPT_LOGIN << PPP_S_LOGIN)                           | 
  731.     (PPP_OPT_DEBUG << PPP_S_DEBUG)                           | 
  732.     (PPP_OPT_DRIVER_DEBUG << PPP_S_DRIVER_DEBUG))
  733. #endif  /* PPP_OPTIONS_FLAGS */
  734.  
  735. PPP_OPTIONS pppOptions =
  736.     {
  737.     PPP_OPTIONS_FLAGS, /* flags field */
  738.     PPP_STR_ASYNCMAP, /* Set the desired async map */
  739.     PPP_STR_ESCAPE_CHARS, /* Set chars to escape on transmission */
  740.     PPP_STR_VJ_MAX_SLOTS, /* Set maximum VJ compression header slots */
  741.     PPP_STR_NETMASK, /* Set netmask value for negotiation */
  742.     PPP_STR_MRU, /* Set MRU value for negotiation */
  743.     PPP_STR_MTU, /* Set MTU value for negotiation */
  744.     PPP_STR_LCP_ECHO_FAILURE, /* Set max # consecutive LCP echo failures */
  745.     PPP_STR_LCP_ECHO_INTERVAL, /* Set time for LCP echo requests */
  746.     PPP_STR_LCP_RESTART, /* Set timeout for LCP */
  747.     PPP_STR_LCP_MAX_TERMINATE, /* Set max # xmits for LCP term-reqs */
  748.     PPP_STR_LCP_MAX_CONFIGURE, /* Set max # xmits for LCP conf-reqs */
  749.     PPP_STR_LCP_MAX_FAILURE, /* Set max # conf-naks for LCP */
  750.     PPP_STR_IPCP_RESTART, /* Set timeout for IPCP */
  751.     PPP_STR_IPCP_MAX_TERMINATE, /* Set max # xmits for IPCP term-reqs */
  752.     PPP_STR_IPCP_MAX_CONFIGURE, /* Set max # xmits for IPCP conf-reqs */
  753.     PPP_STR_IPCP_MAX_FAILURE, /* Set max # conf-naks for IPCP */
  754.     PPP_STR_LOCAL_AUTH_NAME, /* Set local name for authentication */
  755.     PPP_STR_REMOTE_AUTH_NAME, /* Set remote name for authentication */
  756.     PPP_STR_PAP_FILE, /* Set the PAP secrets file */
  757.     PPP_STR_PAP_USER_NAME, /* Set username for PAP auth with peer */
  758.     PPP_STR_PAP_PASSWD, /* Set password for PAP auth with peer */
  759.     PPP_STR_PAP_RESTART, /* Set timeout for PAP */
  760.     PPP_STR_PAP_MAX_AUTHREQ, /* Set max # xmits for PAP auth-reqs */
  761.     PPP_STR_CHAP_FILE, /* Set the CHAP secrets file */
  762.     PPP_STR_CHAP_RESTART, /* Set timeout for CHAP */
  763.     PPP_STR_CHAP_INTERVAL, /* Set interval for CHAP rechallenge */
  764.     PPP_STR_CHAP_MAX_CHALLENGE /* Set max # xmits for CHAP challenge */
  765.     };
  766.  
  767. #endif  /* INCLUDE_PPP */
  768. #endif  /* INCLUDE_NETWORK */
  769. /* forward declarations */
  770. #ifdef __STDC__
  771. void  usrRoot (char *pMemPoolStart, unsigned memPoolSize);
  772. void  usrClock (void);
  773. void usrKernelInit (void);
  774. LOCAL void bootCmdLoop (void);
  775. LOCAL char autoboot (int timeout);
  776. LOCAL void printBootLogo (void);
  777. LOCAL void bootHelp (void);
  778. LOCAL STATUS bootLoad (char *bootString, FUNCPTR *pEntry);
  779. LOCAL STATUS ImageLoad(char * bootString, char * pEntry, UINT32 * imageSize);
  780. LOCAL void go (FUNCPTR entry);
  781. LOCAL void m (char *adrs);
  782. LOCAL void d (char *adrs, int nwords);
  783. LOCAL void bootExcHandler (int tid);
  784. LOCAL void skipSpace (char **strptr);
  785. LOCAL void printExcMsg (char *string);
  786. LOCAL STATUS getArg (char **ppString, int *pValue, BOOL defaultHex,
  787. BOOL optional);
  788. LOCAL void usrBootLineInit (int startType);
  789. LOCAL STATUS usrBootLineCrack (char *bootString, BOOT_PARAMS *pParams);
  790. #ifdef  INCLUDE_NETWORK
  791. LOCAL STATUS netLoad (char *hostName, char *fileName, char *usr, 
  792.  char *passwd, FUNCPTR *pEntry);
  793. LOCAL STATUS netGetFile(char * hostName, char * fileName, char * usr, 
  794.                char * passwd, char * pEntry, UINT32 * imageSize);
  795. LOCAL void netifAdrsPrint (char *ifname);
  796. LOCAL STATUS checkInetAddrField (char *pInetAddr, BOOL subnetMaskOK);
  797. LOCAL STATUS usrNetIfAttach (char *devName, int unitNum, char *inetAdrs);
  798. LOCAL STATUS usrNetIfConfig (char *devName, int unitNum, char *inetAdrs, 
  799.                                 char *inetName, int netmask);
  800. LOCAL STATUS usrBpInit (char *devName, int unitNum, u_long startAddr);
  801. LOCAL STATUS usrSlipInit (char *pBootDev, int unitNum, char *localAddr, 
  802.      char *peerAddr);
  803. LOCAL STATUS    usrPPPInit (char *pBootDev, int unitNum, char *localAddr, 
  804.                             char *peerAddr);
  805. LOCAL STATUS bootpGet (char *pNetDev, char *pBootDevAddr, char *pBootFile,
  806.   char *pHostAddr, int *pMask);
  807. #ifdef INCLUDE_DHCPC
  808. LOCAL STATUS  dhcpGet (char *pNetDev, char *pBootDevAddr, char *pBootFile,
  809.                          char *pHostAddr, int  *pMask,
  810.                          DHCP_LEASE_DATA *pDhcpLease);
  811. #endif
  812. #endif  /* INCLUDE_NETWORK */
  813. #ifdef INCLUDE_SCSI_BOOT
  814. LOCAL STATUS scsiLoad (int bootDevId, int bootDevLUN, char *fileName,
  815.           FUNCPTR *pEntry);
  816. #endif /* INCLUDE_SCSI_BOOT */
  817. #ifdef  INCLUDE_FD
  818. LOCAL STATUS    fdLoad (int drive, int type, char *fileName, FUNCPTR *pEntry);
  819. #endif  /* INCLUDE_FD */
  820. #ifdef  INCLUDE_IDE
  821. LOCAL STATUS    ideLoad (int drive, int type, char *fileName, FUNCPTR *pEntry);
  822. #endif  /* INCLUDE_IDE */
  823. #ifdef INCLUDE_ATA
  824. LOCAL STATUS ataLoad (int ctrl, int drive, char *fileName, FUNCPTR *pEntry);
  825. #endif /* INCLUDE_ATA */
  826. #ifdef INCLUDE_PCMCIA
  827. LOCAL STATUS pcmciaLoad (int sock, char *fileName, FUNCPTR *pEntry);
  828. #endif /* INCLUDE_PCMCIA */
  829. #ifdef INCLUDE_TFFS
  830. LOCAL STATUS    tffsLoad (int drive, int removable, char *fileName, 
  831.   FUNCPTR *pEntry);
  832. #endif /* INCLUDE_TFFS */
  833. #ifdef INCLUDE_TSFS_BOOT
  834. LOCAL STATUS tsfsLoad (char * fileName, FUNCPTR * pEntry);
  835. LOCAL void wdbRebootEventGet (void * pNode, WDB_EVT_DATA * pEvtData);
  836. #endif /* INCLUDE_TSFS_BOOT */
  837. #else
  838. void usrRoot ();
  839. void usrClock ();
  840. void usrKernelInit ();
  841. LOCAL void bootCmdLoop ();
  842. LOCAL char autoboot ();
  843. LOCAL void printBootLogo ();
  844. LOCAL void bootHelp ();
  845. LOCAL STATUS bootLoad ();
  846. LOCAL STATUS ImageLoad();
  847. LOCAL void go ();
  848. LOCAL void m ();
  849. LOCAL void d ();
  850. LOCAL void bootExcHandler ();
  851. LOCAL void skipSpace ();
  852. LOCAL void printExcMsg ();
  853. LOCAL STATUS getArg ();
  854. LOCAL void usrBootLineInit ();
  855. LOCAL STATUS usrBootLineCrack ();
  856. #ifdef  INCLUDE_NETWORK
  857. LOCAL STATUS netLoad ();
  858. LOCAL STATUS netGetFile();
  859. LOCAL void netifAdrsPrint ();
  860. LOCAL STATUS checkInetAddrField ();
  861. LOCAL STATUS usrNetIfAttach ();
  862. LOCAL STATUS usrNetIfConfig ();
  863. LOCAL STATUS usrBpInit ();
  864. LOCAL STATUS usrSlipInit ();
  865. LOCAL STATUS usrPPPInit ();
  866. LOCAL STATUS bootpGet ();
  867. #endif  /* INCLUDE_NETWORK */
  868. #ifdef INCLUDE_SCSI_BOOT
  869. LOCAL STATUS scsiLoad();
  870. #endif /* INCLUDE_SCSI_BOOT */
  871. #ifdef  INCLUDE_FD
  872. LOCAL STATUS    fdLoad ();
  873. #endif  /* INCLUDE_FD */
  874. #ifdef  INCLUDE_IDE
  875. LOCAL STATUS    ideLoad ();
  876. #endif  /* INCLUDE_IDE */
  877. #ifdef INCLUDE_ATA
  878. LOCAL STATUS ataLoad ();
  879. #endif /* INCLUDE_ATA */
  880. #ifdef INCLUDE_PCMCIA
  881. LOCAL STATUS pcmciaLoad ();
  882. #endif /* INCLUDE_PCMCIA */
  883. #ifdef INCLUDE_TFFS
  884. LOCAL STATUS    tffsLoad ();
  885. #endif /* INCLUDE_TFFS */
  886. #ifdef INCLUDE_TSFS_BOOT
  887. LOCAL STATUS tsfsLoad ();
  888. LOCAL void wdbRebootEventGet ();
  889. #endif /* INCLUDE_TSFS_BOOT */
  890. #endif /* __STDC__ */
  891. /*******************************************************************************
  892. *
  893. * usrInit - user-defined system initialization routine
  894. *
  895. * This routine is called by the start-up code in romStart().  It is called
  896. * before kernel multi-tasking is enabled, with the interrupts locked out.
  897. *
  898. * It starts by clearing BSS, so all variables are initialized to 0 as per
  899. * the C specification.  Then it sets up exception vectors, initializes the
  900. * hardware by calling sysHwInit(), and finally starts the kernel with the
  901. * usrRoot() task to do the remainder of the initialization.
  902. *
  903. * NOMANUAL
  904. */
  905. void usrInit 
  906.     (
  907.     int startType
  908.     )
  909.     {
  910.     /*
  911.      * This trap will catch improper loading of the data section.
  912.      * We check the magic cookie values to make sure the data section is
  913.      * in the expected memory location. We do not want
  914.      * to proceed further if the data segment is not correct.
  915.      *
  916.      * It should be easy to detect entry into the trap using an ICE, JTAG,
  917.      * or logic analyzer. Without the trap, the processor is likely to run
  918.      * away out of control.
  919.      *
  920.      * Data section misalignment can occur when there is a change in tool
  921.      * chain, build rules, compiler, host utilites,  etc. 
  922.      */
  923.     while (trapValue1 != TRAP_VALUE_1 || trapValue2 != TRAP_VALUE_2)
  924. {
  925. /* infinite loop */;
  926. }
  927.     
  928. #if (CPU_FAMILY == SPARC)
  929.     excWindowInit (); /* SPARC window management */
  930. #endif
  931. #if (CPU_FAMILY == MIPS)
  932.     sysGpInit (); /* MIPS global pointer */
  933. #endif /* (CPU_FAMILY == MIPS) */
  934. #ifdef INCLUDE_SYS_HW_INIT_0
  935.     /*
  936.      * Perform any BSP-specific initialisation that must be done before
  937.      * cacheLibInit() is called and/or BSS is cleared.
  938.      */
  939.     SYS_HW_INIT_0 ();
  940.     CLED(0x1);
  941. #endif /* INCLUDE_SYS_HW_INIT_0 */
  942.     /* configure data and instruction cache if available and leave disabled */
  943. #ifdef INCLUDE_CACHE_SUPPORT
  944.     /*
  945.      * SPR 73609:  If a cache is not to be enabled, don't require
  946.      * its mode to be defined.  Instead, default it to disabled.
  947.      */
  948. # if (!defined(USER_D_CACHE_ENABLE) && !defined(USER_D_CACHE_MODE))
  949. #  define USER_D_CACHE_MODE CACHE_DISABLED
  950. # endif /* !USER_D_CACHE_ENABLE && !USER_D_CACHE_MODE */
  951. # if (!defined(USER_I_CACHE_ENABLE) && !defined(USER_I_CACHE_MODE))
  952. #  define USER_I_CACHE_MODE CACHE_DISABLED
  953. # endif /* !USER_I_CACHE_ENABLE && !USER_I_CACHE_MODE */
  954.     cacheLibInit (USER_I_CACHE_MODE, USER_D_CACHE_MODE);
  955. #endif /* INCLUDE_CACHE_SUPPORT */
  956. #if (CPU == SPARClite)
  957.     cacheLib.textUpdateRtn = NULL; /* XXX - mod hist 07u */
  958. #endif
  959.     /* don't assume bss variables are zero before this call */
  960.     bzero (edata, end - edata); /* zero out bss variables */
  961.     sysStartType = startType;
  962.     intVecBaseSet ((FUNCPTR *) VEC_BASE_ADRS); /* set vector base table */
  963. #if (CPU_FAMILY == AM29XXX)
  964.     excSpillFillInit ();                        /* am29k stack cache managemt */
  965. #endif
  966.     excVecInit (); /* install exception vectors */
  967.     sysHwInit (); /* initialize system hardware */
  968.     CLED(0x2);
  969.     usrKernelInit (); /* configure the Wind kernel */
  970. #if (CPU==SPARC) || (CPU_FAMILY==I80X86) /* XXX workaround for sun1e */
  971. #undef USER_I_CACHE_ENABLE /* XXX disable instruction cache */
  972. #endif /* (CPU==SPARC) || (CPU_FAMILY==I80X86) */
  973. #ifdef INCLUDE_CACHE_SUPPORT
  974. #ifdef  USER_I_CACHE_ENABLE
  975.     cacheEnable (INSTRUCTION_CACHE); /* enable instruction cache */
  976. #endif /* USER_I_CACHE_ENABLE */
  977. #endif /* INCLUDE_CACHE_SUPPORT */
  978.     /* start the kernel specifying usrRoot as the root task */
  979.     CLED(0x3);
  980.     kernelInit ((FUNCPTR) usrRoot, ROOT_STACK_SIZE,
  981. (char *) MEM_POOL_START_ADRS,
  982. sysMemTop (), ISR_STACK_SIZE, INT_LOCK_LEVEL);
  983.     }
  984. /*******************************************************************************
  985. *
  986. * usrRoot - user-defined root task
  987. *
  988. * The root task performs any initialization that should be done
  989. * subsequent to the kernel initialization.
  990. *
  991. * It initializes the I/O system, install drivers, create devices,
  992. * sets up the network, etc., as necessary for the particular configuration.
  993. * It may also create the system symbol table if one is to be included.
  994. * Finally, it spawns the boot command loop task.
  995. *
  996. * NOMANUAL
  997. */
  998. void usrRoot
  999.     (
  1000.     char *      pMemPoolStart,          /* start of system memory partition */
  1001.     unsigned    memPoolSize             /* initial size of mem pool */
  1002.     )
  1003.     {
  1004.     char tyName [20];
  1005.     int ix;
  1006. #ifdef INCLUDE_END
  1007.     int count;
  1008.     END_TBL_ENTRY* pDevTbl;
  1009. #endif /* INCLUDE_END */
  1010.     /* Initialize the memory pool before initializing any other package.
  1011.      * The memory associated with the root task will be reclaimed at the
  1012.      * completion of its activities.                                 
  1013.      */
  1014.     CLED(0x4);
  1015.     memInit (pMemPoolStart, memPoolSize);/* XXX select between memPartLibInit */
  1016.     /* set up system timer */
  1017.     
  1018.     sysClkConnect ((FUNCPTR) usrClock, 0);/* connect clock interrupt routine */
  1019.     sysClkRateSet (SYS_CLK_RATE);    /* set system clock rate */
  1020.     sysClkEnable ();   /* start it */
  1021.     /*
  1022.      * The select library needs to be initialized before the tyLib module
  1023.      * since the _func_selWakeupListInit FUNCPTR is required (SPR #3314).
  1024.      * The installation of the select task delete hook is not performed
  1025.      * for boot ROMs.
  1026.      */
  1027. #ifdef INCLUDE_SELECT
  1028.     selectInit (NUM_FILES);
  1029. #endif  /* INCLUDE_SELECT */
  1030.     /* initialize I/O and file system */
  1031.     iosInit (NUM_DRIVERS, NUM_FILES, "/null");
  1032.     consoleFd = NONE;
  1033.     /* install driver for on-board serial ports and make devices */
  1034. #ifdef  INCLUDE_TYCODRV_5_2
  1035. #ifdef  INCLUDE_TTY_DEV
  1036.     if (NUM_TTY > 0)
  1037.         {
  1038.         tyCoDrv ();                             /* install console driver */
  1039.         for (ix = 0; ix < NUM_TTY; ix++)        /* create serial devices */
  1040.             {
  1041.             sprintf (tyName, "%s%d", "/tyCo/", ix);
  1042.             (void) tyCoDevCreate (tyName, ix, 512, 512);
  1043.             if (ix == CONSOLE_TTY)
  1044.                 strcpy (consoleName, tyName);   /* store console name */
  1045.             }
  1046.         consoleFd = open (consoleName, O_RDWR, 0);
  1047.         /* set baud rate */
  1048.         (void) ioctl (consoleFd, FIOBAUDRATE, CONSOLE_BAUD_RATE);
  1049.         (void) ioctl (consoleFd, FIOSETOPTIONS,
  1050. OPT_ECHO | OPT_CRMOD | OPT_TANDEM | OPT_7_BIT);
  1051.         }
  1052. #endif  /* INCLUDE_TTY_DEV */
  1053. #else   /* !INCLUDE_TYCODRV_5_2 */
  1054. #ifdef  INCLUDE_TTY_DEV
  1055.     if (NUM_TTY > 0)
  1056.         {
  1057.         ttyDrv();                               /* install console driver */
  1058.         for (ix = 0; ix < NUM_TTY; ix++)        /* create serial devices */
  1059.             {
  1060. #if (defined(INCLUDE_WDB) && (WDB_COMM_TYPE == WDB_COMM_SERIAL))
  1061.     if (ix == WDB_TTY_CHANNEL)          /* don't use WDBs channel */
  1062.      continue;
  1063. #endif
  1064.             sprintf (tyName, "%s%d", "/tyCo/", ix);
  1065.             (void) ttyDevCreate (tyName, sysSerialChanGet(ix), 512, 512);
  1066.             if (ix == CONSOLE_TTY)              /* init the tty console */
  1067.                 {
  1068.                 strcpy (consoleName, tyName);
  1069.                 consoleFd = open (consoleName, O_RDWR, 0);
  1070.                 (void) ioctl (consoleFd, FIOBAUDRATE, CONSOLE_BAUD_RATE);
  1071.                 (void) ioctl (consoleFd, FIOSETOPTIONS,
  1072. OPT_ECHO | OPT_CRMOD | OPT_TANDEM | OPT_7_BIT);
  1073.                 }
  1074.             }
  1075.         }
  1076. #endif  /* INCLUDE_TTY_DEV */
  1077. #ifdef INCLUDE_PC_CONSOLE
  1078.     pcConDrv ();
  1079.     for (ix = 0; ix < N_VIRTUAL_CONSOLES; ix++)
  1080.         {
  1081.         sprintf (tyName, "%s%d", "/pcConsole/", ix);
  1082.         (void) pcConDevCreate (tyName,ix, 512, 512);
  1083.         if (ix == PC_CONSOLE)           /* init the console device */
  1084.             {
  1085.             strcpy (consoleName, tyName);
  1086.             consoleFd = open (consoleName, O_RDWR, 0);
  1087.             (void) ioctl (consoleFd, FIOBAUDRATE, CONSOLE_BAUD_RATE);
  1088.             (void) ioctl (consoleFd, FIOSETOPTIONS,
  1089. OPT_ECHO | OPT_CRMOD | OPT_TANDEM | OPT_7_BIT);
  1090.             }
  1091.         }
  1092. #endif  /* INCLUDE_PC_CONSOLE */
  1093. #endif  /* !INCLUDE_TYCODRV_5_2 */
  1094. #ifdef INCLUDE_WDB
  1095.     wdbConfig(); /* configure and initialize the WDB agent */
  1096.     vxBootFile[0] = NULL; /* clear boot line set by wdbConfig() */
  1097. #if defined(INCLUDE_TSFS_BOOT) && defined(INCLUDE_TSFS_BOOT_VIO_CONSOLE)
  1098.     consoleFd = open ("/vio/0", O_RDWR, 0); /* for Target Server Console */
  1099. #endif
  1100. #endif /* INCLUDE_WDB */
  1101.     ioGlobalStdSet (STD_IN,  consoleFd);
  1102.     ioGlobalStdSet (STD_OUT, consoleFd);
  1103.     ioGlobalStdSet (STD_ERR, consoleFd);
  1104.     pipeDrv (); /* install pipe driver */
  1105. #if     defined(INCLUDE_EXC_HANDLING) && defined(INCLUDE_EXC_TASK)
  1106. #ifdef  INCLUDE_EXC_SHOW
  1107.     excShowInit (); /* init exception show routines */
  1108. #endif
  1109.     excInit (); /* initialize exception handling */
  1110. #endif  /* defined(INCLUDE_EXC_HANDLING) && defined(INCLUDE_EXC_TASK) */
  1111.     excHookAdd ((FUNCPTR) bootExcHandler); /* install exc handler */
  1112.     logInit (consoleFd, 5); /* initialize logging */
  1113. #ifdef INCLUDE_DOSFS
  1114.     hashLibInit (); /* hashLib used by dosFS */
  1115. #endif
  1116.     /* initialize object module loader */
  1117. #if defined(INCLUDE_AOUT)
  1118.     bootAoutInit (); /* use a.out format */
  1119. #else /* coff or ecoff */
  1120. #if defined(INCLUDE_ECOFF)
  1121.     bootEcoffInit (); /* use ecoff format */
  1122. #else /* coff */
  1123. #if defined(INCLUDE_COFF)
  1124.     bootCoffInit (); /* use coff format */
  1125. #else   /* coff */
  1126. #if defined(INCLUDE_ELF)
  1127.     bootElfInit (); /* use elf format */
  1128. #endif
  1129. #endif  /* mips cpp no elif */
  1130. #endif
  1131. #endif
  1132. #ifdef  INCLUDE_PCMCIA                                       
  1133.                                                              
  1134.     pcmciaInit ();                      /* init PCMCIA Lib */
  1135. #endif /* INCLUDE_PCMCIA */
  1136. #ifdef INCLUDE_END
  1137.     /* initialize the MUX */
  1138.     muxMaxBinds = MUX_MAX_BINDS;
  1139.     if (muxLibInit() == ERROR)
  1140. return;                              /* can't return ERROR */
  1141.     /* Initialize all the available devices. */
  1142.     for (count = 0, pDevTbl = endDevTbl; pDevTbl->endLoadFunc != END_TBL_END;
  1143.          pDevTbl++, count++)
  1144.         {
  1145.         cookieTbl[count].pCookie = muxDevLoad (pDevTbl->unit, pDevTbl->endLoadFunc,
  1146.                                        pDevTbl->endLoadString,
  1147.                                        pDevTbl->endLoan, pDevTbl->pBSP);
  1148.         if (cookieTbl[count].pCookie == NULL)
  1149.             {
  1150.             printf ("muxLoad failed!n");
  1151.             }
  1152.         cookieTbl[count].unitNo=pDevTbl->unit;
  1153. bzero((void *)cookieTbl[count].devName,END_NAME_MAX);
  1154. pDevTbl->endLoadFunc((char*)cookieTbl[count].devName, NULL);
  1155.         }
  1156. #endif /* INCLUDE_END */
  1157.     taskSpawn ("tBoot", bootCmdTaskPriority, bootCmdTaskOptions,
  1158. bootCmdTaskStackSize, (FUNCPTR) bootCmdLoop,
  1159. 0,0,0,0,0,0,0,0,0,0);
  1160.     }
  1161. /*******************************************************************************
  1162. *
  1163. * usrClock - user defined system clock interrupt routine
  1164. *
  1165. * This routine is called at interrupt level on each clock interrupt.  It is
  1166. * installed a call to sysClkConnect().  It calls any other facilities that
  1167. * need to know about clock ticks, including the kernel itself.
  1168. *
  1169. * If the application needs anything to happen at clock interrupt level,
  1170. * it should be added to this routine.
  1171. *
  1172. * NOMANUAL
  1173. */
  1174. void usrClock (void)
  1175.     {
  1176.     tickAnnounce (); /* announce system tick to kernel */
  1177.     }
  1178. /*******************************************************************************
  1179. *
  1180. * bootCmdLoop - read and execute user commands forever (until boot)
  1181. */
  1182. LOCAL void bootCmdLoop (void)
  1183.     {
  1184.     BOOT_PARAMS params;
  1185.     char line [BOOT_CMD_MAX_LINE];
  1186.     char *pLine;
  1187.     int nwords;
  1188.     int nbytes;
  1189.     int value;
  1190.     int adr;
  1191.     int adr2;
  1192.     FUNCPTR entry;
  1193.     char key = 0;
  1194.     /* flush standard input to get rid of any garbage;
  1195.      * E.g. the Heurikon HKV2F gets junk in USART if no terminal connected.
  1196.      */
  1197.     (void) ioctl (STD_IN, FIOFLUSH, 0 /*XXX*/);
  1198.     if (sysStartType & BOOT_CLEAR)
  1199. printBootLogo ();
  1200.     CLED(0x5);
  1201.     usrBootLineInit (sysStartType);
  1202.     /* print out any new exception message -
  1203.      * the first byte is zeroed after printing so that we won't print
  1204.      * it again automatically.  However, 'e' command will still print out
  1205.      * the remainder. */
  1206.     printExcMsg (sysExcMsg);
  1207.     *sysExcMsg = EOS; /* indicate exception message is old */
  1208.     /* start autoboot, unless no-autoboot specified */
  1209.     bootStringToStruct (BOOT_LINE_ADRS, &params);
  1210.     sysFlags = params.flags;
  1211. #if defined(INCLUDE_TSFS_BOOT) && defined(INCLUDE_TSFS_BOOT_VIO_CONSOLE)
  1212.     /* Wait for Target Server connection */
  1213.     while (!wdbTargetIsConnected())
  1214.      taskDelay (sysClkRateGet());
  1215.     /*
  1216.      * disable the auto-boot mechanism, because the Target Server may not have
  1217.      * time to start its VIO Console before the end of the auto-boot coutdown.
  1218.      */
  1219.     sysStartType |= BOOT_NO_AUTOBOOT;
  1220. #endif
  1221.     if (!(sysStartType & BOOT_NO_AUTOBOOT) &&
  1222. !(sysFlags & SYSFLG_NO_AUTOBOOT))
  1223. {
  1224. int timeout = TIMEOUT;
  1225. if ((sysStartType & BOOT_QUICK_AUTOBOOT) ||
  1226.     (sysFlags & SYSFLG_QUICK_AUTOBOOT))
  1227.     {
  1228.     timeout = 1;
  1229.     }
  1230. key = autoboot (timeout); /* doesn't return if successful */
  1231. }
  1232.     /* If we're here, either we aren't auto-booting, or we got an error
  1233.      * auto-booting, or the auto-booting was stopped. */
  1234.     /* put console in line mode */
  1235.     (void) ioctl (consoleFd, FIOSETOPTIONS, OPT_TERMINAL);
  1236.     /* read and execute the ROM commands */
  1237.     printf ("n");
  1238.     FOREVER
  1239. {
  1240. if (key == '@')
  1241.     {
  1242.     line [0] = key;
  1243.     line [1] = EOS;
  1244.     key = 0;
  1245.     }
  1246. else
  1247.     {
  1248.     printf ("[VxWorks Boot]: ");
  1249.     fioRdString (STD_IN, line, sizeof (line));
  1250.     }
  1251. adr = adr2 = 0;
  1252. nwords = 0;
  1253. /* take blanks off end of line */
  1254. pLine = line + strlen (line) - 1; /* point at last char */
  1255. while ((pLine >= line) && (*pLine == ' '))
  1256.     {
  1257.     *pLine = EOS;
  1258.     pLine--;
  1259.     }
  1260. pLine = line;
  1261. skipSpace (&pLine);
  1262. switch (*(pLine++))
  1263.     {
  1264.     case EOS: /* blank line */
  1265. break;
  1266.     case 'd': /* display */
  1267. if ((getArg (&pLine, &adr, HEX, OPT) == OK) &&
  1268.     (getArg (&pLine, &nwords, DEC, OPT) == OK))
  1269.     d ((char *) adr, nwords);
  1270. break;
  1271.     case 'e': /* exception */
  1272. printExcMsg (sysExcMsg + 1);
  1273. break;
  1274.     case 'f': /* fill */
  1275. if ((getArg (&pLine, &adr, HEX, !OPT) == OK) &&
  1276.     (getArg (&pLine, &nbytes, DEC, !OPT) == OK) &&
  1277.     (getArg (&pLine, &value, DEC, !OPT) == OK))
  1278.     {
  1279.     bfillBytes ((char *) adr, nbytes, value);
  1280.     }
  1281. break;
  1282.     case 't': /* transpose(?) (running out of letters!) */
  1283. if ((getArg (&pLine, &adr, HEX, !OPT) == OK) &&
  1284.     (getArg (&pLine, &adr2, HEX, !OPT) == OK) &&
  1285.     (getArg (&pLine, &nbytes, HEX, !OPT) == OK))
  1286.     {
  1287.     bcopy ((char *) adr, (char *) adr2, nbytes);
  1288.     }
  1289. break;
  1290.     case 'm': /* modify */
  1291. if (getArg (&pLine, &adr, HEX, !OPT) == OK)
  1292.     m ((char *) adr);
  1293. break;
  1294. #ifdef TARGET_HK_V2F
  1295.     case 's': /* system controller */
  1296. {
  1297. extern ULONG sysBCLSet ();
  1298. if (getArg (&pLine, &value, DEC, !OPT) == OK)
  1299.     {
  1300.     if (value != 0)
  1301. {
  1302. (void) sysBCLSet ((ULONG)HK_BCL_SYS_CONTROLLER,
  1303.   (ULONG)HK_BCL_SYS_CONTROLLER);
  1304. printf ("System controller on.n");
  1305. }
  1306.     else
  1307. {
  1308. (void) sysBCLSet ((ULONG)HK_BCL_SYS_CONTROLLER,
  1309.   (ULONG)0);
  1310. printf ("System controller off.n");
  1311. }
  1312.     }
  1313. break;
  1314. }
  1315. #endif /* TARGET_HK_V2F */
  1316. #if defined(TARGET_FRC_30) || defined(TARGET_FRC_31) || defined(TARGET_FRC_33)
  1317.     case 's': /* system controller */
  1318. if (getArg (&pLine, &value, DEC, !OPT) == OK)
  1319.     {
  1320.     if (value != 0)
  1321. {
  1322. *FGA_CTL1 |= FGA_CTL1_SCON;
  1323. printf ("System controller on.n");
  1324. }
  1325.     else
  1326. {
  1327. *FGA_CTL1 &= ~FGA_CTL1_SCON;
  1328. printf ("System controller off.n");
  1329. }
  1330.     }
  1331. break;
  1332. #endif /* TARGET_FRC_30 || TARGET_FRC_31 || TARGET_FRC_33 */
  1333.     case 'p': /* print boot params */
  1334. bootParamsShow (BOOT_LINE_ADRS);
  1335. break;
  1336.     case 'c': /* change boot params */
  1337. bootParamsPrompt (BOOT_LINE_ADRS);
  1338.                 if (strlen(BOOT_LINE_ADRS) <= BOOT_LINE_SIZE)
  1339.                     {
  1340.                     if ((sysNvRamSet (BOOT_LINE_ADRS,
  1341.                         strlen (BOOT_LINE_ADRS) + 1, 0)) == ERROR)
  1342.                         printf("nNOTE: Bootline not saved to NVRAMn");
  1343.                     }
  1344.                 else
  1345.                     printf("nWARNING:Bootline longer than BOOT_LINE_SIZE 
  1346. (%d bytes). Not saved to NVRAMn", (int) BOOT_LINE_SIZE);
  1347.                 break;
  1348.            case 'C':
  1349.    ixdp425IfConfig();
  1350.    break;
  1351.     case 'g': /* go */
  1352. if (getArg (&pLine, (int *) &entry, HEX, !OPT) == OK)
  1353.     go (entry);
  1354. break;
  1355. #ifdef  INCLUDE_NETWORK
  1356.     case 'n':
  1357. netifAdrsPrint (pLine);
  1358. break;
  1359. #ifdef ETHERNET_ADR_SET
  1360.     case 'N':
  1361. mEnet (pLine);
  1362. break;
  1363. #endif  /* ETHERNET_ADR_SET */
  1364. #endif  /* INCLUDE_NETWORK */
  1365.     case '?': /* help */
  1366.             case 'h': /* help */
  1367. bootHelp ();
  1368. break;
  1369.             case '@': /* load and go with internal params */
  1370.     case '$': /* load and go with internal params */
  1371. if (bootLoad (pLine, &entry) == OK)
  1372.     {
  1373.     go (entry);
  1374.     }
  1375. else
  1376.     {
  1377.     taskDelay (sysClkRateGet ()); /* pause a second */
  1378.     reboot (BOOT_NO_AUTOBOOT); /* something is awry */
  1379.     }
  1380. break;
  1381.             case '!':
  1382.             {
  1383.                 char *pBuffer;
  1384.                 UINT32 imageLength;
  1385.                 pBuffer = malloc(LOAD_IMAGE_MAX_SIZE);
  1386.                 if (pBuffer == NULL)
  1387.                 {
  1388.                     printf("Malloc memory failed.n");
  1389.                 }
  1390.                 else
  1391.                 {
  1392.                     if (ImageLoad(pLine, pBuffer, &imageLength) == OK)
  1393.                     {
  1394.                         int i;
  1395.                         char *romStart;
  1396.     
  1397.                         printf("Load bin image okn");
  1398.                         if (imageLength > (LOAD_IMAGE_MAX_SIZE))
  1399.                         {
  1400.                             printf("Image length is too longn");
  1401.                         }
  1402.                         else
  1403.                         {
  1404.                             printf("Begin to program vxworks image into flashn");
  1405.                             if (programFlash(pBuffer, VXWORKS_IMAGE_BASE,
  1406.                                                           VXWORKS_IMAGE_BASE + imageLength,
  1407.                                                           0, 0) != OK)
  1408.                             {
  1409.                                 printf("Program flash errorn");
  1410.                             }
  1411.                         }
  1412.                     }
  1413.                     free(pBuffer);
  1414.                 }
  1415.             }
  1416.             break;
  1417.             case 'b':
  1418.             {
  1419.                 char *pBuffer;
  1420.                 UINT32 imageLength;
  1421.                 pBuffer = malloc(LOAD_IMAGE_MAX_SIZE);
  1422.                 if (pBuffer == NULL)
  1423.                 {
  1424.                     printf("Malloc 4M memory failed.n");
  1425.                 }
  1426.                 else
  1427.                 {
  1428.                     if (ImageLoad(pLine, pBuffer, &imageLength) == OK)
  1429.                     {
  1430.                         int i;
  1431.                         char *romStart;
  1432.     
  1433.                         printf("Load bin image okn");
  1434.                         if (imageLength > (BOOTROM_IMAGE_MAX_SIZE))
  1435.                         {
  1436.                             printf("Image length is too longn");
  1437.                         }
  1438.                         else
  1439.                         {
  1440.                             printf("Begin to program vxworks image into flashn");
  1441.                             if (programFlash(pBuffer, BOOTROM_IMAGE_BASE,
  1442.                                                           BOOTROM_IMAGE_BASE + imageLength,
  1443.                                                           0, 0) != OK)
  1444.                             {
  1445.                                 printf("Program flash errorn");
  1446.                             }
  1447.                         }
  1448.                     }
  1449.                     free(pBuffer);
  1450.                 }
  1451.             }
  1452.             break;
  1453.     case 'l': /* load with internal params */
  1454. if (bootLoad (pLine, &entry) == OK)
  1455.     {
  1456.     printf ("entry = 0x%xn", (int) entry);
  1457.     }
  1458. else
  1459.     {
  1460.     taskDelay (sysClkRateGet ()); /* pause a second */
  1461.     reboot (BOOT_NO_AUTOBOOT); /* something is awry */
  1462.     }
  1463. break;
  1464.             case 'v':                   /* print version & logo */
  1465.                 printBootLogo ();
  1466.                 break;
  1467.     default:
  1468. printf ("Unrecognized command. Type '?' for help.n");
  1469. break;
  1470.             } /* switch */
  1471.         } /* FOREVER */
  1472.     }
  1473. /******************************************************************************
  1474. *
  1475. * autoboot - do automatic boot sequence
  1476. *
  1477. * RETURNS: Doesn't return if successful (starts execution of booted system).
  1478. */
  1479. LOCAL char autoboot 
  1480.     (
  1481.     int timeout /* timeout time in seconds */
  1482.     )
  1483.     {
  1484.     ULONG autoBootTime;
  1485.     int timeLeft;
  1486.     UINT timeMarker;
  1487.     int bytesRead = 0;
  1488.     FUNCPTR entry;
  1489.     char key;
  1490.     if (timeout > 0)
  1491. {
  1492. printf ("nPress any key to stop auto-boot...n");
  1493. /* Loop looking for a char, or timeout after specified seconds */
  1494. autoBootTime = tickGet () + sysClkRateGet () * timeout;
  1495. timeMarker = tickGet () + sysClkRateGet ();
  1496. timeLeft = timeout;
  1497. printf ("%2dr", timeLeft);
  1498.  while ((tickGet () < autoBootTime) && (bytesRead == 0))
  1499.     {
  1500.     (void) ioctl (consoleFd, FIONREAD, (int) &bytesRead);
  1501.     if (tickGet () == timeMarker)
  1502. {
  1503. timeMarker = tickGet () + sysClkRateGet ();
  1504. printf ("%2dr", --timeLeft);
  1505. }
  1506.     }
  1507. }
  1508.     if (bytesRead == 0)    /* nothing typed so auto-boot */
  1509. {
  1510. /* put the console back in line mode so it echoes (so's you can bang
  1511.  * on it to see if it's still alive) */
  1512. (void) ioctl (consoleFd, FIOSETOPTIONS, OPT_TERMINAL);
  1513. printf ("nauto-booting...nn");
  1514. if (bootLoad (BOOT_LINE_ADRS, &entry) == OK)
  1515.     go (entry); /* ... and never return */
  1516. else
  1517.     {
  1518.     printf ("Can't load boot file!!n");
  1519.     taskDelay (sysClkRateGet ()); /* pause a second */
  1520.     reboot (BOOT_NO_AUTOBOOT); /* something is awry */
  1521.     }
  1522. }
  1523.     else
  1524. {
  1525. /* read the key that stopped autoboot */
  1526. read (consoleFd, &key, 1);
  1527. return (key & 0x7f); /* mask off parity in raw mode */
  1528. }
  1529.     return (ERROR); /* for lint - can't really get here */
  1530.     }
  1531. /******************************************************************************
  1532. *
  1533. * printBootLogo - print initial boot banner page
  1534. */
  1535. LOCAL void printBootLogo (void)
  1536.     {
  1537.     printf ("nnnnnnnnnnn");
  1538.     printf ("%28s%s", "","VxWorks System Boot");
  1539.     printf ("nnnCopyright 1984-2002  Wind River Systems, Inc.nnnnnn");
  1540.     printf ("CPU: %sn", sysModel ());
  1541.     printf ("Version: %sn", vxWorksVersion);
  1542.     printf ("BSP version: " BSP_VERSION BSP_REV "n");
  1543.     printf ("Creation date: %snn", creationDate);
  1544.     }
  1545. /*******************************************************************************
  1546. *
  1547. * bootHelp - print brief help list
  1548. */
  1549. LOCAL void bootHelp (void)
  1550.     {
  1551.     static char *helpMsg[] =
  1552. {
  1553. "?",                      "- print this list",
  1554. "@",                      "- boot (load and go)",
  1555. "p",                      "- print boot params",
  1556. "c",                      "- change boot params",
  1557. "l",                      "- load boot file",
  1558. "g adrs",                 "- go to adrs",
  1559. "d adrs[,n]",             "- display memory",
  1560. "m adrs",                 "- modify memory",
  1561. "f adrs, nbytes, value",  "- fill memory",
  1562. "t adrs, adrs, nbytes",   "- copy memory",
  1563. "e",                      "- print fatal exception",
  1564.         "v",                      "- print boot logo with version",
  1565. #ifdef INCLUDE_NETWORK
  1566. "n netif",      "- print network interface device address",
  1567. #if defined(ETHERNET_ADR_SET)
  1568. "N",   "- set ethernet address",
  1569. #endif  /* ETHERNET_ADR_SET */
  1570. #endif  /* INCLUDE_NETWORK */
  1571. #if defined(TARGET_HK_V2F) || defined(TARGET_FRC_30) || 
  1572.     defined(TARGET_FRC_31) || defined(TARGET_FRC_33)
  1573. "s [0/1]",                "- system controller 0 = off, 1 = on",
  1574. #endif /* TARGET_HK_V2F/FRC_30/FRC_31/FRC_33 */
  1575. "$dev(0,procnum)host:/file h=# e=# b=# g=# u=usr [pw=passwd] f=#", "",
  1576. "                          tn=targetname s=script o=other", "",
  1577. #ifdef INCLUDE_SCSI_BOOT
  1578. "boot device: scsi=id,lun              file name: /sd0/vxWorks","",
  1579. #endif /*INCLUDE_SCSI_BOOT*/
  1580. #ifdef INCLUDE_FD
  1581. "boot device: fd=drive,fdType          file name: /fd0/vxWorks","",
  1582. #endif /* INCLUDE_FD */
  1583. #ifdef INCLUDE_IDE
  1584. "boot device: ide=drive,configType     file name: /ide0/vxWorks","",
  1585. #endif /* INCLUDE_IDE */
  1586. #ifdef INCLUDE_ATA
  1587. "boot device: ata=ctrl,drive           file name: /ata0/vxWorks","",
  1588. #endif /* INCLUDE_ATA */
  1589. #ifdef INCLUDE_PCMCIA
  1590. "boot device: pcmcia=sock              file name: /pcmcia0/vxWorks","",
  1591. #endif /* INCLUDE_PCMCIA */
  1592. #ifdef INCLUDE_TFFS
  1593. "boot device: tffs=drive,removable     file name: /tffs0/vxWorks","",
  1594. #endif /* INCLUDE_TFFS */
  1595. #ifdef INCLUDE_TSFS_BOOT
  1596. "boot device: tsfs                     file name: /tgtsvr/vxWorks","",
  1597. #endif /*INCLUDE_TSFS_BOOT */
  1598. "Boot flags:",   "",
  1599. #if defined(TARGET_HK_V2F) || defined(TARGET_FRC_30) || 
  1600.     defined(TARGET_FRC_31) || defined(TARGET_FRC_33)
  1601. "  0x01  - don't be system controller", "",
  1602. #endif /* TARGET_HK_V2F/FRC_30/FRC_31/FRC_33 */
  1603. "  0x02  - load local system symbols", "",
  1604. "  0x04  - don't autoboot", "",
  1605. "  0x08  - quick autoboot (no countdown)", "",
  1606. #ifdef  INCLUDE_NETWORK
  1607. "  0x20  - disable login security", "",
  1608. #ifdef  INCLUDE_DHCPC
  1609. "  0x40  - use dhcp to get boot parameters", "",
  1610. #else
  1611. "  0x40  - use bootp to get boot parameters", "",
  1612. #endif
  1613. "  0x80  - use tftp to get boot image", "",
  1614. "  0x100 - use proxy arp", "",
  1615. #endif  /* INCLUDE_NETWORK */
  1616. NULL
  1617. };
  1618.     FAST char **pMsg;
  1619. #ifdef  INCLUDE_NETWORK
  1620.     FAST NETIF *pNif;
  1621. #endif  /* INCLUDE_NETWORK */
  1622. #ifdef INCLUDE_END
  1623.     int count;
  1624.     char       muxDevName[8];
  1625.     END_TBL_ENTRY* pDevTbl;
  1626. #endif /* INCLUDE_END */
  1627.     printf ("n");
  1628.     for (pMsg = helpMsg; *pMsg != NULL; pMsg += 2)
  1629. printf (" %-21s %sn", *pMsg, *(pMsg + 1));
  1630. #ifdef  INCLUDE_NETWORK
  1631.     printf ("navailable boot devices:");
  1632. #ifdef INCLUDE_END
  1633.     printf ("Enhanced Network Devicesn");
  1634.     for (count = 0, pDevTbl = endDevTbl; pDevTbl->endLoadFunc != END_TBL_END;
  1635.          pDevTbl++, count++)
  1636.         {
  1637.         if (!pDevTbl->processed)
  1638.             {
  1639.             muxDevName [0] = EOS;
  1640.             pDevTbl->endLoadFunc (muxDevName, NULL);
  1641.             printf (" %s%d", muxDevName, pDevTbl->unit);
  1642.             }
  1643.         }
  1644. #endif /* INCLUDE_END */
  1645.     
  1646.     for (pNif = netIf; pNif->ifName != 0; pNif++)
  1647. {
  1648. if (strncmp (pNif->ifName, "lo", 2) != 0)
  1649.     printf (" %s", pNif->ifName);
  1650. }
  1651. #endif  /* INCLUDE_NETWORK */
  1652. #ifdef INCLUDE_SCSI_BOOT
  1653.     printf (" scsi");
  1654. #endif /*INCLUDE_SCSI_BOOT*/
  1655. #ifdef  INCLUDE_FD
  1656.     printf (" fd");
  1657. #endif  /* INCLUDE_FD */
  1658. #ifdef  INCLUDE_IDE
  1659.     printf (" ide");
  1660. #endif  /* INCLUDE_IDE */
  1661. #ifdef  INCLUDE_ATA
  1662.     printf (" ata");
  1663. #endif  /* INCLUDE_ATA */
  1664. #ifdef  INCLUDE_TFFS
  1665.     printf (" tffs");
  1666. #endif  /* INCLUDE_TFFS */
  1667. #ifdef  INCLUDE_TSFS_BOOT
  1668.     printf (" tsfs");
  1669. #endif  /* INCLUDE_TSFS_BOOT */
  1670.     printf ("n");
  1671.     }
  1672. /*******************************************************************************
  1673. *
  1674. * bootLoad - load a module into memory
  1675. *
  1676. * RETURNS: OK or ERROR
  1677. */
  1678. LOCAL STATUS bootLoad 
  1679.     (
  1680.     char *   bootString,
  1681.     FUNCPTR *pEntry
  1682.     )
  1683.     {
  1684.     BOOT_PARAMS params;
  1685. #ifdef  INCLUDE_SCSI_BOOT
  1686. #ifdef  INCLUDE_SCSI2
  1687.      SCSI_OPTIONS options;
  1688.      UINT which;
  1689.      int devBusId;
  1690. #endif  /* INCLUDE_SCSI2 */
  1691. #endif  /* INCLUDE_SCSI_BOOT */
  1692. #ifdef  INCLUDE_NETWORK
  1693.     char nad [20]; /* host's network internet addr */
  1694.     int netmask = 0; /* temporary storage */
  1695.     int  result;  /* classification of address string */
  1696.     unsigned long  leaseLen;  /* lease length field (optional) */
  1697. #ifdef INCLUDE_DHCPC
  1698.     DHCP_LEASE_DATA dhcpLease;
  1699. #endif  /* INCLUDE_DHCPC */
  1700.     char buf [30]; /* string of netmask and timestamps */
  1701.     char  netDev [BOOT_DEV_LEN + 1];
  1702.     char  bootDev [BOOT_DEV_LEN];
  1703.     BOOL backplaneBoot;
  1704.     char * pBootAddr;
  1705.     BOOL  attached = FALSE; /* driver is attached */
  1706.     char                icmpPeer [BOOT_ADDR_LEN];
  1707.     IMPORT int          netTaskPriority;
  1708.     int                 oldTaskPriority;
  1709. #ifdef INCLUDE_END
  1710.     char muxDevName[8];
  1711. #endif /* INCLUDE_END */
  1712. #endif  /* INCLUDE_NETWORK */
  1713.     /* copy bootString to low mem address, if specified */
  1714.     if ((bootString != NULL) && (*bootString != EOS))
  1715. strcpy (BOOT_LINE_ADRS, bootString);
  1716.     /* interpret boot command */
  1717.     if (usrBootLineCrack (BOOT_LINE_ADRS, &params) != OK)
  1718. return (ERROR);
  1719.     /* Display boot parameters */
  1720.     bootParamsShow (BOOT_LINE_ADRS);
  1721.     /* set our processor number: may establish vme access, etc. */
  1722.     sysFlags = params.flags;
  1723.     sysProcNumSet (params.procNum);
  1724.     if(strncmp (params.bootDev, "flash", 5) == 0)
  1725.     {
  1726.         int c;
  1727.         FUNCPTR entry= (FUNCPTR)RAM_LOW_ADRS;
  1728.         memcpy(entry, VXWORKS_IMAGE_BASE, LOAD_IMAGE_MAX_SIZE);
  1729.         printf("load flash okn");
  1730.  go(entry);
  1731.     }
  1732. #ifdef INCLUDE_SCSI_BOOT
  1733.     /*
  1734.      * initialize either the SCSI1 or SCSI2 interface; initialize SCSI2 when
  1735.      * the SCSI2 interface is available.
  1736.      */
  1737. #ifndef INCLUDE_SCSI2
  1738.     scsi1IfInit ();
  1739. #else
  1740.     scsi2IfInit ();
  1741. #endif
  1742.     if (strncmp (params.bootDev, "scsi", 4) == 0)
  1743. {
  1744. int bootDevId = NONE;
  1745. int bootDevLUN = NONE;
  1746. #ifdef INCLUDE_SCSI2
  1747.         /* Set all devices to asynchronous data transfer */
  1748.         which = SCSI_SET_OPT_XFER_PARAMS;
  1749.         options.maxOffset = 0;
  1750.         options.minPeriod = SCSI_SYNC_XFER_MIN_PERIOD;
  1751.         for (devBusId = 0; devBusId < 8; devBusId++)
  1752.             {
  1753.             scsiTargetOptionsSet (pSysScsiCtrl, devBusId, &options, which);
  1754.             }
  1755. #endif /* INCLUDE_SCSI2 */
  1756. /* check for absence of bus ID and LUN, in which case
  1757.  * auto-configure and display results
  1758.  */
  1759. if (strlen (params.bootDev) == 4)
  1760.     {
  1761.     if (!scsiInitialized)
  1762. {
  1763.      if (sysScsiInit () == ERROR)
  1764.     {
  1765.     printErr ("Could not initialize SCSI.n");
  1766.     return (ERROR);
  1767.     }
  1768. scsiInitialized = TRUE;
  1769. }
  1770.     scsiAutoConfig (pSysScsiCtrl);
  1771.     scsiShow (pSysScsiCtrl);
  1772.     /* return ERROR to indicate that no file was loaded */
  1773.     return (ERROR);
  1774.     }
  1775. sscanf (params.bootDev, "%*4s%*c%d%*c%d", &bootDevId, &bootDevLUN);
  1776. if (scsiLoad (bootDevId, bootDevLUN, params.bootFile, pEntry) != OK)
  1777.     {
  1778.     printErr ("nError loading file: errno = 0x%x.n", errno);
  1779.     return (ERROR);
  1780.     }
  1781. return (OK);
  1782. }
  1783. #endif /* INCLUDE_SCSI_BOOT */
  1784. #ifdef  INCLUDE_FD
  1785.     if (strncmp (params.bootDev, "fd", 2) == 0)
  1786. {
  1787. int type = 0;
  1788. int drive = 0;
  1789. if (strlen (params.bootDev) == 2)
  1790.     return (ERROR);
  1791. else
  1792.     sscanf (params.bootDev, "%*2s%*c%d%*c%d", &drive, &type);
  1793. if (fdLoad (drive, type, params.bootFile, pEntry) != OK)
  1794.     {
  1795.     printErr ("nError loading file: errno = 0x%x.n", errno);
  1796.     return (ERROR);
  1797.     }
  1798. return (OK);
  1799. }
  1800. #endif  /* INCLUDE_FD */
  1801. #ifdef INCLUDE_IDE
  1802.     if (strncmp (params.bootDev, "ide", 3) == 0)
  1803. {
  1804. int type = 0;
  1805. int drive = 0;
  1806. if (strlen (params.bootDev) == 3)
  1807.     return (ERROR);
  1808. else
  1809.     sscanf (params.bootDev, "%*3s%*c%d%*c%d", &drive, &type);
  1810. if (ideLoad (drive, type, params.bootFile, pEntry) != OK)
  1811.     {
  1812.     printErr ("nError loading file: errno = 0x%x.n", errno);
  1813.     return (ERROR);
  1814.     }
  1815. return (OK);
  1816. }
  1817. #endif /* INCLUDE_IDE */
  1818. #ifdef INCLUDE_ATA
  1819.     if (strncmp (params.bootDev, "ata", 3) == 0)
  1820. {
  1821. int ctrl  = 0;
  1822. int drive = 0;
  1823. if (strlen (params.bootDev) == 3)
  1824.     return (ERROR);
  1825. else
  1826.     sscanf (params.bootDev, "%*3s%*c%d%*c%d", &ctrl, &drive);
  1827. if (ataLoad (ctrl, drive, params.bootFile, pEntry) != OK)
  1828.     {
  1829.     printErr ("nError loading file: errno = 0x%x.n", errno);
  1830.     return (ERROR);
  1831.     }
  1832. return (OK);
  1833. }
  1834. #endif /* INCLUDE_ATA */
  1835. #ifdef INCLUDE_PCMCIA
  1836.     if (strncmp (params.bootDev, "pcmcia", 6) == 0)
  1837. {
  1838. int sock = NONE;
  1839. if (strlen (params.bootDev) == 6)
  1840.     return (ERROR);
  1841. else
  1842.     sscanf (params.bootDev, "%*6s%*c%d", &sock);
  1843. if (pcmciaLoad (sock, params.bootFile, pEntry) == OK)
  1844.     return (OK);
  1845. /* fall through if the PC card is not a block device.
  1846.  * let's try to boot it from an ethernet device.
  1847.  */
  1848. printErr ("nCannot load from PCMCIA block device."
  1849.           "nTrying alternate PCMCIA devices ... ");
  1850. }
  1851. #endif /* INCLUDE_PCMCIA */
  1852. #ifdef  INCLUDE_TFFS
  1853.     if (strncmp (params.bootDev, "tffs", 4) == 0)
  1854. {
  1855. int drive = 0;
  1856. int removable = 0;
  1857. if (strlen (params.bootDev) == 4)
  1858.     return (ERROR);
  1859. else
  1860.     sscanf (params.bootDev, "%*4s%*c%d%*c%d", &drive, &removable);
  1861. /* tffsLoad () should be after pcmciaInit () */
  1862. if (tffsLoad (drive, removable, params.bootFile, pEntry) != OK)
  1863.     {
  1864.     printErr ("nError loading file: errno = 0x%x.n", errno);
  1865.     return (ERROR);
  1866.     }
  1867. return (OK);
  1868. }
  1869. #endif  /* INCLUDE_TFFS */
  1870. #ifdef  INCLUDE_TSFS_BOOT
  1871.     if (strncmp (params.bootDev, "tsfs", 4) == 0)
  1872. {
  1873. if (tsfsLoad (params.bootFile, pEntry) != OK)
  1874.     {
  1875.     printErr ("nError loading file: errno = 0x%x.n", errno);
  1876.     return (ERROR);
  1877.     }
  1878. return (OK);
  1879. }
  1880. #endif  /* INCLUDE_TSFS_BOOT */
  1881. #ifndef  INCLUDE_NETWORK
  1882.     printf ("nError loading file: networking code not present.n");
  1883.     return (ERROR);
  1884.     }
  1885. #else  /* INCLUDE_NETWORK */
  1886.     /* start the network */
  1887.     /* initialize the generic socket library */
  1888.     if (sockLibInit (NUM_FILES) == ERROR)
  1889.         return (ERROR);
  1890. #if defined(INCLUDE_BSD) || defined(INCLUDE_BSD_SOCKET)
  1891.     /* add the BSD socket library interface */
  1892.     if (sockLibAdd ((FUNCPTR) bsdSockLibInit, AF_INET_BSD, AF_INET) == ERROR)
  1893.         return (ERROR);
  1894.     if (sockLibAdd ((FUNCPTR) bsdSockLibInit, AF_ROUTE, AF_ROUTE) == ERROR)
  1895.         return (ERROR);
  1896. #endif  /* INCLUDE_BSD || INCLUDE_BSD_SOCKET */
  1897.     /* install default socket library interface */
  1898. #ifndef DEFAULT_STREAMS_SOCKET
  1899.     if (sockLibAdd ((FUNCPTR) bsdSockLibInit, AF_INET, AF_INET) == ERROR)
  1900.         return (ERROR);
  1901. #endif  /* DEFAULT_STREAMS_SOCKET */
  1902.     hostTblInit (); /* initialize host table */
  1903.     usrNetProtoInit ();         /* initialize various protocols */
  1904.     netLibInit ();
  1905. #ifdef INCLUDE_PPP
  1906. #ifdef INCLUDE_PPP_CRYPT 
  1907.     cryptRtnInit (&pppCryptRtn); /* install crypt() routine */ 
  1908. #endif /* INCLUDE_PPP_CRYPT */
  1909. #endif /* INCLUDE_PPP */
  1910.     /* attach and configure boot interface */
  1911.     if (strncmp (params.bootDev, "ppp", 3) == 0)
  1912.         {
  1913.         /* booting via ppp */
  1914.         if (usrPPPInit (params.bootDev, params.unitNum, params.ead, 
  1915.                         ((params.gad[0] == EOS)? params.had : params.gad)) 
  1916.                         == ERROR)
  1917.             return (ERROR);
  1918.         }
  1919.     else if (strncmp (params.bootDev, "sl", 2) == 0)
  1920.         {
  1921.         if (usrSlipInit (params.bootDev, params.unitNum, params.ead, 
  1922.                  ((params.gad[0] == EOS)? params.had : params.gad)) 
  1923.  == ERROR)
  1924.     return (ERROR);
  1925.         }
  1926.     else
  1927. {
  1928.         strncpy (bootDev, params.bootDev, sizeof (bootDev));
  1929. if ((strncmp (params.bootDev, "bp", 2) != 0) &&
  1930.             (strncmp (params.bootDev, "sm", 2) != 0))
  1931.     {
  1932.     pBootAddr = params.ead;
  1933.     backplaneBoot = FALSE;
  1934.     }
  1935.         else
  1936.     {
  1937.     if (sysProcNumGet () == 0)
  1938. {
  1939.                 printf (
  1940.                   "Error: processor number must be non-zero to boot from bpn");
  1941.         return (ERROR);
  1942.                 }
  1943.     if (usrBpInit (bootDev, params.unitNum, 0) == ERROR)
  1944. return (ERROR);
  1945.     pBootAddr = params.bad;
  1946.     backplaneBoot = TRUE;
  1947.     }
  1948.         /* Save requested lease length, if any. Ignore lease origin value. */
  1949.         result = bootLeaseExtract (pBootAddr, &leaseLen, NULL);
  1950.         if (result < 0)
  1951.             {
  1952.             printf ("Error reading target address information.n");
  1953.             return (ERROR);
  1954.             }
  1955.         /* Handle any lease information attached to the address entry. */
  1956.         if (result == 2)
  1957.             {
  1958.             /* 
  1959.              * The current address contains both a duration value and a start
  1960.              * time, indicating that it was assigned by a DHCP server.
  1961.              */
  1962.             if (leaseLen != (ULONG)~0)
  1963.                 {
  1964.                 /* Handle a finite address assignment. */
  1965.                 if (sysFlags & SYSFLG_AUTOCONFIG)
  1966.                     *pBootAddr = EOS;    /* Remove for later replacement. */
  1967.                 else
  1968.                     {
  1969.                     /* 
  1970.                      * Technically, this address is invalid since it contains
  1971.                      * a finite interval that requires DHCP for verification
  1972.                      * and the automatic configuration flag is not set.
  1973.                      * However, this situation can only occur if caused 
  1974.                      * deliberately by the user. So, just ignore the timing
  1975.                      * information and assign the address permanently.
  1976.                      */
  1977.                     result = 0;    /* Prevents restoration of time values. */
  1978.                     }
  1979.                 }
  1980.             }
  1981. #ifdef INCLUDE_DHCPC
  1982.         /* Set the DHCP lease information, if needed. */
  1983.         if (sysFlags & SYSFLG_AUTOCONFIG)
  1984.             {
  1985.             /* Save the requested lease length if entered by the user. */
  1986.             if (result == 1)
  1987.                 dhcpLease.lease_duration = leaseLen;
  1988.             else
  1989.                 {
  1990.                 /* 
  1991.                  * The lease length is either not present or left over from
  1992.                  * an earlier lease. Use the default value.
  1993.                  */
  1994.                 dhcpLease.lease_duration = DHCPC_DEFAULT_LEASE;
  1995.                 }
  1996.             dhcpLease.lease_origin = 0;
  1997.             }
  1998. #endif  /* INCLUDE_DHCPC */
  1999.         netmask = 0;
  2000.         bootNetmaskExtract (pBootAddr, &netmask);
  2001. /* start of network attachment code block */
  2002. #ifdef INCLUDE_END
  2003. /* Try an END device first */
  2004.         pCookie=findCookie(params.unitNum, bootDev);
  2005. if (!attached && (pCookie != NULL))
  2006.     {
  2007.             if (muxDevStart (pCookie) != OK)
  2008.                 {
  2009.                 printf("Failed to start device %sn", bootDev);
  2010.                 return (ERROR);
  2011.                 }
  2012. #if 0
  2013.     if (muxIoctl (pEnd, EIOCGMIB2, (char *)&endM2Tbl)
  2014.     == ERROR)
  2015. return (ERROR);
  2016. #endif
  2017.     /* Add our default address resolution functions. */
  2018.     muxAddrResFuncAdd (M2_ifType_ethernet_csmacd, 0x800, ipEtherResolvRtn);
  2019.     if (ipAttach (params.unitNum, bootDev) != OK)
  2020. {
  2021. printf ("Failed to attach TCP/IP to device %s", muxDevName);
  2022. return (ERROR);
  2023. }
  2024.     printf ("Attached TCP/IP interface to %s%d.n", bootDev,
  2025.      params.unitNum);
  2026.     attached = TRUE;
  2027.     }
  2028. #endif /*INCLUDE_END*/
  2029. #ifdef INCLUDE_BSD
  2030. /* Try a BSD 4.4 device attach sequence */
  2031.         if (!attached)
  2032.     {
  2033.     if (usrNetIfAttach (bootDev, params.unitNum, pBootAddr) == OK)
  2034. {
  2035. attached = TRUE;
  2036. }
  2037.     else
  2038. return ERROR;
  2039.     }
  2040.             
  2041. #endif /* INCLUDE_BSD */
  2042. if (!attached)
  2043.     return ERROR; /* attachment failed */
  2044.         /*
  2045.          * Now that any extra parameters following an "=" sign have
  2046.          * been removed (e.g. the pcmcia socket number), build the
  2047.          * network device string by appending the unit number to the
  2048.          * device name.
  2049.          */
  2050.         sprintf (netDev, "%s%d", bootDev, params.unitNum);
  2051.         if ( (sysFlags & SYSFLG_AUTOCONFIG) || (sysFlags & SYSFLG_PROXY) ||
  2052.             (netmask == 0))
  2053.             {
  2054.             struct ifnet * pIf;
  2055.                 
  2056.             /* Initialize the boot device */
  2057.                 
  2058.             if ( (pIf = ifunit (netDev)) == NULL) 
  2059.                 {
  2060.                 printf ("invalid device "%s"n", netDev);
  2061.                 return (ERROR); /* device not attached */
  2062.                 }
  2063.                 
  2064.             if (pIf->if_init != NULL)
  2065.                 {
  2066.                 if ( (*pIf->if_init) (pIf->if_unit) != 0)
  2067.                     {
  2068.                     printf ("initialization failed for device "%s"n",netDev);
  2069.                     return (ERROR);
  2070.                     }
  2071.                 }
  2072.             }
  2073. #ifdef INCLUDE_SM_NET
  2074.   if (backplaneBoot)
  2075.     {
  2076.     if ((params.bad [0] == EOS) &&
  2077.      (strncmp (bootDev, "sm", 2) == 0) &&
  2078. (smNetInetGet (netDev, params.bad, NONE) == OK))
  2079.      printf ("Backplane inet address: %sn", params.bad);
  2080.     if (params.bad [0] == EOS) 
  2081.      {
  2082.      printf ("no backplane address specifiedn");
  2083. return (ERROR);
  2084. }
  2085.     if ((sysFlags & SYSFLG_AUTOCONFIG) && !(sysFlags & SYSFLG_PROXY))
  2086.         {
  2087. #ifdef INCLUDE_DHCPC
  2088.         printf ("Warning! DHCP over backplane may need proxy arpn");
  2089. #else
  2090.         printf ("Warning! BOOTP over backplane may need proxy arpn");
  2091. #endif
  2092.         }
  2093.     }
  2094. #endif /* INCLUDE_SM_NET */
  2095.         if (sysFlags & SYSFLG_PROXY)
  2096.             {
  2097. #ifdef INCLUDE_PROXY_CLIENT
  2098.             printf ("registering proxy client: %s...", pBootAddr);
  2099.             if (proxyReg (netDev, pBootAddr) == ERROR)
  2100.                 {
  2101.                 printf ("failed: error %xn", errno);
  2102.                 return (ERROR);
  2103.                 }
  2104.             printf ("done.n");
  2105. #else /* INCLUDE_PROXY_CLIENT */
  2106.             printf ("proxy client requested but not included.n");
  2107.             return (ERROR);
  2108. #endif /* INCLUDE_PROXY_CLIENT */
  2109.             }
  2110.         /* Get boot parameters over the network if requested. */
  2111.         if (sysFlags & SYSFLG_AUTOCONFIG)
  2112.             {
  2113.             if (bootpGet (netDev, pBootAddr, params.bootFile, params.had,
  2114.                           &netmask) == ERROR)
  2115.                 return (ERROR);
  2116. #ifdef INCLUDE_DHCPC
  2117.             if (dhcpGet (netDev, pBootAddr, params.bootFile, params.had,
  2118.                          &netmask, &dhcpLease) == ERROR)
  2119.                 return (ERROR);
  2120. #endif      /* INCLUDE_DHCPC */
  2121.             }
  2122.         /* configure the device */
  2123.         if (usrNetIfConfig (bootDev, params.unitNum, pBootAddr, 
  2124.                             (char *) NULL, netmask) != OK)
  2125.             return (ERROR);
  2126.         if (netmask == 0)
  2127.             {
  2128.     if (params.gad [0] == EOS)
  2129.                 strcpy (icmpPeer, params.had);
  2130.             else
  2131.         strcpy (icmpPeer, params.gad);
  2132.             (void) icmpMaskGet (netDev, pBootAddr, backplaneBoot ?
  2133.                                 NULL : icmpPeer, &netmask);
  2134.             if (netmask != 0)
  2135.                 {
  2136.                 sprintf (bootDev, "%s%d", bootDev, params.unitNum);
  2137.                 ifMaskSet (bootDev, netmask);
  2138. printf ("Obtained subnet mask 0x%x from %s.n", netmask,
  2139. icmpPeer);
  2140.                 }
  2141.     else
  2142.         printf ("Warning: no netmask specified.n");
  2143.             }
  2144.   /* get gateway address */
  2145. #ifdef INCLUDE_SM_NET
  2146. if (backplaneBoot && (params.gad [0] == EOS) && 
  2147.     !(sysFlags & SYSFLG_PROXY))
  2148.     {
  2149.         struct in_addr host; /* Internet Address */
  2150.         struct in_addr backpl; /* Internet Address */
  2151.         host.s_addr = inet_addr (params.had);
  2152.         backpl.s_addr = inet_addr (params.bad);
  2153.         if ( in_netof(host) != in_netof(backpl) )
  2154.         {
  2155.         /* We can get the gateway address (assumed to be master)  */
  2156.         if ((strncmp (bootDev, "sm", 2) == 0) && 
  2157.             (smNetInetGet (netDev, params.gad, 0) == OK))
  2158.     printf ("Gateway inet address: %sn", params.gad);
  2159. }
  2160.     }
  2161. #endif /* INCLUDE_SM_NET */
  2162.         if (netmask != 0) /* reconstruct address with mask */
  2163.             {
  2164.             sprintf (buf, ":%x", netmask);
  2165.             strcat  (pBootAddr, buf);
  2166.             }
  2167.         /* 
  2168.          * If a value was specified for the requested lease length and the 
  2169.          * address information was not replaced by automatic configuration, 
  2170.          * restore that value for use by later reboots.
  2171.          */
  2172.         if (!(sysFlags & SYSFLG_AUTOCONFIG) && result == 1)
  2173.             {
  2174.             /* 
  2175.              * The value is ignored if <result> is 2, since that is only
  2176.              * possible at this point for permanent DHCP assignments, 
  2177.              * which need no special processing by later reboots.
  2178.              */
  2179.             if (netmask == 0)  /* Create empty netmask field. */
  2180.                 sprintf (buf, "::%lx", leaseLen);
  2181.             else  /* Append requested lease length to netmask. */
  2182.                 sprintf(buf, ":%lx", leaseLen);
  2183.             strcat (pBootAddr, buf);
  2184.             }
  2185. #ifdef INCLUDE_DHCPC
  2186.         /* 
  2187.          * If the target IP address was assigned by a DHCP server, append
  2188.          * the lease times. The presence of those fields in the address string 
  2189.          * will cause the runtime image to renew the corresponding lease.
  2190.          */
  2191.         if (sysFlags & SYSFLG_AUTOCONFIG)
  2192.             {
  2193.             /* Add lease origin and lease duration if needed. */
  2194.             if (dhcpcBindType == DHCP_NATIVE)
  2195.                 {
  2196.                 if (netmask == 0)  /* Create empty netmask field. */
  2197.                     sprintf (buf, "::%lx:%lx", dhcpLease.lease_duration, 
  2198.                                                dhcpLease.lease_origin);
  2199.                 else  /* Append lease timestamps to netmask. */
  2200.                     sprintf(buf, ":%lx:%lx", dhcpLease.lease_duration, 
  2201.                                              dhcpLease.lease_origin);
  2202.                 strcat (pBootAddr, buf);
  2203.                 }
  2204.             }
  2205. #endif    /* INCLUDE_DHCPC */
  2206.         bootStructToString (BOOT_LINE_ADRS, &params);
  2207.         }
  2208.     usrNetIfAttach ("lo", 0, "127.0.0.1");
  2209.     usrNetIfConfig ("lo", 0, "127.0.0.1", "localhost", 0);
  2210.     /* if a gateway was specified, extract the network part of the host's
  2211.      * address and add a route to this network
  2212.      */
  2213.     if (params.gad[0] != EOS)
  2214.         {
  2215. inet_netof_string (params.had, nad);
  2216. routeAdd (nad, params.gad);
  2217.         }
  2218.     /* associate hostName with the specified host address */
  2219.     hostAdd (params.hostName, params.had);
  2220.     /* load specified file */
  2221.     taskPriorityGet (0, &oldTaskPriority);
  2222.     taskPrioritySet (0, netTaskPriority + 1);
  2223.     if (netLoad (params.had, params.bootFile, params.usr,
  2224.  params.passwd, pEntry) != OK)
  2225. {
  2226. printf ("nError loading file: errno = 0x%x.n", errno);
  2227.         taskPrioritySet (0, oldTaskPriority);
  2228. return (ERROR);
  2229. }
  2230.     taskPrioritySet (0, oldTaskPriority);
  2231.     return (OK);
  2232.     }
  2233. #ifdef INCLUDE_END
  2234. /*******************************************************************************
  2235. *
  2236. * findCookie - traverses the cookieTbl to return the right cookie
  2237. *
  2238. * Given the unit number and the device name this function traverses the cookieTbl
  2239. * to return the right cookie. This is a local file.
  2240. *
  2241. * RETURNS: cookie or NULL
  2242. *
  2243. */
  2244. LOCAL void* findCookie
  2245.     (
  2246.     int unitNo,
  2247.     char* devName
  2248.     )
  2249.     {
  2250.     int count;
  2251.     for(count=0;count<32;count++)
  2252. {
  2253. if((cookieTbl[count].unitNo==unitNo) && 
  2254.     (STREQ(cookieTbl[count].devName,devName)))
  2255.         return(cookieTbl[count].pCookie);
  2256. }
  2257.     return (NULL);
  2258.     }
  2259. #endif    /* INCLUDE_END */
  2260. /*******************************************************************************
  2261. *
  2262. * netLoad - downLoad a file from a remote machine via the network.
  2263. *
  2264. * The remote shell daemon on the machine 'host' is used to download
  2265. * the given file to the specified previously opened network file descriptor.
  2266. * The remote userId should have been set previously by a call to iam().
  2267. * If the file does not exist, the error message from the Unix 'host'
  2268. * is printed to the VxWorks standard error fd and ERROR is returned.
  2269. *
  2270. * RETURNS: OK or ERROR
  2271. */
  2272. LOCAL STATUS netLoad 
  2273.     (
  2274.     char *hostName,
  2275.     char *fileName,
  2276.     char *usr,
  2277.     char *passwd,
  2278.     FUNCPTR *pEntry
  2279.     )
  2280.     {
  2281.     int fd;
  2282.     int errFd; /* for receiving standard error messages from Unix */
  2283.     char command [BOOT_FILE_LEN + BOOT_HOST_LEN];
  2284.     BOOL bootFtp = (passwd[0] != EOS);
  2285.     BOOL bootRsh = FALSE;
  2286.     printf ("Loading... ");
  2287. #ifdef INCLUDE_TFTP_CLIENT
  2288.     if (sysFlags & SYSFLG_TFTP) /* use tftp to get image */
  2289.         {
  2290. if (tftpXfer (hostName, 0, fileName, "get", "binary", &fd,
  2291.       &errFd) == ERROR)
  2292.     return (ERROR);
  2293. }
  2294.    else
  2295. #endif
  2296.        {
  2297. if (bootFtp)
  2298.     {
  2299.     if (ftpXfer (hostName, usr, passwd, "", "RETR %s", "", fileName,
  2300.          &errFd, &fd) == ERROR)
  2301. return (ERROR);
  2302.     }
  2303. else
  2304.     {
  2305.     bootRsh = TRUE;
  2306.     sprintf (command, "cat %s", fileName);
  2307.     fd = rcmd (hostName, RSHD, usr, usr, command, &errFd);
  2308.     if (fd == ERROR)
  2309. return (ERROR);
  2310.     }
  2311. }
  2312.     if (bootLoadModule (fd, pEntry) != OK)
  2313. goto readErr;
  2314. #ifdef INCLUDE_TFTP_CLIENT
  2315.     /*
  2316.      * Successful TFTP transfers don't need any cleanup. The tftpXfer()
  2317.      * routine closes all file descriptors once the data has been
  2318.      * retrieved from the remote host.
  2319.      */
  2320.     if (sysFlags & SYSFLG_TFTP) /* used tftp to get image - just exit */
  2321. {
  2322. /* 
  2323.  * Empty the data socket so that the entire file is received from
  2324.  * TFTP server - allows for graceful close on server side 
  2325.  */
  2326.         while ((iosFdValue(fd) != ERROR)
  2327.        && (read (fd, command, sizeof (command)) > 0));
  2328.         return (OK);
  2329. }
  2330. #endif
  2331.     if (bootRsh == FALSE)
  2332. {
  2333. /* Empty the Data Socket before close. PC FTP server hangs otherwise */
  2334. while ((read (fd, command, sizeof (command))) > 0);
  2335.         /* close the data socket before checking for a ftp reply (SPR #77169) */
  2336.         close (fd);
  2337. if (bootFtp)
  2338.     (void) ftpCommand (errFd, "QUIT",0,0,0,0,0,0);
  2339. }
  2340.     else 
  2341.         close (fd);
  2342.     close (errFd);
  2343.     return (OK);
  2344. readErr:
  2345.     /* check standard error on Unix */
  2346.     if (bootRsh == FALSE)
  2347. {
  2348. /* Empty the Data Socket before close. PC FTP server hangs otherwise */
  2349. while ((read (fd, command, sizeof (command))) > 0);
  2350.         /* close the data socket before checking for a ftp reply (SPR #77169) */
  2351.         close (fd);
  2352. if (bootFtp)
  2353.     {
  2354.     (void) ftpReplyGet (errFd, FALSE); /* error message on std. err */
  2355.     (void) ftpCommand (errFd, "QUIT",0,0,0,0,0,0);
  2356.     }
  2357. }
  2358.     else
  2359. {
  2360. char buf [BOOT_FILE_LEN + BOOT_HOST_LEN];
  2361. int errBytesRecv = fioRead (errFd, buf, sizeof (buf));
  2362. if (errBytesRecv > 0)
  2363.     {
  2364.     /* print error message on standard error fd */
  2365.     buf [errBytesRecv] = EOS;
  2366.     printf ("n%s:%s: %sn", hostName, fileName, buf);
  2367.     }
  2368.         close (fd);
  2369. }
  2370.     close (errFd);
  2371.     return (ERROR);
  2372.     }
  2373. #endif  /* INCLUDE_NETWORK */
  2374. /*******************************************************************************
  2375. *
  2376. * bootLoad - load a module into memory
  2377. *
  2378. * RETURNS: OK or ERROR
  2379. */
  2380. LOCAL STATUS ImageLoad 
  2381.     (
  2382.     char *   bootString,
  2383.     char *pEntry,
  2384.     UINT32 *imageSize
  2385.     )
  2386.     {
  2387.     BOOT_PARAMS params;
  2388. #ifdef  INCLUDE_NETWORK
  2389.     char nad [20]; /* host's network internet addr */
  2390.     int netmask = 0; /* temporary storage */
  2391.     int  result;  /* classification of address string */
  2392.     unsigned long  leaseLen;  /* lease length field (optional) */
  2393. #ifdef INCLUDE_DHCPC
  2394.     DHCP_LEASE_DATA dhcpLease;
  2395. #endif  /* INCLUDE_DHCPC */
  2396.     char buf [30]; /* string of netmask and timestamps */