void main(void *ofw) { int boothowto, i = 0, isfloppy, kboothowto; char kernel[PROM_MAX_PATH]; char bootline[PROM_MAX_PATH]; /* Initialize OpenFirmware */ romp = ofw; prom_init(); printf("\r>> %s, Revision %s\n", bootprog_name, bootprog_rev); /* Figure boot arguments */ strncpy(bootdev, prom_getbootpath(), sizeof(bootdev) - 1); kboothowto = boothowto = bootoptions(prom_getbootargs(), bootdev, kernel, bootline); isfloppy = bootdev_isfloppy(bootdev); for (;; *kernel = '\0') { if (boothowto & RB_ASKNAME) { char cmdline[PROM_MAX_PATH]; printf("Boot: "); kgets(cmdline, sizeof(cmdline)); if (!strcmp(cmdline,"exit") || !strcmp(cmdline,"halt")) { prom_halt(); } else if (!strcmp(cmdline, "?") || !strcmp(cmdline, "help")) { help(); continue; } boothowto = bootoptions(cmdline, bootdev, kernel, bootline); boothowto |= RB_ASKNAME; i = 0; } if (*kernel == '\0') { if (kernelnames[i] == NULL) { boothowto |= RB_ASKNAME; continue; } strncpy(kernel, kernelnames[i++], PROM_MAX_PATH); } else if (i == 0) { /* * Kernel name was passed via command line -- ask user * again if requested image fails to boot. */ boothowto |= RB_ASKNAME; } check_boot_config(); start_kernel(kernel, bootline, ofw, isfloppy, kboothowto); /* * Try next name from kernel name list if not in askname mode, * enter askname on reaching list's end. */ if ((boothowto & RB_ASKNAME) == 0 && (kernelnames[i] != NULL)) { printf(": trying %s...\n", kernelnames[i]); } else { printf("\n"); boothowto |= RB_ASKNAME; } } (void)printf("Boot failed! Exiting to the Firmware.\n"); prom_halt(); }
static int loadk(char *kernel, u_long *marks) { int fd, error; vaddr_t va; paddr_t pa; u_long size; int flags = LOAD_KERNEL; if ((fd = open(kernel, 0)) < 0) return (errno ? errno : ENOENT); marks[MARK_START] = 0; if ((error = fdloadfile(fd, marks, COUNT_KERNEL)) != 0) goto out; size = marks[MARK_END] - marks[MARK_START]; /* We want that leading 16K in front of the kernel image */ size += PROM_LOADADDR; va = marks[MARK_START] - PROM_LOADADDR; /* * Extra space for bootinfo and kernel bootstrap. * In compat mode, we get to re-use the space occupied by the * boot program. Traditionally, we've silently assumed that * is enough for the kernel to work with. */ size += BOOTINFO_SIZE; if (!compatmode) size += 512 * 1024; /* Get a physical load address */ pa = getphysmem(size); if (pa == (paddr_t)-1) { error = EFBIG; goto out; } if (boothowto & AB_VERBOSE) printf("Loading at physical address %lx\n", pa); if (pmap_map(va, pa, size) != 0) { error = EFAULT; goto out; } /* XXX - to do: inspect kernel image and set compat mode */ if (compatmode) { /* Double-map at VA 0 for compatibility */ if (pa + size >= bstart) { printf("%s: too large for compat mode\n", kernel); error = EFBIG; goto out; } if (pa != 0 && pmap_map(0, pa, size) != 0) { error = EFAULT; goto out; } loadaddrmask = 0x07ffffffUL; } if (bootdev_isfloppy(prom_bootdevice)) flags &= ~LOAD_BACKWARDS; marks[MARK_START] = 0; error = fdloadfile(fd, marks, flags); out: close(fd); return (error); }