home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / boot / diskBoot.OpenProm / main.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-09-01  |  2.8 KB  |  114 lines

  1. /* 
  2.  * main.c --
  3.  *
  4.  *    The main program for booting.
  5.  *
  6.  * Copyright 1986 Regents of the University of California
  7.  * All rights reserved.
  8.  */
  9.  
  10. #ifdef  notdef
  11. static char rcsid[] = "$Header: /sprite/src/boot/diskBoot.OpenProm/RCS/main.c,v 1.10 91/09/01 16:41:03 dlong Exp $ SPRITE (Berkeley)";
  12. #endif not lint
  13.  
  14.  
  15. #include "sprite.h"
  16. #include "machMon.h"
  17. #include "fsBoot.h"
  18. #include "boot.h"
  19.  
  20. extern Fs_Device fsDevice;        /* Global FS device descriptor */
  21.  
  22. void Exit();
  23.  
  24. /*
  25.  *----------------------------------------------------------------------
  26.  *
  27.  * main --
  28.  *
  29.  *      This gets arguments from the PROM, calls other routines to open
  30.  *      and load the program to boot, and then transfers execution to that
  31.  *      new program.
  32.  *
  33.  * Results:
  34.  *    None.
  35.  *
  36.  * Side effects:
  37.  *    None.
  38.  *
  39.  *----------------------------------------------------------------------
  40.  */
  41.  
  42. main()
  43. {
  44.     ReturnStatus status;
  45.     register int index;            /* Loop index */
  46.     register int entry;            /* Entry point of boot program */
  47.     Fsio_FileIOHandle *handlePtr;    /* Handle for boot program file */
  48.     char devBuf[64], *devName;
  49.     char *fileName = "vmsprite";
  50.  
  51.     /*
  52.      * The Sun prom collects the boot command line arguments and
  53.      * puts makes them available throught the rom vector.
  54.      */
  55.     if (romVectorPtr->v_romvec_version >= 2) {
  56.     devName = *romVectorPtr->bootpath;
  57.     } else {
  58.     MachMonBootParam *paramPtr;        /* Ref to boot params supplied
  59.                          * by the PROM montor */
  60.     paramPtr = *romVectorPtr->bootParam;
  61.     devName = paramPtr->argPtr[0];
  62.     Mach_MonPrintf("Sprite Boot %s %s\n", devName, paramPtr->fileName);
  63.  
  64.     for (index = 0 ; index < 8; ++index) {
  65.         if (paramPtr->argPtr[index] != (char *)0) {
  66.         if (strcmp(paramPtr->argPtr[index], "-dev") == 0 && index < 7) {
  67.             devName = paramPtr->argPtr[++index];
  68.         }
  69.         } else {
  70.         break;
  71.         }
  72.     }
  73.     if (paramPtr->fileName[0]) {
  74.         fileName = paramPtr->fileName;
  75.     }
  76.     }
  77.  
  78.     /*
  79.      * Set up state about the boot device.
  80.      */
  81.     dev_config(devName, &fsDevice);
  82.     Mach_MonPrintf("Sprite Boot %s %s\n", devName, fileName);
  83.     /*
  84.      * Set up state about the disk.
  85.      */
  86.     status = FsAttachDisk(&fsDevice);
  87. #ifndef SCSI3_BOOT
  88.     if (status != SUCCESS) {
  89.     Mach_MonPrintf("Can't attach disk, status <0x%x>\n",  status);
  90.     goto exit;
  91.     }
  92.     Mach_MonPrintf("Open File \"%s\"\n", fileName);
  93. #endif
  94.     /*
  95.      * Open the file to bootstrap.
  96.      */
  97.     status = Open(fileName, FS_READ, 0, &handlePtr);
  98.     if (status != SUCCESS) {
  99.     Mach_MonPrintf("Can't open \"%s\", <%x>\n", fileName, status);
  100.     SunPromDevClose();
  101.     goto exit;
  102.     }
  103.     entry = FileLoad(handlePtr);
  104.     SunPromDevClose();
  105.     if (entry != -1) {
  106. #ifndef NO_PRINTF
  107.     Mach_MonPrintf("Transferring to location 0x%x\n", entry);
  108. #endif
  109.     Boot_Transfer(entry, romVectorPtr);
  110.     }
  111. exit:
  112.     (*romVectorPtr->exitToMon)();
  113. }
  114.