home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / boot / netBoot.OpenProm / main.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-13  |  2.4 KB  |  98 lines

  1. /*-
  2.  * main.c --
  3.  *    First-level boot program for Sprite. Takes its arguments
  4.  *    and uses tftp to download the appropriate kernel image.
  5.  *
  6.  * Copyright (c) 1987 by the Regents of the University of California
  7.  *
  8.  * Permission to use, copy, modify, and distribute this
  9.  * software and its documentation for any purpose and without
  10.  * fee is hereby granted, provided that the above copyright
  11.  * notice appear in all copies.  The University of California
  12.  * makes no representations about the suitability of this
  13.  * software for any purpose.  It is provided "as is" without
  14.  * express or implied warranty.
  15.  *
  16.  *
  17.  */
  18. #ifndef lint
  19. static char rcsid[] =
  20. "$Header: /sprite/src/boot/netBoot.OpenProm/RCS/main.c,v 1.2 91/01/13 02:39:23 dlong Exp $ SPRITE (Berkeley)";
  21. #endif lint
  22.  
  23. #include    "boot.h"
  24. #include    "mach.h"
  25. #include    <string.h>
  26.  
  27. /*-
  28.  *-----------------------------------------------------------------------
  29.  * main --
  30.  *    Main function for downloading stuff.
  31.  *
  32.  * Results:
  33.  *    None.
  34.  *
  35.  * Side Effects:
  36.  *    Begins the booted program.
  37.  *
  38.  *-----------------------------------------------------------------------
  39.  */
  40. main() 
  41. {
  42.     int        unitNum = 0;
  43.     char    *fileName, *devName;
  44.     int        startAddr;
  45.     void    *fileId;
  46.     
  47.     /*
  48.      * Enable interrupts so that L1-a and the milli-second timer work.
  49.      */
  50.     Mach_EnableIntr();
  51.     if (!CheckRomMagic()) {
  52.     printf("Do not know about ROM magic %x\n", RomMagic);
  53.     ExitToMon();
  54.     }
  55.     printf ("\nROM version is %d\n", RomVersion);
  56.     devName = BootDevName();
  57.     printf("Boot Device: %s\n", devName);
  58.     if (RomVersion >= 2) {
  59.     sscanf(devName, "%*[^:]:%x", &unitNum);
  60.     } else {
  61.     sscanf(devName, "%*2c(%*x,%x,%*x)", &unitNum);
  62.     }
  63.     fileName = BootFileName();
  64.     printf("Boot Path: %s\n", fileName);
  65.  
  66.     if ((strcmp(fileName, "vmunix") == 0) || (*fileName == '\0')) {
  67.     fileName = BOOT_FILE;
  68.     }
  69. #ifdef sun4c
  70.     if (strcmp(fileName, "showprom") == 0) {
  71.     ShowProm();
  72.     ExitToMon();
  73.     }
  74. #endif
  75.     printf ("\nSpriteBoot: ");
  76.     PrintBootCommand();
  77.  
  78.     fileId = (void *)DevOpen(devName);
  79.     if (fileId == 0) {
  80.     printf("DevOpen(\"%s\") failed.  Aborting.\n", devName);
  81.     ExitToMon();
  82.     }
  83.     etheropen(fileId);
  84.     startAddr = tftpload(fileId, fileName, unitNum);
  85.     (void)DevClose(fileId);
  86.     
  87.     if (startAddr == -1){
  88.     ExitToMon();
  89.     } else {
  90.     /*
  91.      * Jump to the address returned by tftpload
  92.      */
  93.     printf("Starting execution at 0x%x\n", startAddr);
  94.     startKernel(startAddr, (char *) romVectorPtr);
  95.     return(startAddr);
  96.     }
  97. }
  98.