static void doboot(const char *file, int flags) { u_long marks[MARK_MAX]; int fd; int dev, unit, part; char *name; short *p; printf("Starting %s, flags 0x%x\n", file, flags); marks[MARK_START] = 0x100000; if ((fd = loadfile(file, marks, LOAD_KERNEL)) == -1) { printf("loadfile failed\n"); return; } close(fd); if (devparse(file, &dev, &unit, &part, &name) != 0) { printf("XXX: unknown corruption in /boot.\n"); } printf("dev = %x, unit = %d, part = %c, name = %s\n", dev, unit, part + 'a', name); if (dev == 0) { /* SCSI */ dev = X68K_MAKESCSIBOOTDEV(X68K_MAJOR_SD, hostadaptor >> 4, hostadaptor & 15, unit & 7, 0, 0); } else {
int devopen(struct open_file *f, const char *fname, char **file) { int error; int dev, unit, part; struct devsw *dp = &devsw[0]; error = devparse(fname, &dev, &unit, &part, file); if (error) return error; dp = &devsw[dev]; if (dp->dv_open == NULL) return ENODEV; f->f_dev = dp; if ((error = (*dp->dv_open)(f, unit, part)) == 0) return 0; return error; }
int devopen(struct open_file *f, const char *fname, char **file) { int error; int dev, adapt, ctlr, unit, part; struct devsw *dp = &devsw[0]; dev = B_TYPE(bootdev); adapt = B_ADAPTOR(bootdev); ctlr = B_CONTROLLER(bootdev); unit = B_UNIT(bootdev); part = B_PARTITION(bootdev); if ((error = devparse(fname, &dev, &adapt, &ctlr, &unit, &part, file))) return(error); /* * Set up filesystem type based on what device we're opening. */ switch (dev) { case 0: /* ct */ bcopy(file_system_rawfs, file_system, sizeof(struct fs_ops)); break; case 2: /* hd */ bcopy(file_system_ufs, file_system, sizeof(struct fs_ops)); break; case 4: /* sd */ bcopy(file_system_ufs, file_system, sizeof(struct fs_ops)); bcopy(file_system_cd9660, &file_system[1], sizeof(struct fs_ops)); nfsys = 2; break; case 6: /* le */ bcopy(file_system_nfs, file_system, sizeof(struct fs_ops)); break; default: /* XXX what else should we do here? */ printf("WARNING: BOGUS BOOT DEV TYPE 0x%x!\n", dev); return (EIO); } dp = &devsw[dev]; if (!dp->dv_open) return(ENODEV); f->f_dev = dp; if ((error = (*dp->dv_open)(f, adapt, ctlr, part)) == 0) { if ((error = (*punitsw[dev].p_punit)(adapt, ctlr, &unit)) != 0) { goto bad; } opendev = MAKEBOOTDEV(dev, adapt, ctlr, unit, part); return(0); } bad: printf("%s(%d,%d,%d,%d): %s\n", devsw[dev].dv_name, adapt, ctlr, unit, part, strerror(error)); return(error); }
/* * Substitute root value with NetBSD root partition name. */ int patch_bootstring(char *bootspec) { char *sp = bootstring; uint8_t unit, part; int dev; char *file; DPRINTF(("patch_bootstring: %s\n", bootspec)); /* get boot parameters */ if (devparse(bootspec, &dev, &unit, &part, (const char **)&file) != 0) unit = part = 0; DPRINTF(("patch_bootstring: unit = %d, part = %d\n", unit, part)); /* take out the 'root=xxx' parameter */ if ((sp = strstr(bootstring, "root=")) != NULL) { const char *end; end = strchr(sp, ' '); /* strip off leading spaces */ for (--sp; (sp > bootstring) && (*sp == ' '); --sp) ; if (end != NULL) strcpy(++sp, end); else *++sp = '\0'; } DPRINTF(("patch_bootstring: [%s]\n", bootstring)); #define DEVNAMESIZE (MAXDEVNAME + sizeof(" root=/dev/hd") + sizeof("0a")) if (strcmp(devsw[dev].dv_name, "wd") == 0 && strlen(bootstring) <= (511 - DEVNAMESIZE)) { int len; /* omit "nfsroot=" arg on wd boot */ if ((sp = strstr(bootstring, "nfsroot=")) != NULL) { const char *end; end = strchr(sp, ' '); /* strip off leading spaces */ for (--sp; (sp > bootstring) && (*sp == ' '); --sp) ; if (end != NULL) strcpy(++sp, end); else *++sp = '\0'; } /* bsd notation -> linux notation (wd0a -> hda1) */ strcat(bootstring, " root=/dev/hd"); len = strlen(bootstring); bootstring[len++] = unit + 'a'; bootstring[len++] = part + '1'; bootstring[len++] = '\0'; } DPRINTF(("patch_bootstring: -> %s\n", bootstring)); return 0; }